Docs Menu

$box

項目一覧

$box

Specifies a rectangle for a 地理空間 $geoWithin query to return documents that are within the bounds of the rectangle, according to their point-based location data. When used with the $box operator, $geoWithin returns documents based on grid coordinates and does ではない query for GeoJSON shapes.

To use the $box operator, you must specify the bottom left and top right corners of the rectangle in an array object:

{
<location field>: {
$geoWithin: {
$box: [
[ <bottom left coordinates> ],
[ <upper right coordinates> ]
]
}
}
}

重要

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

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

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

Only the 2d geospatial index supports $box.

The following example query returns all documents that are within the box having points at: [ 0 , 0 ], [ 0 , 100 ], [ 100 , 0 ], and [ 100 , 100 ].

db.places.find( {
loc: { $geoWithin: { $box: [ [ 0, 0 ], [ 100, 100 ] ] } }
} )

項目一覧