Loading TOC...

MarkLogic 12 EA 1 Product Documentation
geojson.toGeojson

geojson.toGeojson(
   regions as cts.region[]
) as Sequence

Summary

Convert cts:region values into GeoJSON object nodes.

Parameters
regions Zero or more cts:region values to convert to GeoJSON.

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.

The return Sequence contains JSON object nodes conforming to the GeoJSON representation.

See Also

Example

const geojson = require("/MarkLogic/geospatial/geojson");

geojson.toGeojson(
  cts.polygon([
    cts.point(5.0,1.0), cts.point(8.0,1.0),
    cts.point(8.0,6.0), cts.point(5.0,7.0)
  ])
)

==> A Sequence containing a JSON object node that represents a
    GeoJSON polygon similar to the following:
{ "type": "Polygon", 
  "coordinates": [
      [[1.0, 5.0], [1.0, 8.0], [6.0, 8.0], [7.0, 5.0], [1.0, 5.0]]
  ]
}
  

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