Log geojson to a custom URL
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
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"}}]}
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.
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.
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.