$geometry
MongoDB 5.0 已于 10 月 2024结束生命周期。 不再支持此版本的文档。 要升级5.0 部署,请参阅 MongoDB.6 0升级过程。
$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 坐标参考系有严格的逆时针缠绕顺序。
重要
如果指定纬度和经度坐标,则先列出经度,然后列出纬度。
有效经度值介于
-180
和180
之间,两者均包括在内。有效纬度值介于
-90
和90
之间,两者均包括在内。