Docs Menu

$center

項目一覧

$center

The $center operator specifies a circle for a $geoWithin query. The query returns legacy coordinate pairs that are within the bounds of the circle. The operator does ではない return GeoJSON objects.

To use the $center operator, specify an array that contains:

  • 円の中心点のグリッド座標、および

  • The circle's radius, as measured in the units used by the coordinate system.

{
<location field>: {
$geoWithin: { $center: [ [ <x>, <y> ] , <radius> ] }
}
}

重要

経度と緯度を使用する場合は、最初に経度を指定します。

クエリは平面(平面)ジオメトリを使用して距離を計算します。

アプリケーションは、地理空間インデックスが なく$center ても を使用できます。ただし、地理空間インデックスでは、インデックスがない場合よりもはるかに高速なクエリをサポートします。

Only the 2d geospatial index supports $center.

The following example query returns all documents that have coordinates that exist within the circle centered on [ -74, 40.74 ] and with a radius of 10:

db.places.find(
{ loc: { $geoWithin: { $center: [ [-74, 40.74], 10 ] } } }
)

項目一覧