On this page本页内容
$centerSphere
¶Defines a circle for a geospatial query that uses spherical geometry. 为使用球形几何图形的地理空间查询定义圆。The query returns documents that are within the bounds of the circle. 该查询返回圆圈范围内的文档。You can use the 可以在GeoJSON对象和传统坐标对上使用$centerSphere
operator on both GeoJSON objects and legacy coordinate pairs.$centerSphere
运算符。
To use 要使用$centerSphere
, specify an array that contains:$centerSphere
,请指定包含以下内容的阵列:
Important重要的
If you use longitude and latitude, specify longitude first.如果使用经度和纬度,请先指定经度。
Applications can use 应用程序可以使用$centerSphere
without having a geospatial index. $centerSphere
,而无需地理空间索引。However, geospatial indexes support much faster queries than the unindexed equivalents.然而,地理空间索引支持的查询速度比没有索引的索引要快得多。
Both 2dsphere and 2d geospatial indexes support 2dsphere和2d地理空间索引都支持$centerSphere
.$centerSphere
。
The following example queries grid coordinates and returns all documents within a 10 mile radius of longitude 下面的示例查询网格坐标,并返回经度88 W
and latitude 30 N
. 88 W
、纬度30 N
的10英里半径内的所有文档。The query converts the distance to radians by dividing by the approximate equatorial radius of the earth, 3963.2 miles:该查询将距离除以地球的近似赤道半径3963.2英里,转换为弧度: