ST_CONTAINS
更新时间:2025-10-17
描述
判断几何图形 shape1 是否完全能够包含几何图形 shape2
语法
SQL
1ST_CONTAINS( <shape1>, <shape2>)
参数
| 参数 | 说明 |
|---|---|
<shape1> |
传入的几何图形,用于判断是否包含 shape2 |
<shape2> |
传入的几何图形,用于判断是被 shape1 包含 |
返回值
返回 1:shape1 图形可包含图形 shape2
返回 0:shape1 图形不可包含图形 shape2
举例
SQL
1SELECT ST_Contains(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))"), ST_Point(5, 5));
Text
1+----------------------------------------------------------------------------------------+
2| st_contains(st_polygon('POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))'), st_point(5.0, 5.0)) |
3+----------------------------------------------------------------------------------------+
4| 1 |
5+----------------------------------------------------------------------------------------+
SQL
1SELECT ST_Contains(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))"), ST_Point(50, 50));
Text
1+------------------------------------------------------------------------------------------+
2| st_contains(st_polygon('POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))'), st_point(50.0, 50.0)) |
3+------------------------------------------------------------------------------------------+
4| 0 |
5+------------------------------------------------------------------------------------------+
