gpslogger icon indicating copy to clipboard operation
gpslogger copied to clipboard

Log geojson to a custom URL

Open dshanske opened this issue 7 years ago • 6 comments

Would you be able to add a preset to log geojson to a custom URL? Looking to try this product. I could probably write a template, but I would imagine it could be useful for others.

https://github.com/aaronpk/Compass

dshanske avatar Oct 23 '18 23:10 dshanske

Hi, POSTing a file to a URL is too complex for the app. So what you can try instead is in the custom URL logger.

Looking at the Compass API - it seems like you just need an HTTP POST with a body

POST /api/input?token=XXXXXXX HTTP/1.1
Content-type: application/json

{
  "locations": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [-122.621, 45.535]
      },
      "properties": {
        "timestamp": "2017-01-01T10:00:00-0700",
        "horizontal_accuracy": 65
      }
    }
  ]
}

I think this means you can send such a body with one point each (even though it refers to a locaitons array) to the API endpoint and it will record each one in its database.

Your custom URL body can look like

{
  "locations": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [%LAT, %LON]
      },
      "properties": {
        "timestamp": "%TIME",
        "horizontal_accuracy": %ACC
      }
    }
  ]
}

Or try it in one line

{"locations":[{"type":"Feature","geometry":{"type":"Point","coordinates":["%LAT","%LON"]},"properties":{"timestamp":"%TIME","horizontal_accuracy":"%ACC"}}]}

mendhak avatar Oct 24 '18 18:10 mendhak

Also worth mentioning - it's JSON so there'll be a lot of fiddling with the quotes and braces but this should get you there. Try with a hardcoded body block first.

mendhak avatar Oct 24 '18 18:10 mendhak

I actually meant using the custom URL, not the file feature. I was just thinking a %GEOJSON% to output a geojson point in a template might be helpful as a feature.

dshanske avatar Oct 24 '18 22:10 dshanske

That would be very nice if we can send it in a http post request using json by just filling the variable with gps data.

hgultekin avatar Jun 03 '19 23:06 hgultekin