- 카테고리:
ST_CONTAINS¶
Returns TRUE if a GEOGRAPHY or GEOMETRY object is completely inside another object of the same type.
보다 엄격하게는, g2의 점이 g1의 외부에 없고, B 내부의 점 중 적어도 한 개가 A의 내부에 있는 경우에만 오브젝트 g1은 오브젝트 g2를 포함합니다. 이 정의에는 곧바로 명확하게 이해되지 않는 미묘한 점이 어느 정도 있습니다. 《포함》의 의미에 대한 자세한 내용은 차원 확장 9-교차 모델(DE-9IM) 을 참조하십시오.
Although ST_COVERS and ST_CONTAINS might seem similar, the two functions have subtle differences. For details on the differences between 《covers》 and 《contains》, see the Dimensionally Extended 9-Intersection Model (DE-9IM).
참고
이 함수는 GeometryCollection 또는 FeatureCollection을 입력 값으로 사용하는 것을 지원하지 않습니다.
- 참고 항목:
구문¶
ST_CONTAINS( <geography_expression_1> , <geography_expression_2> )
ST_CONTAINS( <geometry_expression_1> , <geometry_expression_2> )
인자¶
geography_expression_1
GeometryCollection 또는 FeatureCollection이 아닌 GEOGRAPHY 오브젝트입니다.
geography_expression_2
GeometryCollection 또는 FeatureCollection이 아닌 GEOGRAPHY 오브젝트입니다.
geometry_expression_1
A GEOMETRY object that is not a GeometryCollection or FeatureCollection.
geometry_expression_2
A GEOMETRY object that is not a GeometryCollection or FeatureCollection.
반환¶
BOOLEAN.
Usage Notes¶
For GEOMETRY objects, the function reports an error if the two input GEOMETRY objects have different SRIDs.
예¶
GEOGRAPHY Examples¶
이는 ST_CONTAINS 함수의 간단한 사용법을 보여줍니다.
create table geospatial_table_01 (g1 GEOGRAPHY, g2 GEOGRAPHY); insert into geospatial_table_01 (g1, g2) values ('POLYGON((0 0, 3 0, 3 3, 0 3, 0 0))', 'POLYGON((1 1, 2 1, 2 2, 1 2, 1 1))');SELECT ST_CONTAINS(g1, g2) FROM geospatial_table_01; +---------------------+ | ST_CONTAINS(G1, G2) | |---------------------| | True | +---------------------+
GEOMETRY Examples¶
The query below shows several examples of using ST_CONTAINS. Note how ST_CONTAINS determines that:
The Polygon contains itself.
The Polygon does not contain the LineString that is on its border.
SELECT ST_CONTAINS(poly, poly_inside), ST_CONTAINS(poly, poly), ST_CONTAINS(poly, line_on_boundary), ST_CONTAINS(poly, line_inside) FROM (SELECT TO_GEOMETRY('POLYGON((-2 0, 0 2, 2 0, -2 0))') AS poly, TO_GEOMETRY('POLYGON((-1 0, 0 1, 1 0, -1 0))') AS poly_inside, TO_GEOMETRY('LINESTRING(-1 1, 0 2, 1 1)') AS line_on_boundary, TO_GEOMETRY('LINESTRING(-2 0, 0 0, 0 1)') AS line_inside);
+--------------------------------+------------------------+------------------------------------+-------------------------------+ | ST_CONTAINS(POLY, POLY_INSIDE) | ST_CONTAINS(POLY,POLY) | ST_CONTAINS(POLY,LINE_ON_BOUNDARY) | ST_CONTAINS(POLY,LINE_INSIDE) | |--------------------------------+------------------------+------------------------------------+-------------------------------| | True | True | False | True | +--------------------------------+------------------------+------------------------------------+-------------------------------+