Giter VIP home page Giter VIP logo

terra's Introduction

Terra

Terra is NOT usable yet.

Tile38 is an open source (MIT licensed), in-memory geolocation data store, spatial index, and realtime geofence. It supports a variety of object types including lat/lon points, bounding boxes, XYZ tiles, Geohashes, and GeoJSON.

Terra is a Tile38 based Geofence server in Rust. Terra is meant to be a memory-safe and highly concurrent geofence server. Terra is meant to be used for my personal location-based projects. It in no way is a replacement for the amazing Tile38 server, but is actually an augmentation to it.

Terra is NOT available as a crate on crates.io yet, although I plan to.

Terra supports two types of Geofences: Circular and Polygonal. (so far)

Getting started

The easiest way to to clone the project and run as a Rust binary project like this:

~$ git clone https://github.com/younisshah/terra.git

~$ cd terra

~$ cargo check

~$ cargo build

~$ cargo run

If all went well, you'll see something like this:

          ________
          ___  __/_____ ______________________ _
          __  /   _  _ \__  ___/__  ___/_  __ `/       Terra is a Tile38 based Geofence server.
          _  /    /  __/_  /    _  /    / /_/ /        v0.0.1
          /_/     \___/ /_/     /_/     \__,_/
[+] Checking if Tile38 is running at '127.0.0.1:9851' is live... <br/>
[+] Tile38 is RUNNING.<br/>
[+] Terra started! Listening for incoming connections on '127.0.0.1:9761'.<br/>

By default, Terra runs on port 9761 and expects an instance of Tile38 server running on it's default port 9851. However, the defaults can be changed. Run the following command to see Terra's usage:

~$ ./target/debug/terra --help

Terra 0.0.1 <br/>

 USAGE:<br/>
     terra [FLAGS]<br/>

 FLAGS:<br/>
         --help        Prints help information<br/>
     -h, --host        Set the host address to listen for new connections<br/>
     -p, --port        Set the port number to listen for new connections<br/>
         --t38_host    Set the host address of Tile38 server<br/>
         --t38_port    Set the port number of Tile38 server<br/>
     -V, --version     Prints version information<br/>

Once, Terra is up and running, create a WebSocket connection like this.

This is a JS client. You can use any WebSocket client:

const socket = new WebSocket("ws://localhost:9761");
socket.onmessage = function(event) {
  console.log(event.data);
};

Send fence creation request:

To create a circular geofence:

Send the following data:

const fence = {fence_type: "circle", fleet_name: "my_circular_fence", lat: "12.3", lng: "34.4", radius: "6000"};
socket.send(fence)
To create a polygonal geofence:

Send the following data:

const fence = { fence_type: "polygon", fleet_name : "my_polygonal_fence", id: "some_id", coordinates: [[12.12, 43.32],[12.12, 53.32],[12.4, 55.2],[12.12, 43.32]]};
socket.send(fence);

That's it!

TODO

  • Write sane documentation.
  • Expose server API.
  • Change to a crate.
  • Add more shapes of geofences.

terra's People

Contributors

younisshah avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.