Loading TOC...

MarkLogic 12 EA 2 Product Documentation
geojson.geospatialQueryFromNodes

geojson.geospatialQueryFromNodes(
   regions as Node[],
   [options as String[]],
   [weight as Number?]
) as cts.query

Summary

Returns a cts:query matching points within given regions.

Parameters
regions One or more geographic circles, polygons, linestrings or points, represented as GeoJSON objects. Where multiple circles, polygons, linestrings or points are specified, the query matches if any circle, polygon, linestring or point matches.
options Options to this query. The default is ().

Options include:

"coordinate-system=string"
Use the given coordinate system. Valid values are:
wgs84
The WGS84 coordinate system.
wgs84/double
The WGS84 coordinate system at double precision.
raw
The raw (unmapped) coordinate system.
raw/double
The raw coordinate system at double precision.
"boundaries-included"
Points on boxes' and circles' boundaries are counted as matching. This is the default.
"boundaries-excluded"
Points on boxes' and circles' boundaries are not counted as matching.
"boundaries-latitude-excluded"
Points on boxes' latitude boundaries are not counted as matching.
"boundaries-longitude-excluded"
Points on boxes' longitude boundaries are not counted as matching.
"boundaries-south-excluded"
Points on the boxes' southern boundaries are not counted as matching.
"boundaries-west-excluded"
Points on the boxes' western boundaries are not counted as matching.
"boundaries-north-excluded"
Points on the boxes' northern boundaries are not counted as matching.
"boundaries-east-excluded"
Points on the boxes' eastern boundaries are not counted as matching.
"boundaries-circle-excluded"
Points on circles' boundary are not counted as matching.
weight A weight for this query. The default is 1.0.

Usage Notes

Point values and boundary specifications of boxes are given in degrees relative to the WGS84 coordinate system. Southern latitudes and Western longitudes take negative values. Longitudes will be wrapped to the range (-180,+180) and latitudes will be clipped to the range (-90,+90).

If the northern boundary of a box is south of the southern boundary, no points will match. However, longitudes wrap around the globe, so that if the western boundary is east of the eastern boundary, then the box crosses the anti-meridian.

Special handling occurs at the poles, as all longitudes exist at latitudes +90 and -90.

This function will take into account interior polygons, if any, and properly construct the query to account for them.

Example

// Assume you previously inserted a document into the database, as follows:
declareUpdate();
xdmp.documentInsert('example.json',
  { type: 'Feature',  
    geometry: {    
      type: 'Point',    
      coordinates: [125.6, 8.1]
     },
     properties: { name: 'Test' }
  });

// Then the following search matches the above document.
const geojson = require('/MarkLogic/geospatial/geojson');
cts.search(
  geojson.geospatialQueryFromNodes(
    { "type": "Polygon",
      "coordinates": [
        [ [35, 1], [131, 1], [131, 120], [35, 120], [35, 1] ]
      ]
    }
));

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