geobeyond / Arpav-PPCV-backend

Backend di Piattaforma Proiezioni Climatiche per il Nord-Est.
Creative Commons Attribution 4.0 International
0 stars 1 forks source link

Find municipality by coordinates #137

Closed ricardogsilva closed 1 month ago

ricardogsilva commented 1 month ago

This PR adds a new /api/v2/municipalities endpoint which is able to return a list of municipalities in GeoJSON format.

Among other filters, it accepts a coords query parameter which must be specified in WKT format and it can be either a point or a polygon. This will be used to find intersecting municipalities.

Example usage:

http://localhost:8877/api/v2/municipalities/?coords=POINT(11.4223 46.7143)

Response:

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "MultiPolygon",
        "coordinates": [ "Omitted for brevity" ]
      },
      "properties": {
        "province_name": "Bolzano/Bozen",
        "name": "Sarentino/Sarntal",
        "region_name": "Trentino-Alto Adige/Südtirol"
      },
      "id": "e8ade09f-18af-47ca-857a-d392f8082712"
    }
  ],
  "links": {
    "self": "http://localhost:8877/api/v2/municipalities/?limit=20&offset=0&coords=POINT(11.4223 46.7143)",
    "next": null,
    "previous": null,
    "first": "http://localhost:8877/api/v2/municipalities/?limit=20&offset=0&coords=POINT(11.4223 46.7143)",
    "last": "http://localhost:8877/api/v2/municipalities/?limit=20&offset=0&coords=POINT(11.4223 46.7143)"
  },
  "number_matched": 1,
  "number_total": 182,
  "number_returned": 1
}