ajnisbet / opentopodata

Open alternative to the Google Elevation API!
https://www.opentopodata.org
MIT License
327 stars 71 forks source link

Feature: Output as geojson Feature Collection #86

Closed arnesetzer closed 9 months ago

arnesetzer commented 1 year ago

Heyo, I needed the geojson format for my project and thought it might be useful for someone else. The parameter is set via config.yaml so that the format of the API can't be changed by mistake.

ajnisbet commented 1 year ago

Thank you for this! Geojson responses are something I would love to support. I have a few changes I'd like to make to your implementation though: I'll try and get to these over the next few weeks

  1. Use a FeatureCollection of Point, rather than a LineString. OTD can return a single point, whereas a LineString is only valid for 2 or more points. Also a LineString can't have individual properties.
  2. Return a complete valid geojson response (including type key) and removing the status key.
  3. Including the data source as a property. This also allows extending the response if the API changes in the future.
  4. Making the parameter selectable by url query option rather than server config (in the spirit of a RESTful API where the client can select the representation of the result).

So the complete response would be something like

{ "type": "FeatureCollection",
    "features": [
      { "type": "Feature",
        "geometry": {"type": "Point", "coordinates": [122.1, -42.1, 1234]},
        "properties": {"dataset": "test-dataset"}
      },
      { "type": "Feature",
        "geometry": {"type": "Point", "coordinates": [122.2, -42.1, 2345]},
        "properties": {"dataset": "test-dataset"}
      }
   ]
}

Would such a format still be useful for you?

arnesetzer commented 1 year ago

Hi, thanks for your input. I'm working on it.

Would such a format still be useful for you?

Not really, but I already minimized the API to my needs (remove CORS-check, only allow POST jsonised, hardcoded values, etc.) so it doesn't matter 😄

arnesetzer commented 1 year ago

Love the Lat-Lon or Lon-Lat discussion 😅

make test finishes without any errors, but I'm not familiar enough with pytest to write tests for the new case

arnesetzer commented 1 year ago

Ready for review 😄

ajnisbet commented 1 year ago

Amazing thank you! I have seen this, will get it merged as soon as life allows.

arnesetzer commented 9 months ago

@ajnisbet Any news here? 😃