INTERSECTS key [CURSOR start] [LIMIT count] [SPARSE spread] [MATCH pattern] [WHERE field min max ...] [NOFIELDS] [FENCE] [DETECT what] [COMMANDS which] [COUNT|IDS|OBJECTS|POINTS|BOUNDS|(HASHES precision)] (GET key id)|(BOUNDS minlat minlon maxlat maxlon)|(OBJECT geojson)|(TILE x y z)|(QUADKEY quadkey)|(HASH geohash)
INTERSECTS searches a collection for objects that intersect a specified bounding area.
WITHIN and INTERSECTS have identical syntax. The only difference between the two is that WITHIN returns objects that are contained inside an area, and intersects returns objects that are contained or intersects an area.
This command has many options, but at it’s most simplest it may appear like.
Above is a search around the rectangle with the southwestern point
33.462,-112.268 and the northeastern point
33.491,-112.245. A list of all objects that intersect the rectangle are returned.
Please note that the SCAN command does not allow
FENCE - FENCE opens a Geofence.
DETECT - DETECT is available when the FENCE options is specified. It allows for filtering out geofence notifications based on the type. For more information see the Geofence topic.
SPARSE - SPARSE will distribute the results of a search evenly across the requested area.
This is very helpful for example; when you have many (perhaps millions) of objects and do not want them all clustered together on a map. Sparse will limit the number of objects returned and provide them evenly distributed so that your map looks clean.
You can choose a value between 1 and 8. The value 1 will result in no more than 4 items. The value 8 will result in no more than 65536. 1=4, 2=16, 3=64, 4=256, 5=1024, 6=4098, 7=16384, 8=65536.
|No Sparsing||Sparse 1||Sparse 2||Sparse 3||Sparse 4||Sparse 5|
Please note that the higher the sparse value, the slower the performance. Also, LIMIT and CURSOR are not available when using SPARSE.
WHERE - WHERE allows for filtering out results based on field values. For example
nearby fleet where speed 70 +inf point 33.462 -112.268 6000 will return only the objects in the ‘fleet’ collection that are within the 6 km radius and have a field named
speed that is greater than
Multiple WHEREs are concatenated as and clauses.
WHERE speed 70 +inf WHERE age -inf 24 would be interpreted as speed is over 70 and age is less than 24.
The default value for a field is always
0. Thus if you do a WHERE on the field
speed and an object does not have that field set, the server will pretend that the object does and that the value is Zero.
MATCH - MATCH is similar to WHERE except that it works on the object id instead of fields.
nearby fleet match truck* point 33.462 -112.268 6000 will return only the objects in the ‘fleet’ collection that are within the 6 km radius and have an object id that starts with
truck. There can be multiple MATCH options in a single search. The MATCH value is a simple glob pattern.
CURSOR - CURSOR is used to iterate though many objects from the search results. An iteration begins when the CURSOR is set to Zero or not included with the request, and completes when the cursor returned by the server is Zero.
NOFIELDS - NOFIELDS tells the server that you do not want field values returned with the search results.
LIMIT - LIMIT can be used to limit the number of objects returned for a single search request.
COUNT - Total object count for the search.
CURSOR options are ignored
IDS - A list of IDs belonging to the key. Will not return the objects.
OBJECTS - A list of GeoJSON objects.
POINTS - A list of standard latitude, longitude points.
BOUNDS - A list of minimum bounding rectangle.
HASHES - A list of Geohash. Requires a precision of 1 to 22.
GET - Any object that already exists in the database. For example,
Might be used to search for all object in the
poi key that are within the object
tempe that belongs to the key
cities. Of course, the
cities/tempe object must exist in the database.
BOUNDS - A minimum bounding rectangle.
OBJECT - A GeoJSON object.
TILE - An XYZ Tile.
QUADKEY - A QuadKey.
HASH - A Geohash.
The object field values are grouped together in a list per object. Due to the way Tile38 organizes field memory, it’s possible to see zero values for fields that have not been set. It’s recommended to treat all nonexistent or omitted fields as having the value of zero. Check out this Github issue for more information.