MarkLogic 9 Product Documentation
geojson:polygon

geojson:polygon(
   $polygon-or-points as object-node()+
) as cts:polygon

Summary

Create a cts:polygon value from a GeoJSON "Polygon" type geometry object or a sequence of GeoJSON "Point" type geometry objects.

Parameters
polygon-or-points A sequence of Point node representing the vertices of the polygon or a Polygon node itself. Note that if it is a Polygon node, the return from this function represents the exterior polygon.

Example

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

  geojson:polygon((
    object-node { "type" : "Point", "coordinates" : array-node {100.0, 0.0} },
    object-node { "type" : "Point", "coordinates" : array-node {101.0, 0.0} },
    object-node { "type" : "Point", "coordinates" : array-node {101.0, 1.0} },
    object-node { "type" : "Point", "coordinates" : array-node {100.0, 1.0} },
    object-node { "type" : "Point", "coordinates" : array-node {100.0, 0.0} }
  ))
  

Example

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

  geojson:polygon(object-node {
    "type": "Polygon",
    "coordinates": array-node {
      array-node { 
        array-node {100.0, 0.0}, 
        array-node {101.0, 0.0}, 
        array-node {101.0, 1.0}, 
        array-node {100.0, 1.0},
        array-node {100.0, 0.0}
      },
      array-node { 
        array-node {100.2, 0.2}, 
        array-node {100.8, 0.2}, 
        array-node {100.8, 0.8}, 
        array-node {100.2, 0.8}, 
        array-node {100.2, 0.2} 
      }
     }
   })
  
Powered by MarkLogic Server | Terms of Use | Privacy Policy