Docs Menu

$geoIntersects

이 페이지의 내용

$geoIntersects

Selects documents whose geospatial data intersects with a specified GeoJSON object; i.e. where the intersection of the data and the specified object is non-empty.

The $geoIntersects operator uses the $geometry operator to specify the GeoJSON object. To specify a GeoJSON polygons or multipolygons using the default coordinate reference system (CRS), use the following syntax:

{
<location field>: {
$geoIntersects: {
$geometry: {
type: "<GeoJSON object type>" ,
coordinates: [ <coordinates> ]
}
}
}
}

For $geoIntersects queries that specify GeoJSON geometries with areas greater than a single hemisphere, the use of the default CRS results in queries for the complementary geometries.

사용자 지정 MongoDB CRS를 사용하여 단일 고리 GeoJSON 다각형을 지정하려면 $geometry 표현식에 사용자 지정 MongoDB CRS를 지정하는 다음 프로토타입을 사용하세요.

{
<location field>: {
$geoIntersects: {
$geometry: {
type: "Polygon" ,
coordinates: [ <coordinates> ],
crs: {
type: "name",
properties: { name: "urn:x-mongodb:crs:strictwinding:EPSG:4326" }
}
}
}
}
}

The custom MongoDB CRS uses a counter-clockwise winding order and allows $geoIntersects to support queries with a single-ringed GeoJSON polygon whose area is greater than or equal to a single hemisphere. If the specified polygon is smaller than a single hemisphere, the behavior of $geoIntersects with the MongoDB CRS is the same as with the default CRS. See also '큰' 다각형.

중요

위도 및 경도 좌표를 지정하는 경우 경도를 먼저 나열한 다음 위도를 나열합니다.

  • 유효한 경도 값은 -180~180입니다(둘 모두 포함).

  • 유효한 위도 값은 -90~90입니다(둘 모두 포함).

$geoIntersects uses spherical geometry. $geoIntersects does not require a geospatial index. However, a geospatial index will improve query performance. Only the 2dsphere geospatial index supports $geoIntersects.

$geoIntersects does not guarantee that it will consider a polygon to intersect with its own edges; its own vertices; or another polygon sharing vertices or edges but no interior space.

$geoIntersects 의 경우 단일 반구보다 큰 면적을 가진 단일 고리 다각형을 지정하는 경우 the custom MongoDB coordinate reference system in the $geometry 표현식을 포함합니다. 그렇지 않으면 $geoIntersects 이 보완 기하 도형을 쿼리합니다. 반구보다 큰 면적을 가진 다른 모든 GeoJSON 다각형의 경우 $geoIntersects 는 보완 기하 도형을 쿼리합니다.

The following example uses $geoIntersects to select all loc data that intersect with the Polygon defined by the coordinates array. The area of the polygon is less than the area of a single hemisphere:

db.places.find(
{
loc: {
$geoIntersects: {
$geometry: {
type: "Polygon" ,
coordinates: [
[ [ 0, 0 ], [ 3, 6 ], [ 6, 1 ], [ 0, 0 ] ]
]
}
}
}
}
)

For single-ringed polygons with areas greater than a single hemisphere, see Intersects a "Big" Polygon.

면적이 단일 반구보다 큰 단일 링 GeoJSON 다각형을 사용하여 쿼리하려면 $geometry 표현식에 사용자 지정 MongoDB 좌표 참조 시스템을 지정해야 합니다. 예시:

db.places.find(
{
loc: {
$geoIntersects: {
$geometry: {
type : "Polygon",
coordinates: [
[
[ -100, 60 ], [ -100, 0 ], [ -100, -60 ], [ 100, -60 ], [ 100, 60 ], [ -100, 60 ]
]
],
crs: {
type: "name",
properties: { name: "urn:x-mongodb:crs:strictwinding:EPSG:4326" }
}
}
}
}
}
)

이 페이지의 내용