Loading TOC...

MarkLogic 12 EA 1 Product Documentation
geojson.polygon

geojson.polygon(
   polygon-or-points as objectNode()[]
) 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

// Create a cts.polygon from a set of GeoJSON points
const geojson = require('/MarkLogic/geospatial/geojson.xqy');

geojson.polygon([
  {type: 'Point', coordinates: [100.0,0.0]},
  {type: 'Point', coordinates: [101.0,0.0]},
  {type: 'Point', coordinates: [101.0,1.0]},
  {type: 'Point', coordinates: [100.0,1.0]},
  {type: 'Point', coordinates: [100.0,0.0]}
])
  

Example

// Create a cts.polygon from a GeoJSON polygon
const geojson = require('/MarkLogic/geospatial/geojson.xqy');

geojson.polygon(
  { type: 'Polygon', 
    coordinates: [
      [[100.0,0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]]
  ] }
)
  

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