名称

ST_Envelope — 返回一个表示几何图形边界框的几何图形。

概要

geometry ST_Envelope(geometry g1);

描述

返回所提供几何图形的双精度 (float8) 最小边界框,以几何图形的形式返回。多边形由边界框的角点定义 ((MINX, MINY), (MINX, MAXY), (MAXX, MAXY), (MAXX, MINY), (MINX, MINY))。(PostGIS 也会添加 ZMIN/ZMAX 坐标)。

退化情况(垂直线、点)将返回维度低于 POLYGON 的几何图形,即 POINTLINESTRING

可用性:1.5.0 版本行为已更改为输出双精度而不是 float4

此方法实现了OGC Simple Features Implementation Specification for SQL 1.1. s2.1.1.1

此方法实现了 SQL/MM 规范。SQL-MM 3: 5.1.19

示例

SELECT ST_AsText(ST_Envelope('POINT(1 3)'::geometry));
 st_astext
------------
 POINT(1 3)
(1 row)


SELECT ST_AsText(ST_Envelope('LINESTRING(0 0, 1 3)'::geometry));
		   st_astext
--------------------------------
 POLYGON((0 0,0 3,1 3,1 0,0 0))
(1 row)


SELECT ST_AsText(ST_Envelope('POLYGON((0 0, 0 1, 1.0000001 1, 1.0000001 0, 0 0))'::geometry));
						  st_astext
--------------------------------------------------------------
 POLYGON((0 0,0 1,1.00000011920929 1,1.00000011920929 0,0 0))
(1 row)
SELECT ST_AsText(ST_Envelope('POLYGON((0 0, 0 1, 1.0000000001 1, 1.0000000001 0, 0 0))'::geometry));
						  st_astext
--------------------------------------------------------------
 POLYGON((0 0,0 1,1.00000011920929 1,1.00000011920929 0,0 0))
(1 row)

SELECT Box3D(geom), Box2D(geom), ST_AsText(ST_Envelope(geom)) As envelopewkt
	FROM (SELECT 'POLYGON((0 0, 0 1000012333334.34545678, 1.0000001 1, 1.0000001 0, 0 0))'::geometry As geom) As foo;


	

点的包络线和线串。

SELECT ST_AsText(ST_Envelope(
		ST_Collect(
			ST_GeomFromText('LINESTRING(55 75,125 150)'),
				ST_Point(20, 80))
				)) As wktenv;
wktenv
-----------
POLYGON((20 75,20 150,125 150,125 75,20 75))