适用于:
Databricks Runtime 18.1 及更高版本
重要
此功能目前以公共预览版提供。
返回输入 GEOGRAPHY 或 GEOMETRY 值的 2D 投影。
Syntax
st_force2d ( geoExpr )
Arguments
-
geoExpr:GEOGRAPHY或GEOMETRY值。
退货
类型或GEOGRAPHYGEOMETRY表示输入值的 2D 投影的值。
输出 GEOGRAPHY 或 GEOMETRY 值的 SRID 值等于输入值的 SRID 值。
如果输入为 NULL.,则函数返回 NULL 。
备注
如果输入具有 Z 或 M 坐标,则输出中排除了这些坐标。
如果输入已为 2D,则函数将返回它不变。
示例
-- Drops the M coordinate from a point geography.
> SELECT st_astext(st_force2d(st_geogfromtext('POINT M (1 2 3)')));
POINT(1 2)
-- Drops Z and M coordinates from a multipoint geography.
> SELECT st_astext(st_force2d(st_geogfromtext('MULTIPOINT ZM (EMPTY,0 0 10 20, 1 1 11 21)')));
MULTIPOINT(EMPTY,(0 0),(1 1))
-- Drops the Z coordinate from a polygon geography.
> SELECT st_astext(st_force2d(st_geogfromtext('POLYGON Z ((0 0 2,1 0 3,0 1 4,0 0 5))')));
POLYGON((0 0,1 0,0 1,0 0))
-- Drops the Z coordinate from a point geometry.
> SELECT st_astext(st_force2d(st_geomfromtext('POINT Z (1 2 3)')));
POINT(1 2)
-- Drops Z and M coordinates from a linestring geometry.
> SELECT st_astext(st_force2d(st_geomfromtext('LINESTRING ZM (0 0 10 20, 1 1 11 21)')));
LINESTRING(0 0,1 1)
-- Returns the input 2D geometry as is.
> SELECT st_astext(st_force2d(st_geomfromtext('POINT(1 2)')));
POINT(1 2)
-- Preserves the SRID of the input geography.
> SELECT st_srid(st_force2d(st_geogfromtext('POINT(1 2)')));
4326
-- Preserves the SRID of the input geometry.
> SELECT st_srid(st_force2d(st_geomfromtext('POINT(1 2)', 4326)));
4326
-- Returns NULL if the input is NULL.
> SELECT st_force2d(NULL);
NULL