Skip to content

iwpnd/detectr

Repository files navigation

detectr

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.

Installation

cli

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)

Usage

# 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"
          }
        }
    ]
  }
}

License

MIT

Acknowledgement

Maintainer

Benjamin Ramser - @iwpnd

Project Link: https://github.com/iwpnd/detectr