geojson.polygon( polygon-or-points as objectNode()[] ) as cts.polygon
Create a cts:polygon value from a GeoJSON "Polygon" type geometry object or a sequence of GeoJSON "Point" type geometry objects.
// Create a cts.polygon from a set of GeoJSON points var 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]} ])
// Create a cts.polygon from a GeoJSON polygon var 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: Get the most useful answers to questions from the MarkLogic community, or ask your own question.