$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
ても を使用できます。ただし、地理空間インデックスでは、インデックスがない場合よりもはるかに高速なクエリをサポートします。
例
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 ] } } } )