Loading TOC...

MarkLogic Server 11.0 Product Documentation
geo:shortest-distance

geo:shortest-distance(
   $p1 as cts:point,
   $region as cts:region+,
   [$options as xs:string*]
) as xs:double

Summary

Returns the great circle distance (in units) between a point and a region. The region is defined by a cts:region.

Parameters
p1 The first point.
region A region such as a circle, box, polygon, linestring, or complex-polygon. For compatibility with previous versions, a sequence of points is interpreted as a sequence of arcs (defined pairwise) and the distance returned is the shortest distance to one of those points. If the first parameter is a point within the region specified in this parameter, then this function returns 0. If the point specified in the first parameter in not in the region specified in this parameter, then this function returns the shortest distance to the boundary of the region.
options Options for the operation. The default is ().

Options include:

"coordinate-system=string"
Use the given coordinate system. Valid values are:
wgs84
The WGS84 coordinate system with degrees as the angular unit.
wgs84/radians
The WGS84 coordinate system with radians as the angular unit.
wgs84/double
The WGS84 coordinate system at double precision with degrees as the angular unit.
wgs84/radians/double
The WGS84 coordinate system at double precision with radians as the angular unit.
etrs89
The ETRS89 coordinate system.
etrs89/double
The ETRS89 coordinate system at double precision.
raw
The raw (unmapped) coordinate system.
raw/double
The raw coordinate system at double precision.
"units=value"
Measure distance and the radii of circles in the specified units. Allowed values: miles (default), km, feet, meters.
"precision=value"
Use the coordinate system at the given precision. Allowed values: float and double.

Usage Notes

The value of the precision option takes precedence over that implied by the governing coordinate system name, including the value of the coordinate-system option. For example, if the governing coordinate system is "wgs84/double" and the precision option is "float", then the operation uses single precision.

See Also

Example

geo:shortest-distance(
  cts:point(37.494965, -122.267654),
  cts:linestring((cts:point(40.720921, -74.008878),
                  cts:point(38.950224, -77.019714)))
)

=> 2431.82739813132, which is the shortest distance (in miles)
   between San Carlos, CA and an arc between New York City and
   Washington DC.

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.