Loading TOC...

geojson:parse-geojson

geojson:parse-geojson(
   $geojson as object-node()*
) as cts:region*

Summary

Convert GeoJSON object nodes into cts:region values.

Parameters
geojson Zero or more JSON object nodes conforming to the GeoJSON specification.

Usage Notes

The GeoJSON Point node includes additional information that is not retained in the cts:point value. In particular, the altitude part of the point value will be dropped. Therefore two GeoJSON points at the same latitude and longitude with different altitude will nevertheless have equal cts:point values.

See Also

Example

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

geojson:parse-geojson(
  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:polygon similar to the following:
    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.