Docs Menu

$geometry

$geometry

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

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

$geometry: {
type: "<GeoJSON object type>",
coordinates: [ <coordinates> ]
}

To specify a single-ringed GeoJSON polygon with a custom MongoDB CRS, use the following prototype (available only for $geoWithin and $geoIntersects):

$geometry: {
type: "Polygon",
coordinates: [ <coordinates> ],
crs: {
type: "name",
properties: { name: "urn:x-mongodb:crs:strictwinding:EPSG:4326" }
}
}

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

重要

緯度と経度の座標を指定する場合は、最初に経度、次に緯度を指定します。

  • 有効な経度の値は、-180 以上、180 以下です。

  • 有効な緯度の値は-90 以上、90 以下です。