st_pointonsurface 函數

適用於:勾選已標記為 Databricks 執行時間 18 LTS 及以上

Note

Databricks Runtime 18 比 Databricks Runtime 18.0、18.1 和 18.2 更新。 原本會以後期編號版本推出的功能,現在改為以 Databricks Runtime 18 的更新形式提供。 詳情請參見 關於統一發布說明

回傳一個保證位於輸入 GEOMETRY 值上或其內的點。

Syntax

st_pointonsurface ( geoExpr )

論點

  • geoExpr:一個GEOMETRY值。

Returns

一個保證位於輸入GEOMETRY值上方或內部的二維點GEOMETRY數值。 更準確地說:

  • 如果輸入 GEOMETRY 值為空,則會傳回 2D 空點。
  • 若輸入 GEOMETRY 值為非空點,則回傳該點的二維投影。
  • 若輸入 GEOMETRY 值為非空行字串,則回傳中位頂點。
  • 若輸入 GEOMETRY 值為非空多邊形,則盡可能回傳多邊形內部的點;否則返回其邊界上的點。
  • 若輸入 GEOMETRY 值為多點,則返回最接近包圍盒中心的非空點。
  • 若輸入 GEOMETRY 值為多線字串,則回傳線條曲面上長度最大的一點。
  • 若輸入 GEOMETRY 值為多邊形,則返回多邊形表面上面積最大的一點。
  • 若輸入 GEOMETRY 值為幾何集合,則返回集合中最大維元素之一曲面上的一個點。

輸出 GEOMETRY 值的 SRID 值與輸入值的 SRID 值相同。

Examples

-- 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