For Dashboard Designers APIs Geo-Spatial Index
Friday, November 11, 2022 12:52 PMGeo-spatial index
Description
Using this API one can index a collection of polygons (usually geographic areas) then subsequently, very quickly, query for one (or multiple) point(s) what polygons contain that point.
This API uses FeatureCollection
, Polygon
and MultiPolygon
GeoJSON structures
Limitations
- Currently the index supports only one collection of polygons at a time.
- The index is kept in memory so more polygons means more (server) memory used.
- Index data is not saved on disk meaning that it will be lost when the Graphileon server is restarted.
Endpoints
Add features
Description: adds geographic polygons to the index
URL: /api/spatial-index/add-features
Method: POST
Parameters:
Key | Description | Type | Possible values |
---|---|---|---|
type |
Type of GeoJSON data structure | string |
FeatureCollection |
features |
List of GeoJSON features. Only Polygon and MultiPolygon structures are indexed. |
array |
|
<feature>.id or <feature>.properties.id |
Unique key to identify a specific feature in the index. This key will pe returned by query-points endpoint |
string / number |
Response: true
(success) when index was updated successfully
Clear
Description: empties the index (removes all indexed polygons)
URL: /api/spatial-index/clear
Method: GET
Parameters: none
Response: true
(success) when index was updated successfully
Query points
Description: given an array of geographic points returns, for each point, the list of ids of the geographic polygons that contain the given point
URL: /api/spatial-index/query-points
Method: POST
Parameters:
Key | Description | Type | Possible values |
---|---|---|---|
points |
Array of geographical positions (points) | array |
|
<point>.latitude |
Position of the point on the y axis |
float |
|
<point>.longitude |
Position of the point on the x axis |
float |
Response: for each point an array of Feature ids (already added to the index) that contain (intersect) with the point. (array
of array
of polygon ids
)