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 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]} ])
// 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]] ] } )