共用方式為


st_addpoint函式

適用於:核取標示為是 Databricks SQL 核取標示為是 Databricks Runtime 17.1 和更新版本

Important

這項功能目前處於 公開預覽版

備註

這項功能不適用於 Databricks SQL Classic 倉儲。 若要深入瞭解 Databricks SQL 倉儲,請參閱 SQL 倉儲類型

將新點加入至輸入線串 GEOGRAPHYGEOMETRY 值的第 n 個位置。

Syntax

st_addpoint ( geo1Expr, geo2Expr[, indexExpr] )

Arguments

  • geo1ExprGEOGRAPHYGEOMETRY 值,代表一個行字串。
  • geo2ExprGEOGRAPHYGEOMETRY 值,表示一個點。
  • indexExpr:選擇性 INTEGER 值,表示應該加入新點的行字串中以 1 為基礎的位置。 預設值為 -1。

Returns

如果GEOGRAPHYgeo1Expr都是geo2Expr型別,則為GEOGRAPHY型別的值;如果GEOMETRYgeo1Expr都是geo2Expr型別,則為GEOMETRY型別的值。 如果 indexExpr 為正數,則 GEOGRAPHYGEOMETRY 回傳的值是一個新的線串,其第 indexExpr 點(從左計算)設為 geo2Expr。 如果 indexExpr 為負數,則會從右邊測量新增點所在行字符串的第 1 個位置。

  • 如果任何輸入為 NULL,則函式會傳NULL回 。
  • 輸出行字串的SRID值等於輸入 GEOGRAPHYGEOMETRY 值的通用SRID值。
  • 輸出 GEOGRAPHYGEOMETRY 的行字串的維度與 geo1Expr 的維度相同。 如果 geo2Expr 座標的維度在 geo1Expr 中不存在,則將對應座標設定為 0。

錯誤條件

Examples

-- We do not specify a position; the point is appended at the end (right) of the linestring.
> SELECT st_asewkt(st_addpoint(st_geomfromtext('LINESTRING(1 2,3 4)', 4326), st_geomfromtext('POINT(7 8)', 4326)));
  SRID=4326;LINESTRING(1 2,3 4,7 8)

-- A positive index indicates the position. We add the point at that position in the linestring.
> SELECT st_astext(st_addpoint(st_geomfromtext('LINESTRING(1 2,3 4)'), st_geomfromtext('POINT(7 8)'), 3));
  LINESTRING(1 2,3 4,7 8)

-- The position is specified as a negative index. The point is added at that position counting from the right.
-- The point is missing a Z coordinate. This is set to 0 when the point is added in the linestring.
> SELECT st_asewkt(st_addpoint(st_geogfromtext('LINESTRING ZM (1 2 3 4,5 6 7 8)'), st_geogfromtext('POINT M (0 9 99)'), -1));
  SRID=4326;LINESTRING ZM (1 2 3 4,5 6 7 8,0 9 0 99)