Skip to main content

GeoJSON

GeoJSON, defined in RFC 7946, is the format of geo values in Ember Nexus. Requests can also send them as WKT (well-known text), and responses can return WKT on request. Internally, geometries are stored in one format and converted when a response is written.

Geo values are only recognized for properties which the schema defines with one of the geo types. Without a definition, a GeoJSON object is stored as a plain object and a WKT string as a plain string, without validation, conversion or geo index.

Supported geometries

Schema typeGeoJSONWKT example
pointPointPOINT (13.4 52.5)
linestringLineStringLINESTRING (0 0, 1 1)
polygonPolygonPOLYGON ((0 0, 10 0, 10 10, 0 0))
multipointMultiPointMULTIPOINT ((0 0), (1 1))
multilinestringMultiLineStringMULTILINESTRING ((0 0, 1 1), (2 2, 3 3))
multipolygonMultiPolygonMULTIPOLYGON (((0 0, 1 0, 1 1, 0 0)), ((5 5, 6 5, 6 6, 5 5)))

GeometryCollection and Feature objects are not supported, store each geometry in its own property instead.

Positions are [longitude, latitude], or [longitude, latitude, altitude] for properties with "dimensions": 3, in WGS 84. Longitudes range from -180 to 180 and latitudes from -90 to 90. Rings of polygons have to be closed: their last position equals the first one. The values are checked for their structure and these ranges, not for e.g. self-intersections.

WKT

WKT is accepted as input for every geo property, whatever format the responses use. It is the compact format for ingesting data, e.g. from a spatial database or a CSV export, and may also be used for queries in the future.

  • Keywords are case-insensitive, and the Z marker is optional for positions with three coordinates: POINT Z (13.4 52.5 34) equals POINT (13.4 52.5 34).
  • An SRID=4326; prefix is accepted, other reference systems are rejected.
  • MULTIPOINT accepts positions with and without their own parentheses: MULTIPOINT ((0 0), (1 1)) and MULTIPOINT (0 0, 1 1).
  • EMPTY geometries are not supported.
{
"type": "Place",
"data": {
"location": "POINT (13.4 52.5)"
}
}

Response format

Responses contain GeoJSON by default. Requests can ask for WKT with the Prefer header of RFC 7240:

GET /<uuid>
Prefer: geometry=wkt
PreferenceGeo values in the response
noneGeoJSON
geometry=geojsonGeoJSON
geometry=wktWKT strings

The preference applies to the whole response, every geo value of every element has the same format. Responses which honored a preference carry Preference-Applied: geometry=wkt (or geometry=geojson), unknown preferences and values are ignored. Responses vary by the header, so they carry Vary: Prefer.

The preference is supported by GET /<uuid>, the collections GET /, GET /<uuid>/children, GET /<uuid>/parents and GET /<uuid>/related, and the element hydration step of POST /search and POST /search/<uuid>. Other search steps work with the internal format.

The ETag of a response in another format than GeoJSON gets the name of the format appended: an element whose ETag is "abcdefg" has the ETag "abcdefg-wkt" in WKT responses, on every endpoint above, whether the element has geo values or not. If-None-Match and If-Match accept both forms, see caching and conditional requests.

Expressions

Schema rules, search expressions and the playground see geo values as GeoJSON, whatever format the request used. The geo functions of Expr create, convert, measure and compare them, e.g. geoContains(document.area, document.location) or geoFromWkt('POINT (13.4 52.5)'). They check geometries more strictly than writes do: self-intersecting rings, for example, are stored, but fail the geo functions.