| 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
Module: Geospatial Supporting Functions - MCGM Functions
The MCGM module provides support for geospatial queries using MetaCarta geospatial markup. To use the MCGM module as part of your own XQuery module, include the following line in your XQuery prolog: `import module namespace mcgm = "http://marklogic.com/geospatial/mcgm" at "/MarkLogic/geospatial/mcgm.xqy";` The library namespace prefix `mcgm` is not predefined in the server.
Function Summary
mcgm:circle | Create a cts:circle value from a radius and MCGM Dot element.
mcgm:geospatial-query | Returns a cts:query matching points within given regions.
mcgm:geospatial-query-from-elements | Returns a cts:query matching points within given regions.
mcgm:point | Create a cts:point value from a MCGM Dot element.
mcgm:polygon | Construct a cts:polygon value from a sequence of MCGM Dot elements.
Function Detail
mcgm:circle(
| $radius as xs:double,
| $center as element(Dot)
) as cts:circle
Summary: Create a cts:circle value from a radius and MCGM Dot element.
Parameters:
$radius : The radius of the circle, in miles.
$center : A Point element representing the center of the circle.
Example:
      xquery version "1.0-ml";
      import module namespace mcgm = "http://marklogic.com/geospatial/mcgm"
             at "/MarkLogic/geospatial/mcgm.xqy";

      mcgm:circle(47, <Dot Latitude="12.5" Longitude="-127.24"/>)
mcgm:geospatial-query(
| $regions as cts:region*,
| [$options as xs:string*],
| [$weight as xs:double?]
) as cts:query
Summary: Returns a cts:query matching points within given regions.
Parameters:
$regions : One or more geographic boxes, circles, polygons, or points. Where multiple boxes, circles, polygons, or points are specified, the query matches if any box, circle, polygon, or point matches.
$options (optional): Options to this query. The default is (). Options include: "coordinate-system=wgs84" Use the WGS84 coordinate system. "boundaries-included" Points on boxes' and circles' boundaries are counted as matching. This is the default. "boundaries-excluded" Points on boxes' and circles' boundaries are not counted as matching. "boundaries-latitude-excluded" Points on boxes' latitude boundaries are not counted as matching. "boundaries-longitude-excluded" Points on boxes' longitude boundaries are not counted as matching. "boundaries-south-excluded" Points on the boxes' southern boundaries are not counted as matching. "boundaries-west-excluded" Points on the boxes' western boundaries are not counted as matching. "boundaries-north-excluded" Points on the boxes' northern boundaries are not counted as matching. "boundaries-east-excluded" Points on the boxes' eastern boundaries are not counted as matching. "boundaries-circle-excluded" Points on circles' boundary are not counted as matching.
$weight (optional): A weight for this query. The default is 1.0.
Usage Notes: The point value is expressed in the content of the element as a pair of numbers, separated by whitespace and punctuation (excluding decimal points and sign characters). Point values and boundary specifications of boxes are given in degrees relative to the WGS84 coordinate system. Southern latitudes and Western longitudes take negative values. Longitudes will be wrapped to the range (-180,+180) and latitudes will be clipped to the range (-90,+90). If the northern boundary of a box is south of the southern boundary, no points will match. However, longitudes wrap around the globe, so that if the western boundary is east of the eastern boundary, then the box crosses the anti-meridian. Special handling occurs at the poles, as all longitudes exist at latitudes +90 and -90.
Example:
    xquery version "1.0-ml";

    (: create a document with test data :)
    xdmp:document-insert("/points.xml",
    <root xmlns:mcgm="http://marklogic.com/geospatial/mcgm">
      <item><Dot Latitude="10.5" Longitude="30.0"/></item>
      <item><Dot Latitude="15.35" Longitude="35.34"/></item>
      <item><Dot Latitude="5.11" Longitude="40.55"/></item>
    </root> );

    xquery version "1.0-ml";
    import module namespace mcgm = "http://marklogic.com/geospatial/mcgm"
       at "/MarkLogic/geospatial/mcgm.xqy";

    cts:search(doc("/points.xml")//item,
      mcgm:geospatial-query(
        cts:box(10.0, 35.0, 20.0, 40.0)))
    (:
      returns the following node:
      <item><Dot Latitude="15.35" Longitude="35.34"/></item>
    :)
    ,

    cts:search(doc("/points.xml")//item,
      mcgm:geospatial-query(cts:box(10.0, 40.0, 20.0, 35.0)))
    (:
      returns the following nodes (wrapping around the Earth):
      <item><Dot Latitude="10.5" Longitude="30.0"/></item>
    :)
    ,

    cts:search(doc("/points.xml")//item,
      mcgm:geospatial-query(
        cts:box(10.0, 35.0, 20.0, 40.0)))
    (:
      returns the following node:
      <item><Dot Latitude="15.35" Longitude="35.34"/></item>
    :)
mcgm:geospatial-query-from-elements(
| $regions as element(Dot)*,
| [$options as xs:string*],
| [$weight as xs:double?]
) as cts:query
Summary: Returns a cts:query matching points within given regions.
Parameters:
$regions : One or more geographic regions, represented by MCGM elements. Where multiple regions are specified, the query matches if any region matches.
$options (optional): Options to this query. The default is (). Options include: "coordinate-system=wgs84" Use the WGS84 coordinate system. "boundaries-included" Points on boxes' and circles' boundaries are counted as matching. This is the default. "boundaries-excluded" Points on boxes' and circles' boundaries are not counted as matching. "boundaries-latitude-excluded" Points on boxes' latitude boundaries are not counted as matching. "boundaries-longitude-excluded" Points on boxes' longitude boundaries are not counted as matching. "boundaries-south-excluded" Points on the boxes' southern boundaries are not counted as matching. "boundaries-west-excluded" Points on the boxes' western boundaries are not counted as matching. "boundaries-north-excluded" Points on the boxes' northern boundaries are not counted as matching. "boundaries-east-excluded" Points on the boxes' eastern boundaries are not counted as matching. "boundaries-circle-excluded" Points on circles' boundary are not counted as matching.
$weight (optional): A weight for this query. The default is 1.0.
Usage Notes: The point value is expressed in the content of the element as a pair of numbers, separated by whitespace and punctuation (excluding decimal points and sign characters). Point values and boundary specifications of boxes are given in degrees relative to the WGS84 coordinate system. Southern latitudes and Western longitudes take negative values. Longitudes will be wrapped to the range (-180,+180) and latitudes will be clipped to the range (-90,+90). If the northern boundary of a box is south of the southern boundary, no points will match. However, longitudes wrap around the globe, so that if the western boundary is east of the eastern boundary, then the box crosses the anti-meridian. Special handling occurs at the poles, as all longitudes exist at latitudes +90 and -90.
mcgm:point(
| $point as element(Dot)
) as cts:point
Summary: Create a cts:point value from a MCGM Dot element.
Parameters:
$point : A Dot element.
Example:
      xquery version "1.0-ml";
      import module namespace mcgm = "http://marklogic.com/geospatial/mcgm"
             at "/MarkLogic/geospatial/mcgm.xqy";

      mcgm:point(<Dot Latitude="12.5" Longitude="-127.24"/>)
mcgm:polygon(
| $vertices as element(Dot)*
) as cts:polygon
Summary: Construct a cts:polygon value from a sequence of MCGM Dot elements.
Parameters:
$vertices : A sequence of Dot elements representing the vertices of the polygon.
Example:
      xquery version "1.0-ml";
      import module namespace mcgm = "http://marklogic.com/geospatial/mcgm"
             at "/MarkLogic/geospatial/mcgm.xqy";

      mcgm:polygon(( <Dot Latitude="12.5" Longitude="-127.24"/>,
                     <Dot Latitude="15.25" Longitude="-127.8"/>,
                     <Dot Latitude="13.45" Longitude="-126.1"/>,
                     <Dot Latitude="12.5" Longitude="-127.24"/>
                  ))

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