Docs 菜单

Docs 主页开发应用程序MongoDB Manual

$geometry

$geometry

$geometry操作符指定与以下地理空间查询操作符一起使用的GeoJSON几何图形: $geoWithin$geoIntersects$near$nearSphere$geometry使用EPSG:4326作为默认坐标参考系 (CRS)。

要使用默认 CRS 指定 GeoJSON 对象,请对$geometry使用以下原型:

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

如需使用自定义 MongoDB CRS 指定单环 GeoJSON 多边形,请使用以下原型(仅适用于 $geoWithin$geoIntersects):

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

自定义的 MongoDB 坐标参考系有严格的逆时针缠绕顺序。

重要

如果指定纬度和经度坐标,则先列出经度,然后列出纬度

  • 有效经度值介于 -180180 之间,两者均包括在内。

  • 有效纬度值介于 -9090 之间,两者均包括在内。

← $centerSphere