TairGIS is a data structure that uses R-tree indexes and supports APIs related to a geographic information system (GIS). Compared with native Redis GEO commands that allow you to use Geohash and Redis Sorted Set to query points, TairGIS provides more features by allowing you to query points, linestrings, and polygons.
Main features
- R-tree indexes for query and storage.
- Line and polygon queries, including queries for the intersection of sets.
- GIS.SEARCH command, which functions like native Redis
GEORADIUS
command.
Best practices
Monitor user trajectories by using TairGISPrerequisites
Precautions
The TairGIS data that you want to manage is stored on a Tair instance.
Supported commands
Command | Syntax | Description |
---|---|---|
GIS.ADD | GIS.ADD area polygonName polygonWkt [polygonName polygonWkt ...] |
Adds one or more specific polygons to a specific area. The polygons are described in Well Known Text (WKT).
Note WKT is a text markup language for representing vector geometry objects on a map, spatial reference systems of spatial objects, and transformations between spatial reference systems.
|
GIS.GET | GIS.GET area polygonName |
Retrieves the WTK of a specific polygon within a specific area. |
GIS.GETALL | GIS.GETALL area [WITHOUTWKT] |
Retrieves the names and WKTs of all polygons within a specific area. If you specify the WITHOUTWKT parameter, only the names of the polygons are returned. |
GIS.CONTAINS | GIS.CONTAINS area polygonWkt [WITHOUTWKT] |
Checks whether a specified point, linestring, or polygon is located in polygons within a specific area. If yes, this command returns the number and WKTs of polygons that contain the point, linestring, or polygon in the area. |
GIS.WITHIN | GIS.WITHIN area polygonWkt [WITHOUTWKT] |
Checks whether a specific area is located within a specified point, linestring, or polygon. If yes, this command returns the number and WKTs of polygons that are located within the point, linestring, or polygon. |
GIS.INTERSECTS | GIS.INTERSECTS area polygonWkt |
Checks whether a specific point, linestring, or polygon intersects with polygons within a specific area. If yes, this command returns the number and WKTs of polygons within the area that intersect with the point, linestring, or polygon. |
GIS.SEARCH | GIS.SEARCH area [RADIUS longitude latitude distance M|KM|FT|MI] [MEMBER field distance M|KM|FT|MI] [GEOM geom] [COUNT count] [ASC|DESC] [WITHDIST] [WITHOUTWKT] |
Queries the points within a specific area that are located within a specific radius of a specific longitude and latitude position. |
GIS.DEL | GIS.DEL area polygonName |
Deletes a specific polygon from a specific area. |
DEL | DEL key [key ...] |
Deletes one or more TairGIS keys. This is a native Redis command. |
Uppercase keyword
: the command keyword.Italic
: Words in italic indicate variable information that you supply.[options]
: optional parameters. Parameters that are not included in brackets are required.AB
: specifies that these parameters are mutually exclusive. Select one of two or more parameters....
: specifies to repeat the preceding content.
GIS.ADD
Item | Description |
---|---|
Syntax | GIS.ADD area polygonName polygonWkt [polygonName polygonWkt ...] |
Time complexity | O(log n) |
Command description |
Adds one or more specific polygons to a specific area. The polygons are described in Well Known Text (WKT).
Note WKT is a text markup language for representing vector geometry objects on a map, spatial reference systems of spatial objects, and transformations between spatial reference systems.
|
Parameter |
|
Output |
|
Example | Sample command:
Sample output:
|
GIS.GET
Item | Description |
---|---|
Syntax | GIS.GET area polygonName |
Time complexity | O(1) |
Command description | Retrieves the WTK of a specific polygon within a specific area. |
Parameter |
|
Output |
|
Example | The Sample command:
Sample output:
|
GIS.GETALL
Item | Description |
---|---|
Syntax | GIS.GETALL area [WITHOUTWKT] |
Time complexity | O(n) |
Command description | Retrieves the names and WKTs of all polygons within a specific area. If you specify the WITHOUTWKT parameter, only the names of the polygons are returned. |
Parameter |
|
Output |
|
Example | The Sample command:
Sample output:
|
GIS.CONTAINS
Item | Description |
---|---|
Syntax | GIS.CONTAINS area polygonWkt [WITHOUTWKT] |
Time complexity |
|
Command description | Checks whether a specified point, linestring, or polygon is located in polygons within a specific area. If yes, this command returns the number and WKTs of polygons that contain the point, linestring, or polygon in the area. |
Parameter |
|
Output |
|
Example | The Sample command:
Sample output:
|
GIS.WITHIN
Item | Description |
---|---|
Syntax | GIS.WITHIN area polygonWkt [WITHOUTWKT] |
Time complexity |
|
Command description | Checks whether a specific area is located within a specified point, linestring, or polygon. If yes, this command returns the number and WKTs of polygons that are located within the point, linestring, or polygon. |
Parameter |
|
Output |
|
Example | The Sample command:
Sample output:
|
GIS.INTERSECTS
Item | Description |
---|---|
Syntax | GIS.INTERSECTS area polygonWkt |
Time complexity |
|
Command description | Checks whether a specific point, linestring, or polygon intersects with polygons within a specific area. If yes, this command returns the number and WKTs of polygons within the area that intersect with the point, linestring, or polygon. |
Parameter |
|
Output |
|
Example | The Sample command:
Sample output:
|
GIS.SEARCH
Item | Description |
---|---|
Syntax |
|
Time complexity |
|
Command description | Queries the points within a specific area that are located within a specific radius of a specific longitude and latitude position. |
Parameter |
Note You can specify only one of the
RADIUS,
MEMBER, and
GEOM parameters.
|
Output |
|
Example | The Sample command:
Sample output:
|
GIS.DEL
Item | Description |
---|---|
Syntax | GIS.DEL area polygonName |
Time complexity | O(log n) |
Command description | Deletes a specific polygon from a specific area. |
Parameter |
|
Output |
|
Example | The Sample command:
Sample output:
|