GeoJSON API

GeoJSON API provides an interface for storage of GeoJSON [1] features and geometries.

Foreign members (extra JSON keys) are allowed for any input GeoJSON but omitted during save (except id which is used for entity update).

Save Geometry

GeoJSONs are canonicalized before they are stored. Exteriors of Polygon and MultiPolygon geometries are made counterclockwise and holes clockwise. Coordinates are rounded to 7 decimal places.

Geometry ID is a cryptographic hash function [2] of provided GeoJSON.

POST /geojson/geometry/save

Request body is a GeoJSON geometry [3] to be stored.

Example request:

{
    "type": "Polygon",
    "coordinates": [[
        [14.420124292373657, 50.08701720781953],
        [14.422232508659363, 50.08701720781953],
        [14.422232508659363, 50.08817024264307],
        [14.420124292373657, 50.08817024264307],
        [14.420124292373657, 50.08701720781953]
    ]]
}

Response contains stored canonicalized GeoJSON geometry with its ID.

Response JSON Object:
 
  • id (string) – ID of the geometry

Example response:

{
    "type": "Polygon",
    "id": "gPYMnyHqZg",
    "coordinates": [[
        [14.4201242, 50.0870172],
        [14.4222325, 50.0870172],
        [14.4222325, 50.0881702],
        [14.4201242, 50.0881702],
        [14.4201242, 50.0870172]
    ]]
}

Get Geometry

Knowledge of geometry ID is the only requirement to get a geometry.

POST /geojson/geometry/get
Request JSON Object:
 
  • geometryId (string) – required; ID of the geometry to get

Example request:

{
    "geometryId": "gPYMnyHqZg"
}

Response is a GeoJSON geometry [3].

Response JSON Object:
 
  • id (string) – ID of the geometry

Example response:

{
    "type": "Polygon",
    "id": "gPYMnyHqZg",
    "coordinates": [[
        [14.4201242, 50.0870172],
        [14.4222325, 50.0870172],
        [14.4222325, 50.0881702],
        [14.4201242, 50.0881702],
        [14.4201242, 50.0870172]
    ]]
}

Save Feature

Geometrical part is internally stored with Save Geometry.

POST /geojson/feature/save

Request body is a GeoJSON Feature [4] to be stored.

Request JSON Object:
 
  • id (string) – optional; if not given, a new entity is created, otherwise an existing entity is replaced by this one.

Example request:

{
    "type": "Feature",
    "id": "gPYMnyHqZg",
    "properties": {
        "name": "Old Town Square, Prague"
    },
    "geometry": {
        "type": "Polygon",
        "coordinates": [[
            [14.420124292373657, 50.08701720781953],
            [14.422232508659363, 50.08701720781953],
            [14.422232508659363, 50.08817024264307],
            [14.420124292373657, 50.08817024264307],
            [14.420124292373657, 50.08701720781953]
        ]]
    }
}
Response JSON Object:
 
  • featureId (string) – ID of the feature
  • geometryId (string) – ID of the geometrical part, see Save Geometry.

Example response:

{
    "featureId": "abYMozHqZg",
    "geometryId": "gPYMnyHqZg"
}

Get Feature

User can get only features she owns.

POST /geojson/feature/get
Request JSON Object:
 
  • featureId (string) – required; ID of the feature to get

Example request:

{
    "featureId": "abYMozHqZg"
}

Response is a GeoJSON Feature [4].

Response JSON Object:
 
  • id (string) – ID of the feature
  • geometry.id (string) – ID of the geometry

Example response:

{
    "type": "Feature",
    "properties": {
        "name": "Old Town Square, Prague"
    },
    "id": "abYMozHqZg",
    "geometry": {
        "type": "Polygon",
        "id": "gPYMnyHqZg",
        "coordinates": [[
            [14.4201242, 50.0870172],
            [14.4222325, 50.0870172],
            [14.4222325, 50.0881702],
            [14.4201242, 50.0881702],
            [14.4201242, 50.0870172]
        ]]
    }
}

Delete Feature

User can delete only features she owns.

POST /geojson/feature/delete
Request JSON Object:
 
  • featureId (string) – required; ID of the feature to be deleted

Example request:

{
    "featureId": "abYMozHqZg"
}

Example response:

{}

List Features

This endpoint returns a list of features created by the authorized user. The endpoint is paginated.

POST /geojson/feature/list
Request JSON Object:
 
  • cursor (string) – optional; next page cursor

Example request:

{}
Response JSON Object:
 
  • results (list) – list of geometries
  • results[i] (object) – i-th GeoJSON Feature [4] owned by the client
  • results[i].id (string) – ID of i-th feature
  • results[i].geometry.id (string) – ID of geometry of i-th feature
  • cursor (string) – next page cursor

Example response:

{
    "cursor": null,
    "results": [
        {
            "type": "Feature",
            "id": "abYMozHqZg",
            "properties": {
                "name": "Old Town Square, Prague"
            },
            "geometry": {
                "type": "Polygon",
                "id": "gPYMnyHqZg",
                "coordinates": [[
                    [14.4201242, 50.0870172],
                    [14.4222325, 50.0870172],
                    [14.4222325, 50.0881702],
                    [14.4201242, 50.0881702],
                    [14.4201242, 50.0870172]
                ]]
            }
        }
    ]
}

Footnotes

[1]https://tools.ietf.org/html/rfc7946
[2]https://en.wikipedia.org/wiki/Cryptographic_hash_function
[3](1, 2) https://tools.ietf.org/html/rfc7946#section-3.1
[4](1, 2, 3) https://tools.ietf.org/html/rfc7946#section-3.2