$geometry

  • $geometry

Changed in version 3.0: Add support to specify single-ringed GeoJSON polygons with areas greater than a single hemisphere.

The $geometry operator specifies a GeoJSON geometryfor use with the following geospatial query operators:$geoWithin, $geoIntersects, $near, and$nearSphere. $geometry uses EPSG:4326 as thedefault coordinate reference system (CRS).

To specify GeoJSON objects with the default CRS, use the followingprototype for $geometry:

  1. $geometry: {
  2. type: "<GeoJSON object type>",
  3. coordinates: [ <coordinates> ]
  4. }

New in version 3.0: To specify a single-ringed GeoJSON polygon with a custom MongoDB CRS, use the followingprototype (available only for $geoWithin and$geoIntersects):

  1. $geometry: {
  2. type: "Polygon",
  3. coordinates: [ <coordinates> ],
  4. crs: {
  5. type: "name",
  6. properties: { name: "urn:x-mongodb:crs:strictwinding:EPSG:4326" }
  7. }
  8. }

The custom MongoDB coordinate reference system has a strictcounter-clockwise winding order.

Important

If specifying latitude and longitude coordinates, list thelongitude first and then latitude:

  • Valid longitude values are between -180 and 180, bothinclusive.
  • Valid latitude values are between -90 and 90, bothinclusive.