On this page本页内容
$geoIntersects¶Selects documents whose geospatial data intersects with a specified GeoJSON object; i.e. where the intersection of the data and the specified object is non-empty.选择其地理空间数据与指定GeoJSON对象相交的文档;即,数据与指定对象的交集为非空。
The $geoIntersects operator uses the $geometry operator to specify the GeoJSON object. $geoIntersects运算符使用$geometry运算符指定GeoJSON对象。To specify a GeoJSON polygons or multipolygons using the default coordinate reference system (CRS), use the following syntax:要使用默认坐标参考系(CRS)指定GeoJSON多边形或多多边形,请使用以下语法:
For 对于指定面积大于一个半球的GeoJSON几何体的$geoIntersects queries that specify GeoJSON geometries with areas greater than a single hemisphere, the use of the default CRS results in queries for the complementary geometries.$geoIntersects查询,使用默认CRS将导致查询互补几何体。
To specify a single-ringed GeoJSON polygon with a custom MongoDB CRS, use the following prototype that specifies the custom MongoDB CRS in the 要使用自定义MongoDB CRS指定单个环形GeoJSON多边形,请使用以下原型在$geometry expression:$geometry表达式中指定自定义MongoDB CRS:
The custom MongoDB CRS uses a counter-clockwise winding order and allows 自定义MongoDB CRS使用逆时针缠绕顺序,并允许$geoIntersects to support queries with a single-ringed GeoJSON polygon whose area is greater than or equal to a single hemisphere. $geoIntersects支持使用面积大于或等于单个半球的单个环形GeoJSON多边形进行查询。If the specified polygon is smaller than a single hemisphere, the behavior of 如果指定的多边形小于单个半球,则$geoIntersects with the MongoDB CRS is the same as with the default CRS. $geoIntersects与MongoDB CRS的行为与默认CRS的行为相同。See also “Big” Polygons.请参见“大”多边形。
Important重要
If specifying latitude and longitude coordinates, list the longitude first and then latitude:如果指定纬度和经度坐标,请先列出经度,然后列出纬度:
-180 and 180, both inclusive.-180和180之间,两者都包括在内。-90 and 90, both inclusive.-90和90之间,两者都包括在内。$geoIntersects uses spherical geometry. 使用球形几何体。$geoIntersects does not require a geospatial index. 不需要地理空间索引。However, a geospatial index will improve query performance. 但是,地理空间索引将提高查询性能。Only the 2dsphere geospatial index supports 只有2dsphere地理空间索引支持$geoIntersects.$geoIntersects。
$geoIntersects does not guarantee that it will consider a polygon to intersect with its own edges; its own vertices; or another polygon sharing vertices or edges but no interior space.不保证它将考虑多边形与其自身的边相交;自身顶点;或其他多边形共享顶点或边,但没有内部空间。
For 对于$geoIntersects, if you specify a single-ringed polygon that has an area greater than a single hemisphere, include the custom MongoDB coordinate reference system in the $geometry expression; otherwise, $geoIntersects queries for the complementary geometry. $geoIntersects,如果指定面积大于单个半球的单个环形多边形,请在$geometry表达式中包含自定义MongoDB坐标参考系;否则,$geoIntersects将查询互补几何体。For all other GeoJSON polygons with areas greater than a hemisphere, 对于面积大于半球的所有其他GeoJSON多边形,$geoIntersects queries for the complementary geometry.$geoIntersects查询互补几何体。
The following example uses 以下示例使用$geoIntersects to select all loc data that intersect with the Polygon defined by the coordinates array. $geoIntersects选择与坐标数组定义的多边形相交的所有loc数据。The area of the polygon is less than the area of a single hemisphere:多边形的面积小于单个半球的面积:
For single-ringed polygons with areas greater than a single hemisphere, see Intersects a “Big” Polygon.对于面积大于单个半球的单个环形多边形,请参阅与“大”多边形相交。