All Products
Search
Document Center

:in_query_polygon

Last Updated:Sep 09, 2021

Functionality functions

You can use functionality functions in filter clauses to define filter conditions. Functionality functions that return numeric values can be used in sort clauses for sorting.

The fields that you reference in the parameters of functionality functions must be configured as index or attribute fields based on the description of each function.

in_query_polygon: judges whether a specific geographical location is in specific polygon-shaped areas.

1.Syntax:

in_query_polygon(polygon_key, doc_point)

2.Parameters:

  • polygon_key: the key defined in the kvpairs clause. The coordinates of vertices of polygons are stored in the value of the key. The field must be of the DOUBLE_ARRAY type. The field values are ordered x-coordinates and y-coordinates that form polygons. A pair of coordinates is in the [x,y] format. The coordinates of vertices must follow the clockwise or anticlockwise direction. Separate multiple coordinates with commas (,). Example: xA,yA,xB,Yb. Separate multiple polygons with semicolons (;).

  • doc_point: the geographical location to be judged. The field must be of the DOUBLE_ARRAY type. The field can contain only two values, which are an x-coordinate and a y-coordinate.

3.Return value:

The return value is of the INT type and indicates the subscript of the first matched polygon. If no polygon is matched, 0 is returned.

4.Scenario:

Scenario 1:

Search for Grandma's House in the Yintai business district (xA,yA,xB,Yb,xC,Yc;xD,yD,xE,yE,xF,yF,xG,yG). The doc_point field is used to store the geographical location of Grandma's House.

query=default: 'Grandma's House'&&filter=in_query_polygon ("polygons", point)>0&&kvpairs=polygons:xA\,yA\,xB\,Yb\,xC\,Yc;xD\,yD\,xE\,yE\,xF\,yF\,xG\,yG

5.Usage notes:

  • The fields that you reference in the parameters of the function must be configured as attribute fields.