정의
$geoIntersects지리적 공간 데이터가 지정된 GeoJSON 객체와 교차하는 문서를 선택합니다. 여기서 데이터와 지정된 객체의 교차 부분은 비어 있지 않습니다.
The
$geoIntersectsoperator uses the$geometryoperator 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
$geoIntersectsqueries that specify GeoJSON geometries with areas greater than a single hemisphere, the use of the default CRS results in queries for the complementary geometries.보완 기하 도형은 두 도형 중 더 작은 도형입니다. 지정된 도형이 반구 이상을 포함하는 경우 기본값 CRS 쿼리 보완 도형에 대한 문서를 반환합니다.
예시 들어 도형을 지구 표면의 75%를 차지하는 영역으로 정의하는 경우 CRS는 나머지 25%를 보완 영역으로 사용합니다. 쿼리 더 큰 75% 대신 더 작은 보완 25% 영역의 결과를 반환합니다.
이 페이지의 예제 섹션에서는 더 작은 영역과 더 큰 영역을 지정하는 방법을 보여 줍니다.
사용자 지정 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
$geoIntersectsto 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$geoIntersectswith the MongoDB CRS is the same as with the default CRS. See also "Big" Polygons.중요
위도 및 경도 좌표를 지정하는 경우 경도를 먼저 나열한 다음 위도를 나열합니다.
유효한 경도 값은
-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 특정 다각형이 자체 모서리, 자체 정점 또는 꼭지점이나 가장자리를 공유하지만 내부 공간은 없는 다른 다각형과 교차하는 것으로 간주한다는 보장은 없습니다.
'큰' 다각형
For $geoIntersects, if you specify a single-ringed polygon that has an area greater than a single hemisphere, include the custom MongoDB coordinate reference system in the $geometry expression. Otherwise, $geoIntersects queries for the complementary geometry. For all other GeoJSON polygons with areas greater than a hemisphere, $geoIntersects queries for the complementary geometry.
예시
다각형 교차
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 ] ] ] } } } } )
단일 반구보다 큰 면적을 가진 단일 고리 다각형의 경우 '큰' 다각형과 교차하기를 참조하세요.
"큰" 다각형과 교차합니다.
면적이 단일 반구보다 큰 단일 링 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" } } } } } } )