st_pointonsurface 函数

适用于:检查标记为是 Databricks Runtime 18.3 及更高版本

Important

此功能目前以公共预览版提供。

返回一个保证位于输入值内或位于输入 GEOMETRY 值内的点。

Syntax

st_pointonsurface ( geoExpr )

Arguments

  • geoExpr:一个 GEOMETRY 值。

Returns

保证位于输入值内或位于输入GEOMETRY值的 2D 点GEOMETRY值。 更确切地说:

  • 如果输入 GEOMETRY 值为空,则返回 2D 空点。
  • 如果输入 GEOMETRY 值为非空点,则返回该点的 2D 投影。
  • 如果输入 GEOMETRY 值为非空行字符串,则返回中间顶点。
  • 如果输入 GEOMETRY 值为非空多边形,则尽可能返回多边形的内部点;否则返回其边界上的点。
  • 如果输入 GEOMETRY 值为多点,则返回离边界框中心最近的非空点。
  • 如果输入 GEOMETRY 值为多行字符串,则返回长度最大的线字符串图面上的点。
  • 如果输入 GEOMETRY 值为多多边形,则返回具有最大面积的多边形图面上的点。
  • 如果输入 GEOMETRY 值为几何图形集合,则返回集合的最大维元素之一的图面上的点。

输出 GEOMETRY 值的 SRID 值与输入值的 SRID 值相同。

示例

-- Example taking a 2D polygon.
> SELECT st_asewkt(st_pointonsurface(st_geomfromtext('POLYGON((0 0,10 0,10 10,0 10,0 0))')));
  POINT(5 5)

-- Example taking a 2D polygon with a hole: the result lies in the donut region.
> SELECT st_asewkt(st_pointonsurface(st_geomfromtext('POLYGON((0 0,30 0,30 30,0 30,0 0),(5 5,25 5,25 25,5 25,5 5))')));
  POINT(3.75 3.75)

-- Example taking a 3DZ linestring: the median vertex is returned and the Z coordinate is dropped.
> SELECT st_asewkt(st_pointonsurface(st_geomfromtext('LINESTRING Z (1 2 -1,3 4 -2,5 6 -3)')));
  POINT(3 4)

-- Example taking a multipolygon: a point on the polygon with the largest area is returned.
> SELECT st_asewkt(st_pointonsurface(st_geomfromtext('MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0)),((100 100,101 100,101 101,100 101,100 100)))')));
  POINT(5 5)

-- Example showing that the SRID is preserved.
> SELECT st_asewkt(st_pointonsurface(st_geomfromtext('POLYGON((0 0,10 0,10 10,0 10,0 0))', 3857)));
  SRID=3857;POINT(5 5)

-- Example taking a NULL input.
> SELECT st_pointonsurface(NULL);
  NULL