geo:geospatial-query-from-nodes( $regions as node()*, [$options as xs:string*], [$weight as xs:double?] ) as cts:query
Returns a query matching points within given regions.
geospatial-query-from-elements
(if the input region is an XML element) or to
geojson:geospatial-query-from-nodes
(if the input region is a JSON object node). See the API docs of those
two functions for more details.
xquery version "1.0-ml"; (: create a document with test data :) declare namespace gml= "http://www.opengis.net/gml"; declare namespace georss= "http://www.georss.org/georss"; xdmp:document-insert("/points.xml", <root xmlns:geo="http://marklogic.com/geospatial"> <item><gml:Point><gml:pos>10.5 30.0</gml:pos></gml:Point></item> <item><georss:point>15.35 35.34</georss:point></item> <item><Dot Latitude="5.11" Longitude="40.55"/></item> </root> ); xquery version "1.0-ml"; import module namespace geo = "http://marklogic.com/geospatial" at "/MarkLogic/geospatial/geospatial.xqy"; declare namespace gml= "http://www.opengis.net/gml"; declare namespace georss= "http://www.georss.org/georss"; declare namespace kml= "http://earth.google.com/kml/2.0"; cts:search(doc("/points.xml")//item, geo:geospatial-query-from-nodes( <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><georss:point>15.35 35.34</georss:point></item> :) , cts:search(doc("/points.xml")//item, geo:geospatial-query-from-nodes( <kml:LatLongBox> <kml:north>20.0</kml:north> <kml:south>10.0</kml:south> <kml:east>35.0</kml:east> <kml:west>40.0</kml:west> </kml:LatLongBox> ))