LineString
linestring holds a LineString, a line through two or more positions, e.g. a route. Values can be written as GeoJSON or as and are stored in one internal format. Responses contain GeoJSON, or WKT if the request asks for it with Prefer: geometry=wkt, see .
Note: geo values are only recognized for properties which the schema defines as linestring. 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.
Expressions
Schema and search expressions see values of this type as GeoJSON, also if they were written as WKT. The geo work on them: geoLength(document.route) measures the length in meters, geoIntersects checks whether it crosses another geometry.
Settings
| Setting | Meaning |
|---|---|
dimensions | 2 (default) for [longitude, latitude], 3 for [longitude, latitude, altitude]. Every position of a value has to have this many coordinates. |
The settings of every apply as well.
Storage
| Database | Stored as | Notes |
|---|---|---|
| MongoDB | GeoJSON object | (default), with a 2dsphere index for the intent geo |
| Neo4j | not supported | Neo4j has no native type for it, "storage": "graph" is rejected with 400 Bad Request |
| Elasticsearch | geo_shape | search copy |
The search is written unless the property or the type sets "search": false. Where a property is stored is explained in .
Indices
geo, see geo .
Limits
Positions are [longitude, latitude] in WGS 84 (longitude -180 to 180, latitude -90 to 90), longitude first, unlike most map UIs, which show latitude first. Lines need at least two positions. Neo4j only stores points, see above. MongoDB documents are limited to 16 MB, which limits the number of positions, see .
Example
Schema:
{ "type": "linestring", "index": "geo"}| Format | Input | Output |
|---|---|---|
| GeoJSON | {"type": "LineString", "coordinates": [[13.37, 52.51], [13.4, 52.52], [13.45, 52.5]]} | {"type": "LineString", "coordinates": [[13.37, 52.51], [13.4, 52.52], [13.45, 52.5]]}, the default |
| WKT | "LINESTRING (13.37 52.51, 13.4 52.52, 13.45 52.5)" | "LINESTRING (13.37 52.51, 13.4 52.52, 13.45 52.5)" with Prefer: geometry=wkt |