A worldwide regions or fences database, give it coordinates it answers back with informations for the fence like country and state
Go Makefile Python Protocol Buffer
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
cmd
db/boltdb
geostore
mobile
testdata
.gitignore
Dockerfile
Dockerfile.build
LICENSE
Makefile
README.md
coverer.go
coverer_test.go
fence.go
geofence.go
stree.go
wercker.yml

README.md

wercker status Go Report Card GoDoc

Region à gogo is a microservice, it's a simple database that returns metadata associated to a fence for a given location.

It uses S2 and a segment tree to create a fast geo shape database, details of implementation are described in this blog post.

It can also be used directly from docker docker run -P akhenakh/regionagogo

Data

You can use any geo data but the provided GeoJSON comes from Natural Earth Data. Some regions are not precise enough and some accentuated names are wrong, if you are aware of a better source please tell me.

It works too with the better Gadm Data but the data are not free for commercial use.

Regionagogo is using a BoltDB datafile to store the fences and a small segment tree as index lives in memory.

Build & Install

go get github.com/akhenakh/regionagogo
cd $GOPATH/src/github.com/akhenakh/regionagogo
make

To generate the database from GeoJSON use the provided ragogenfromjson command, you can specify the fields you want from the GeoJSON properties to be saved into the DB:

ragogenfromjson -filename testdata/world_states_10m.geojson -importFields iso_a2,name -dbpath ./region.db

Usage

Run regionagogo -dbpath ./region.db, it will listen on port 8082.

You can query via HTTP GET:

GET /query?lat=19.542915&lng=-155.665857

{
    "code": "US",
    "name": "Hawaii"
}

Using it as a library

You can use it in your own code without the HTTP interface:

gs := regionagogo.NewGeoSearch("region.db")
r := gs.StabbingQuery(msg.Latitude, msg.Longitude)

TODO

  • move the cache outside of boltdb storage to make it generic
  • implement an in memory storage