A minimal geofencing application build with gofiber, using an embedded rtree and geoindex for fast geospatial lookups.
Bring your own data, pass a location and receive the geofences that your location is currently in.
go install github.com/iwpnd/detectr/cmd/detectr-server@latest
➜ detectr --help
NAME:
detectr - geofence application
USAGE:
detectr [global options] command [command options] [arguments...]
COMMANDS:
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--port value define port (default: 3000)
--require-key use keyauth (default: false)
--log-level value set loglevel (default: "error")
--data value path to dataset to load with app
--help, -h show help (default: false)
# start up
detectr --data my_featurecollection.geojson
# send a location
curl -X POST -H "Content-Type: application/json" -d '{"lng":13.4042367,"lat":52.473091}' http://localhost:3000/location
>> {
"data": {
"elapsed": "150.75µs",
"request": {
"lat": 52.473091,
"lng": 13.4042367
},
"matches": [
{
"type": "Feature",
"properties": {"id":"my geofence"},
"geometry": {
"coordinates": [
[
[
13.41493887975497,
52.47961028115867
],
[
13.393534522441712,
52.47961028115867
],
[
13.393534522441712,
52.466572160399664
],
[
13.41493887975497,
52.466572160399664
],
[
13.41493887975497,
52.47961028115867
]
]
],
"type": "Polygon"
}
}
]
}
}
MIT
- Triggered by this article on the UBER engineering blog about UBERs highest query per second service.
- Heavily inspired by Tile38 and build because I wanted to understand how Tile38 works under the hood.
Benjamin Ramser - @iwpnd
Project Link: https://github.com/iwpnd/detectr