Loading TOC...

MarkLogic 9 Product Documentation
geo:parse

geo:parse(
   $data as node()*
) as cts:region*

Summary

Convert nodes in one or more of the supported geospatial representations into cts:region values.

Parameters
data Zero or more nodes containing geospatial data in one of the supported formats, such as KML, GML, GeoRSS, or GeoJSON.

Usage Notes

This function examines each input node and delegates to the appropriate format-specific parsing function, such as gml:parse-gml or geojson:parse-geojson. The input nodes need not all use the same representation.

See Also

Example

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

(: Construct a cts:polygon from GeoJSON data. :)
geo:parse((
  <gml:Point xmlns:gml="http://www.opengis.net/gml/3.2">
    <gml:pos>12.5 -127.24</gml:pos>
  </gml:Point>,
  xdmp:unquote('
    { "type": "Polygon", 
      "coordinates": [
        [[1.0, 5.0], [1.0, 8.0], [6.0, 8.0], [7.0, 5.0], [1.0, 5.0]]
    ]}
  ')/object-node()
))

==> A cts:point created from a GML node and a cts:polygon created 
    from a GeoJSON node, similar to the following:
    (cts:point("12.5,-127.24"), cts:polygon("5,1 8,1 8,6 5,7 5,1"))
  

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