geogml.geospatialQuery

geogml.geospatialQuery(
   regions as cts.region[],
   [options as String[]],
   [weight as Number?],
   [namespace as String?]
) 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 Options to this query. The default is ().

Options include:

"coordinate-system=string"
Use the given coordinate system. Valid values are:
wgs84
The WGS84 coordinate system.
wgs84/double
The WGS84 coordinate system at double precision.
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.
"type=value"
Specify the format of point coordinates, either (lat,long) or (long,lat). Latitude-first order is the default. Allowed values: point (default) or long-lat-point.
"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 A weight for this query. The default is 1.0.
namespace An optional GML namespace URI you can use to control which version of GML data to match. Default: http://www.opengis.net/gml/3.2

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:gml="http://www.opengis.net/gml/3.2">
  <item><gml:Point><gml:pos>10.5 30.0</gml:pos></gml:Point></item>
  <item><gml:Point><gml:pos>15.35 35.34</gml:pos></gml:Point></item>
  <item><gml:Point><gml:pos>5.11 40.55</gml:pos></gml:Point></item>
</root> );

xquery version "1.0-ml";
import module namespace geogml = "http://marklogic.com/geospatial/gml"
   at "/MarkLogic/geospatial/gml.xqy";
declare namespace gml="http://www.opengis.net/gml/3.2";

cts:search(doc("/points.xml")//item, 
  geogml:geospatial-query(
    geogml:box(
      <gml:Envelope>
        <gml:lowerCorner>10.0 35.0</gml:lowerCorner>
        <gml:upperCorner>20.0 40.0</gml:upperCorner>
      </gml:Envelope>) ))
(:
  returns the following node: 
  <item xmlns:gml="http://www.opengis.net/gml/3.2">
    <gml:Point><gml:pos>15.35 35.34</gml:pos></gml:Point>
  </item>
:)
,

cts:search(doc("/points.xml")//item, 
  geogml:geospatial-query(geogml:box(
    <gml:Envelope xmlns:gml="http://www.opengis.net/gml/3.2">
      <gml:lowerCorner>10.0 40.0</gml:lowerCorner>
      <gml:upperCorner>20.0 35.0</gml:upperCorner>
    </gml:Envelope>
  )))
(:
  returns the following nodes (wrapping around the Earth):
  <item xmlns:gml="http://www.opengis.net/gml/3.2">
    <gml:Point><gml:pos>10.5 30.0</gml:pos></gml:Point>
  </item>
:)
Powered by MarkLogic Server | Terms of Use | Privacy Policy