定義
$centerThe
$centeroperator specifies a circle for a$geoWithinquery. The query returns legacy coordinate pairs that are within the bounds of the circle. The operator does not return GeoJSON objects.To use the
$centeroperator, specify an array that contains:円の中心点のグリッド座標、および
座標システムで使用される単位で測定される円の半径。
{ <location field>: { $geoWithin: { $center: [ [ <x>, <y> ] , <radius> ] } } } 重要
経度と緯度を使用する場合は、最初に経度を指定します。
動作
クエリは平面(平面)ジオメトリを使用して距離を計算します。
Applications can use $center without having a geospatial index. However, geospatial indexes support much faster queries than the unindexed equivalents.
例
次のクエリの例では、 [ -74, 40.74 ]を中心とし、半径が10の円内に存在する座標を持つすべてのドキュメントが返されます。
db.places.find( { loc: { $geoWithin: { $center: [ [-74, 40.74], 10 ] } } } )