AI エージェント向け: ドキュメントインデックスは https://www.mongodb.com/ja-jp/docs/llms.txt で利用できます。すべてのページの markdown バージョンは、いずれかの URL パスに .md を追加することで利用できます。
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 not return GeoJSON objects.

To use the $center operator, 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.

Only the 2d geospatial index supports $center.

次のクエリの例では、 [ -74, 40.74 ]を中心とし、半径が10の円内に存在する座標を持つすべてのドキュメントが返されます。

db.places.find(
{ loc: { $geoWithin: { $center: [ [-74, 40.74], 10 ] } } }
)
このページを評価

項目一覧