st_makeenvelope 函数

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

Important

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

返回一个GEOMETRY值,该值表示由两个角坐标和两个角坐标(x1, y1)(x2, y2)定义的二维轴对齐信封(最小边界框)。

Syntax

st_makeenvelope ( x1, y1, x2, y2 )

Arguments

  • x1:一个 DOUBLE 值,表示第一个角的 X 坐标。
  • y1:一个 DOUBLE 值,表示第一个角的 Y 坐标。
  • x2:一个 DOUBLE 值,表示第二个角的 X 坐标。
  • y2:一个 DOUBLE 值,表示第二个角的 Y 坐标。

Returns

类型的 GEOMETRY值,表示两个输入角的 2D 轴对齐信封。 返回的几何图形的 SRID 为 0。

可以按任意顺序提供输入角;生成的信封与转角规范化到 (xmin, ymin)(xmax, ymax)规范化时相同。

返回的几何图形的类型取决于输入角:

  • 如果框退化为单个点(x1 = x2 并且 y1 = y2),则结果是一个点。
  • 如果框退化为段(x1 = x2y1 = y2,但不是两者),则结果是一个带两个点的线字符串。
  • 否则,结果是具有五个顶点(封闭环)的多边形。

如果任何输入为NULL,该函数将返回NULL

示例

-- Returns the polygon envelope defined by two corners.
> SELECT st_astext(st_makeenvelope(1.0, 2.0, 4.0, 6.0));
  POLYGON((1 2,1 6,4 6,4 2,1 2))
-- Corners may be provided in any order.
> SELECT st_astext(st_makeenvelope(4.0, 6.0, 1.0, 2.0));
  POLYGON((1 2,1 6,4 6,4 2,1 2))
-- Returns a point when the box degenerates to a point.
> SELECT st_astext(st_makeenvelope(3.0, 5.0, 3.0, 5.0));
  POINT(3 5)
-- Returns a linestring when the box degenerates to a horizontal segment.
> SELECT st_astext(st_makeenvelope(1.0, 0.0, 4.0, 0.0));
  LINESTRING(1 0,4 0)
-- Returns a linestring when the box degenerates to a vertical segment.
> SELECT st_astext(st_makeenvelope(0.0, 2.0, 0.0, 7.0));
  LINESTRING(0 2,0 7)
-- The SRID of the returned geometry is always 0.
> SELECT st_srid(st_makeenvelope(0.0, 0.0, 10.0, 10.0));
  0