适用于:
Databricks SQL
Databricks 运行时间 19 及以上
Lakehouse//RT
Note
此功能在 Databricks SQL 经典仓库上不可用。 若要详细了解 Databricks SQL 仓库,请参阅 SQL 仓库类型。
如果两个输入 GEOMETRY 值相互交叉,则返回 true。
Syntax
st_crosses ( geo1, geo2 )
Arguments
-
geo1:第一个GEOMETRY值。 -
geo2:第二个GEOMETRY值。
Returns
一个类型的 BOOLEAN值,表示两个输入 GEOMETRY 值是否相互交叉。
两个几何体是否相交取决于它们的拓扑维度:
- 如果几何体的拓扑维度不同,则当它们内部相交且低维几何体内部的一部分位于高维几何体之外时,它们就会相交。
- 如果两个几何体都是一维的(线串或多线弦),则它们的内部仅在点处相交,则它们相交。
- 否则,它们不会交叉。 两个零维几何(点或多点)和两个二维几何(多边形或多边形)永远不会相交。
结果不取决于参数的顺序。
如果任何输入为空,函数将返回 false 。
该函数不支持几何图形集合。
有关更多细节和正式定义,请参见 DE-9IM 矩阵定义中的 Crosses 谓词。
如果任何输入为NULL,该函数将返回NULL。
错误条件
- 如果任一输入几何图形是几何图形集合,函数将返回 ST_INVALID_ARGUMENT。INVALID_TYPE。
- 如果输入几何图形没有相同的 SRID 值,函数将返回 ST_DIFFERENT_SRID_VALUES。
Examples
-- Returns true for two linestrings whose interiors intersect at a point.
> SELECT st_crosses(st_geomfromtext('LINESTRING(0 0,2 2,4 4)'),st_geomfromtext('LINESTRING(0 1,2 1,3 1)'));
true
-- Returns true for a linestring that passes through the interior of a polygon and leaves it.
> SELECT st_crosses(st_geomfromtext('LINESTRING(0 0,10 10)'),st_geomfromtext('POLYGON((0 0,0 5,5 5,5 0,0 0))'));
true
-- Returns false for a linestring that runs along the boundary of a polygon but never enters its interior.
> SELECT st_crosses(st_geomfromtext('LINESTRING(0 0,10 0)'),st_geomfromtext('POLYGON((0 0,0 5,5 5,5 0,0 0))'));
false
-- Returns true for a multipoint with one point in the interior of a linestring and one point outside it.
> SELECT st_crosses(st_geomfromtext('MULTIPOINT(1 0,1 1)'),st_geomfromtext('LINESTRING(0 0,1 0,3 3)'));
true