For Dashboard Designers APIs Geo-Spatial Index
Friday, May 10, 2024 10:15 AMGeo-spatial index
Description
Using this API one can index a collection of geoJSON features (usually geographic areas) then subsequently, very quickly, query for one (or multiple) point(s) what polygons contain that point.
This API uses FeatureCollection
, Point
, LineString
, Polygon
and MultiPolygon
GeoJSON structures
Index Name
Index name (indexName
) gets used by most of the endpoints. It is a string that identifies the index. If not provided, the default index name is default
.
Endpoints
Add features
Description: adds geographic features to the index
URL: /api/spatial-index/add-features
Method: POST
Parameters:
Key | Description | Type | Possible values |
---|---|---|---|
indexName |
Name of the index | string |
default |
type |
Type of GeoJSON data structure | string |
FeatureCollection |
features |
List of GeoJSON features. Only Point , LineString , 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 endpoints |
string / number |
Response: true
(success) when index was updated successfully
Remove features
Description: removes geographic features from the index
URL: /api/spatial-index/remove-features
Method: POST
Parameters:
Key | Description | Type | Possible values |
---|---|---|---|
indexName |
Name of the index | string |
default |
featureIds |
GeoJSON Feature item IDs | [string | number] |
Response: true
(success) when index was updated successfully
Unload
Description: removes the index from the memory
URL: /api/spatial-index/unload
Method: POST
Parameters:
Unloads each spatial index from memory given array of indexName
If no indexName is given, unloads all spatial indexes
Clear
Description: empties the index (removes all indexed polygons)
URL: /api/spatial-index/clear
Method: DELETE
Parameters:
Key | Description | Type | Possible values |
---|---|---|---|
indexName |
Name of the index | string |
default |
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
)
query-polygon
Description: given a polygon returns the list of ids of the geographic polygons that intersect with the given polygon
URL: /api/spatial-index/query-polygon
Method: POST
Parameters:
Key | Description | Type | Possible values |
---|---|---|---|
indexName |
Name of the index | string |
default |
type |
GeoJSON Feature | string |
Feature |
geomety |
GeoJSON Polygon | object |