| XQUERY/XSLT API DOCUMENTATION 4.2 |
All XQuery & XSLT Functions MarkLogic Built-In Functions Admin (xdmp:) AppServer (xdmp:) Classifier (cts:) Debug (dbg:) Document Conversion (xdmp:) Extension (xdmp:) Documents, Directories, Properties, and Locks Functions Extension Functions Function Values Functions HTTP Functions JSON Functions MarkLogic Server Functions Search Functions XML Functions XQuery Context Functions XSLT Functions map (map:) Math (math:) Profile (prof:) Search (cts:) cts:query Constructors Functions Geospatial Functions Geospatial Lexicon Functions Lexicon Functions Search Functions Search Clustering Functions Security (xdmp:) Server Monitoring (xdmp:) Spell (spell:) Update (xdmp:) XQuery Library Modules Admin Library (admin:) Actions Functions Appserver Functions Database Functions Forest Functions Group Functions Host Functions Mimetypes Functions Scheduler Functions Alerting (alert:) Elastic Compute Cloud (ec2:) Entity Enrichment (entity:) Flexible Replication (flexrep:) Geospatial Supporting Functions GEO Functions GeoRSS Functions GML Functions KML Functions MCGM Functions Information Studio (info:) Information Studio Developer (infodev:) Library Services (dls:) cts:query Constructor Functions Document Management Functions Document Update Functions Retention Policy Functions XInclude Functions Modular Documents XInclude Functions XPointer Functions PKI (pki:) Plugin (plugin:) Search (search:) Security-sec (sec:) Spelling Dictionary Management (spell:) Thesaurus (thsr:) Triggers (trgr:) Triggers Library (trgr:) WordProcessingML (ooxml:) ZIP Package (ooxml:) CPF Functions Content Processing Framework (cpf:) CSS Conversion (css:) DocBook Conversion (dbk:) Domains (dom:) Excel Conversion (excel:) Generic Conversion (cvt:) Links (lnk:) MSWord Conversion (msword:) PDF Conversion (pdf:) Pipelines (p:) Powerpoint Conversion (ppt:) XHTML Conversion (xhtml:) W3C-Standard Functions Accessor (fn:) AnyURI (fn:) Boolean (fn:) Context (fn:) DurationDateTime (fn:) Error and Trace (fn:) Node (fn:) Numeric (fn:) QName (fn:) Sequence (fn:) String (fn:) XSLT (fn:) W3C XQuery/XSLT Reference W3C XQuery Functions W3C XQuery Language W3C XSLT Language
This page was generated September 12, 2012 6:00 AM | XQuery & XSLT Built-In & Modules Function Reference
Built-In: Search - Geospatial Functions
The geospatial built-in functions are XQuery functions defined to operate on geospatial values.
Function Summary
cts:arc-intersection | Returns the point at the intersection of two arcs.
cts:bearing | Returns the true bearing in radians of the path from the first point to the second.
cts:box | Returns a geospatial box value.
cts:box-east | Returns a box's eastern boundary.
cts:box-north | Returns a box's northern boundary.
cts:box-south | Returns a box's southern boundary.
cts:box-west | Returns a box's western boundary.
cts:circle | Returns a geospatial circle value.
cts:circle-center | Returns a circle's center point.
cts:circle-radius | Returns a circle's radius.
cts:destination | Returns the point at the given distance (in miles) along the given bearing (in radians) from the starting point.
cts:distance | Returns the distance (in miles) between two points.
cts:point | Returns a point value.
cts:point-latitude | Returns a point's latitude value.
cts:point-longitude | Returns a point's longitude value.
cts:polygon | Returns a geospatial polygon value.
cts:polygon-vertices | Returns a polygon's vertices.
cts:shortest-distance | Returns the great circle distance (in miles) between a point and an arc.
Function Detail
cts:arc-intersection(
| $p1 as cts:point,
| $p2 as cts:point,
| $q1 as cts:point,
| $q2 as cts:point,
| [$options as xs:string*]
) as cts:point
Summary: Returns the point at the intersection of two arcs. If the arcs do not intersect, or lie on the same great circle, or if either arc covers more than 180 degrees, an error is raised.
Parameters:
$p1 : The starting point of the first arc.
$p2 : The ending point of the first arc.
$q1 : The starting point of the second arc.
$q2 : The ending point of the second arc.
$options (optional): Options for the operation. The default is (). Options include: "coordinate-system=wgs84" Use the WGS84 coordinate system.
Example:
    let $sf := cts:point(37, -122)
    let $ny := cts:point(40, -73)
    let $a := cts:point(35,-100)
    let $b := cts:point(41,-70)
    return
    cts:arc-intersection($sf,$ny,$a,$b)

    => 40.458347,-76.203682
cts:bearing(
| $p1 as cts:point,
| $p2 as cts:point,
| [$options as xs:string*]
) as xs:double
Summary: Returns the true bearing in radians of the path from the first point to the second. An error is raised if the two points are the same.
Parameters:
$p1 : The first point.
$p2 : The second point.
$options (optional): Options for the operation. The default is (). Options include: "coordinate-system=wgs84" Use the WGS84 coordinate system.
Example:
    let $sf := cts:point(37, -122)
    let $ny := cts:point(40, -73)
    return
    cts:bearing($sf, $ny)

    => 1.22100904274442
cts:box(
| $south as xs:float,
| $west as xs:float,
| $north as xs:float,
| $east as xs:float
) as cts:box
Summary: Returns a geospatial box value.
Parameters:
$south : The southern boundary of the box.
$west : The western boundary of the box.
$north : The northern boundary of the box.
$east : The eastern boundary of the box.
Example:
    cts:box(45, -122, 78, 30)
    => [45, -122, 78, 30] (as a cts:box)
cts:box-east(
| $box as cts:box
) as xs:float
Summary: Returns a box's eastern boundary.
Parameters:
$box : The box.
Example:
    cts:box-east(cts:box(45, -122, 78, 30))
    => 30
cts:box-north(
| $box as cts:box
) as xs:float
Summary: Returns a box's northern boundary.
Parameters:
$box : The box.
Example:
    cts:box-north(cts:box(45, -122, 78, 30))
    => 78
cts:box-south(
| $box as cts:box
) as xs:float
Summary: Returns a box's southern boundary.
Parameters:
$box : The box.
Example:
    cts:box-south(cts:box(45, -122, 78, 30))
    => 45
cts:box-west(
| $box as cts:box
) as xs:float
Summary: Returns a box's western boundary.
Parameters:
$box : The box.
Example:
    cts:box-west(cts:box(45, -122, 78, 30))
    => -122
cts:circle(
| $radius as xs:float,
| $center as cts:point
) as cts:circle
Summary: Returns a geospatial circle value.
Parameters:
$radius : The radius of the circle. The units for the radius is determined at runtime by the `cts:query` options (miles is currently the only option).
$center : A point representing the center of the circle.
Example:
    cts:circle(20, cts:point(37.655983, -122.425525))
    => @20 37.655983,-122.42552 (as a cts:circle)
cts:circle-center(
| $circle as cts:circle
) as cts:point
Summary: Returns a circle's center point.
Parameters:
$circle : The circle.
Example:
    cts:circle-center(cts:circle(20, cts:point(37.655983, -122.425525)))
    => 37.655983, -122.425525 (as a cts:point)
cts:circle-radius(
| $circle as cts:circle
) as xs:float
Summary: Returns a circle's radius.
Parameters:
$circle : The circle.
Example:
    cts:circle-radius(cts:circle(20, cts:point(37.655983, -122.425525)))
    => 20
cts:destination(
| $p as cts:point,
| $bearing as xs:double,
| $distance as xs:double,
| [$options as xs:string*]
) as cts:point
Summary: Returns the point at the given distance (in miles) along the given bearing (in radians) from the starting point.
Parameters:
$p : The starting point.
$bearing : The bearing, in radians.
$distance : The distance, in miles.
$options (optional): Options for the operation. The default is (). Options include: "coordinate-system=wgs84" Use the WGS84 coordinate system. "units=miles" Distance is measured in miles.
Example:
    let $sf := cts:point(37, -122)
    let $ny := cts:point(40, -73)
    return
    cts:destination($sf,1.22100904274442,2626.42211914063)

    =>
cts:distance(
| $p1 as cts:point,
| $p2 as cts:point,
| [$options as xs:string*]
) as xs:double
Summary: Returns the distance (in miles) between two points.
Parameters:
$p1 : The first point.
$p2 : The second point.
$options (optional): Options for the operation. The default is (). Options include: "coordinate-system=wgs84" Use the WGS84 coordinate system. "units=miles" Distance is measured in miles.
Example:
    let $sf := cts:point(37, -122)
    let $ny := cts:point(40, -73)
    return
    cts:distance($sf, $ny)

    => 2626.42211914063
cts:point(
| $latitude as xs:float,
| $longitude as xs:float
) as cts:point
Summary: Returns a point value.
Parameters:
$latitude : The latitude of the point.
$longitude : The longitude of the point.
Example:
      cts:point(0.373899653086420E+02, -0.122078578406509E+03)
cts:point-latitude(
| $point as cts:point
) as xs:float
Summary: Returns a point's latitude value.
Parameters:
$point : The point.
Example:
      let $point := cts:point(37.270556, -118.672778)
      return
      cts:point-latitude($point)
cts:point-longitude(
| $point as cts:point
) as xs:float
Summary: Returns a point's longitude value.
Parameters:
$point : The point.
Example:
      let $point := cts:point(37.270556, -118.672778)
      return
      cts:point-longitude($point)
cts:polygon(
| $vertices as cts:point*
) as cts:polygon
Summary: Returns a geospatial polygon value.
Parameters:
$vertices : The vertices of the polygon, given in order. No edge may cover more than 180 degrees of either latitude or longitude. The polygon as a whole may not encompass both poles. These constraints are necessary to ensure an unambiguous interpretation of the polygon. There must be at least three vertices. The first vertex should be identical to the last vertex to close the polygon. vertexes.
Example:
      (: this polygon approximates the 94041 zip code :)
      let $points := (cts:point(0.373899653086420E+02, -0.122078578406509E+03),
        cts:point(0.373765400000000E+02, -0.122063772000000E+03),
        cts:point(0.373781400000000E+02, -0.122067972000000E+03),
        cts:point(0.373825650000000E+02, -0.122068365000000E+03),
        cts:point(0.373797400000000E+02, -0.122072172000000E+03),
        cts:point(0.373899400000000E+02, -0.122092573000000E+03),
        cts:point(0.373941400000000E+02, -0.122095573000000E+03),
        cts:point(0.373966400000000E+02, -0.122094173000000E+03),
        cts:point(0.373958400000000E+02, -0.122092373000000E+03),
        cts:point(0.374004400000000E+02, -0.122091273000000E+03),
        cts:point(0.374004400000000E+02, -0.122091273000000E+03),
        cts:point(0.373873400000000E+02, -0.122057872000000E+03),
        cts:point(0.373873400000000E+02, -0.122057872000000E+03),
        cts:point(0.373854400000000E+02, -0.122052672000000E+03),
        cts:point(0.373833400000000E+02, -0.122053372000000E+03),
        cts:point(0.373819400000000E+02, -0.122057572000000E+03),
        cts:point(0.373775400000000E+02, -0.122060872000000E+03),
        cts:point(0.373765400000000E+02, -0.122063772000000E+03) )
      return
      cts:polygon($points)
cts:polygon-vertices(
| $polygon as cts:polygon
) as cts:point*
Summary: Returns a polygon's vertices. The first vertex and last vertex will always be the same.
Parameters:
$polygon : The polygon.
Example:
      let $node :=
        <polygon zip="94041">
           0.373899653086420E+02,       -0.122078578406509E+03
           0.373765400000000E+02,       -0.122063772000000E+03
           0.373781400000000E+02,       -0.122067972000000E+03
           0.373825650000000E+02,       -0.122068365000000E+03
           0.373797400000000E+02,       -0.122072172000000E+03
           0.373899400000000E+02,       -0.122092573000000E+03
           0.373941400000000E+02,       -0.122095573000000E+03
           0.373966400000000E+02,       -0.122094173000000E+03
           0.373958400000000E+02,       -0.122092373000000E+03
           0.374004400000000E+02,       -0.122091273000000E+03
           0.374004400000000E+02,       -0.122091273000000E+03
           0.373873400000000E+02,       -0.122057872000000E+03
           0.373873400000000E+02,       -0.122057872000000E+03
           0.373854400000000E+02,       -0.122052672000000E+03
           0.373833400000000E+02,       -0.122053372000000E+03
           0.373819400000000E+02,       -0.122057572000000E+03
           0.373775400000000E+02,       -0.122060872000000E+03
           0.373765400000000E+02,       -0.122063772000000E+03
        </polygon>
        return
        cts:polygon-vertices(cts:polygon(fn:data($node)))
cts:shortest-distance(
| $p1 as cts:point,
| $v as cts:point+,
| [$options as xs:string*]
) as xs:double
Summary: Returns the great circle distance (in miles) between a point and an arc. The arc is defined by a pair of points.
Parameters:
$p1 : The first point.
$v : A sequence of points defining (pairwise) a sequence of arcs.
$options (optional): Options for the operation. The default is (). Options include: "coordinate-system=wgs84" Use the WGS84 coordinate system. "units=miles" Distance is measured in miles.
Example:

© Copyright 2002-2012 MarkLogic Corporation. All rights reserved.