Fields that are within a Specified Distance from a Specified Point

DISTCARTESIAN

The DISTCARTESIAN field specifier allows you to find documents that contain fields that define a point (X and Y coordinates) or region that is within a specified distance from a specified point.

You can specify the document position fields either as a pair of fields (corresponding to X and Y coordinate fields), or a single field that uses POINT or POLYGON definitions (in Well-known text format) to specify position information (for example, a unified GeospatialType field).

TIP: If your document location fields contain regions (in Well-known text POLYGON format), the DISTCARTESIAN operator calculates distances from the geometric center of the region.

FieldText=DISTCARTESIAN{coordX,coordY,dist}:POSITION

where:

coordX is the specified X coordinate.
coordY is the specified Y coordinate.
dist is the distance in kilometers from the specified coordinates.
POSITION

The document field or fields that contain the position value. You can use one of the following options to specify location fields:

  • a single field. This field must contain a Well-known text format POINT or POLYGON definition (for example, POINT(x y)).
  • two fields, in the format X:Y, where X is the field that contains the x coordinate, and Y is the field that contains the y coordinate. You must specify the fields in the order x:y.

You can specify multiple options for the location fields, in form POSITION1:POSITION2:POSITION3, and so on. This form can include a mix of types (unified location fields and split latitude and longitude fields).

NOTE: If you use multiple position fields or field pairs, IDOL Server cannot match documents where a pair of split geospatial fields occurs interleaved with other geospatial fields. For example, if you use X1:Y1:POSITION in your query, and these fields occur in a document in the order X1, POSITION, Y1, IDOL Server does not match that document.

In such cases, you can rewrite the query, in the form DISTCARTESIAN{...}:X1:Y1 OR DISTCARTESIAN{...}:POSITION

Example:

FieldText=DISTCARTESIAN{10,11,5}:X:Y

This example matches all documents whose (X,Y) position is within a distance of 5 units of the point (10,11). The position of a document in this example is contained in the fields X and Y.

FieldText=DISTCARTESIAN{10,11,5}:POSITION

This example matches all documents whose (X,Y) position is within a distance of 5 units of the point (10,11). The position of a document in this example is contained in the POSITION field.

DISTSPHERICAL

The DISTSPHERICAL field specifier allows you to find documents that contain location fields that define a point (latitude and longitude) or region that is within a specified distance from a specified point.

You can specify the document location fields either as a pair of fields (corresponding to latitude and longitude fields), or a single field that uses POINT or POLYGON definitions (in Well-known text format) to specify location information (for example, a unified GeospatialType field).

TIP: If your document location fields contain regions (in Well-known text POLYGON format), the DISTSPHERICAL operator calculates distances from the geometric center of the region.

FieldText=DISTSPHERICAL{lat,long,dist}:LOCATION

where:

lat is the latitude. Specify latitude positions south of the equator as negative.
long is the longitude. Specify longitude positions west of the Greenwich Meridian as negative.
dist is the distance in kilometers from the specified latitude and longitude.
LOCATION

The document field or fields that contain the location value. You can use one of the following options to specify location fields:

  • a single field. This field must contain a Well-known text format POINT definition (that is, POINT (x y)).
  • two fields, in the format LATFIELD:LONGFIELD, where LATFIELD is the field that contains the latitude value, and LONGFIELD is the field that contains the longitude value. You must specify the fields in the order latitude:longitude.

You can specify multiple options for the location fields, in form LOCATION1:LOCATION2:LOCATION3, and so on. This form can include a mix of types (unified location fields and split latitude and longitude fields).

NOTE: If you use multiple position fields or field pairs, IDOL Server cannot match documents where a pair of split geospatial fields occurs interleaved with other geospatial fields. For example, if you use LAT1:LONG1:LOCATION in your query, and these fields occur in a document in the order LAT1, LOCATION, LONG1, IDOL Server does not match that document.

In such cases, you can rewrite the query, in the form DISTSPHERICAL{...}:LAT1:LONG1 OR DISTCARTESIAN{...}:LOCATION

Example:

FieldText=DISTSPHERICAL{37.75,-122.4,20}:LAT:LONG

This example matches all documents whose position is within a 20 kilometer radius of San Francisco (37.75N,122.4W). The latitude and longitude position of a document in this example is contained in the fields LAT and LONG, respectively.

FieldText=DISTSPHERICAL{52.2,0.1,20}:LOCATION

This example matches all documents whose position is within a 20 kilometer radius of Cambridge (52.2N,0.1W). The latitude and longitude position of a document in this example is contained in the LOCATION field.