ST_Envelope

定义

ST_Envelope 以多边形的形式返回几何对象的最小边界框。

开始行动开始行动:

此函数符合开放地理空间联盟 (OGC) 简单要素规范,其中规定 ST_Envelope 返回多边形。为处理点几何或水平/垂直线的特殊情况,ST_Envelope 函数将返回围绕这些形状的多边形,这是根据几何的空间参考系统的 XY 比例因子计算出的小包络矩形容差。此容差将从最小 x 和 y 中减去,并加到最大 x 和 y 坐标上,从而返回围绕这些形状的多边形。

语法

Oracle 和 PostgreSQL

sde.st_envelope (geometry1 sde.st_geometry)

SQLite

st_envelope (geometry1 geometryblob)

返回类型

Oracle 和 PostgreSQL

ST_Geometry

SQLite

Geometryblob

示例

envelope_test 表的 geotype 列存储 g1 列中存储的几何子类的名称。INSERT 语句将每个几何子类插入 envelope_test 表中。

接下来,ST_Envelope 函数运行并返回围绕各几何的多边形包络矩形。

Oracle

--Create table and insert values.
CREATE TABLE envelope_test (
 geotype varchar(20),
 g1 sde.st_geometry
);

INSERT INTO ENVELOPE_TEST VALUES (
'Point',
sde.st_geometry ('point (-1509734.232 -36684.757)', 102004)
);

INSERT INTO ENVELOPE_TEST VALUES (
'Linestring',
sde.st_geometry ('linestring (-1511144.181 -37680.015, -1509734.232 -38841.149, -1508656.036 -39753.469)', 102004)
);

INSERT INTO ENVELOPE_TEST VALUES (
'Polygon',
sde.st_geometry ('polygon ((-1506333.768 -36435.943, -1504343.252 -36767.695, -1502684.489 -35357.747, -1506333.768 -36435.943))', 102004)
);

INSERT INTO ENVELOPE_TEST VALUES (
'Multipoint',
sde.st_geometry ('multipoint (-1493229.539 -40665.789, -1494141.859 -40831.665, -1495800.622 -42739.242)', 102004)
);

INSERT INTO ENVELOPE_TEST VALUES (
'Multilinestring',
sde.st_geometry ('multilinestring ((-1504757.943 -33201.355, -1507411.964 -35606.561), (-1502518.613 -38094.706, -1499781.653 -37099.448, -1498952.272 -34694.241))', 102004)
);

INSERT INTO ENVELOPE_TEST VALUES (
'Multipolygon',
sde.st_geometry ('multipolygon (((-1492068.405 -47300.841, -1492814.848 -45725.016, -1493975.983 -46471.459,
-1493478.354 -47798.47, -1492068.405 -47300.841), (-1497874.076 -48047.284, -1498537.581 -50618.367, -1497210.571 -50037.8,
-1497874.076 -48047.284)))', 102004)
);
--Return the polygon envelope around each geometry in well-known text.
SELECT geotype geometry_type,
 sde.st_astext (sde.st_envelope (g1)) envelope
 FROM ENVELOPE_TEST;

GEOMETRY_TYPE    ENVELOPE
 
Point           |POLYGON (( -1509734.23220000 -36684.75720000, -1509734.23180000 -36684.75720000, 
-1509734.23180000 -36684.75680000, -1509734.23220000 -36684.75680000, -1509734.23220000 -36684.75720000))

Linestring      |POLYGON (( -1511144.18100000 -39753.46900000, -1508656.03600000 -39753.46900000, 
-1508656.03600000 -37680.01500000, -1511144.18100000 -37680.01500000, -1511144.18100000 -39753.46900000))

Polygon         |POLYGON (( -1506333.76800000 -36767.69500000, -1502684.48900000 -36767.69500000, 
-1502684.48900000 -35357.74700000, -1506333.76800000 -35357.74700000, -1506333.76800000 -36767.69500000))

Multipoint      |POLYGON (( -1495800.62200000 -42739.24200000, -1493229.53900000 -42739.24200000, 
-1493229.53900000 -40665.78900000, -1495800.62200000 -40665.78900000, -1495800.62200000 -42739.24200000))

Multilinestring |POLYGON (( -1507411.96400000 -38094.70600000, -1498952.27200000 -38094.70600000, 
-1498952.27200000 -33201.35500000, -1507411.96400000 -33201.35500000, -1507411.96400000 -38094.70600000))

Multipolygon    |POLYGON (( -1498537.58100000 -50618.36700000, -1492068.40500000 -50618.36700000, 
-1492068.40500000 -45725.01600000, -1498537.58100000 -45725.01600000, -1498537.58100000 -50618.36700000))

PostgreSQL

--Create table and insert values.
CREATE TABLE envelope_test (
 geotype varchar(20),
 g1 sde.st_geometry
);

INSERT INTO ENVELOPE_TEST VALUES (
'Point',
sde.st_geometry ('point (-1509734.232 -36684.757)', 102004)
);

INSERT INTO ENVELOPE_TEST VALUES (
'Linestring',
sde.st_geometry ('linestring (-1511144.181 -37680.015, -1509734.232 -38841.149, -1508656.036 -39753.469)', 102004)
);

INSERT INTO ENVELOPE_TEST VALUES (
'Polygon',
sde.st_geometry ('polygon ((-1506333.768 -36435.943, -1504343.252 -36767.695, -1502684.489 -35357.747, -1506333.768 -36435.943))', 102004)
);

INSERT INTO ENVELOPE_TEST VALUES (
'Multipoint',
sde.st_geometry ('multipoint (-1493229.539 -40665.789, -1494141.859 -40831.665, -1495800.622 -42739.242)', 102004)
);

INSERT INTO ENVELOPE_TEST VALUES (
'Multilinestring',
sde.st_geometry ('multilinestring ((-1504757.943 -33201.355, -1507411.964 -35606.561), (-1502518.613 -38094.706, -1499781.653 -37099.448, -1498952.272 -34694.241))', 102004)
);

INSERT INTO ENVELOPE_TEST VALUES (
'Multipolygon',
sde.st_geometry ('multipolygon (((-1492068.405 -47300.841, -1492814.848 -45725.016, -1493975.983 -46471.459,
-1493478.354 -47798.47, -1492068.405 -47300.841), (-1497874.076 -48047.284, -1498537.581 -50618.367, -1497210.571 -50037.8,
-1497874.076 -48047.284)))', 102004)
);
--Return the polygon envelope around each geometry in well-known text.
SELECT geotype AS geometry_type, 
 sde.st_astext (sde.st_envelope (g1)) AS Envelope
 FROM envelope_test;

geometry_type     envelope

"Point"           |"POLYGON (( -1509734.23220000 -36684.75720000, -1509734.23180000 -36684.75720000, 
-1509734.23180000 -36684.75680000, -1509734.23220000 -36684.75680000, -1509734.23220000 -36684.75720000))"

"Linestring"      |"POLYGON (( -1511144.18100000 -39753.46900000, -1508656.03600000 -39753.46900000, 
-1508656.03600000 -37680.01500000, -1511144.18100000 -37680.01500000, -1511144.18100000 -39753.46900000))"

"Polygon"         |"POLYGON (( -1506333.76800000 -36767.69500000, -1502684.48900000 -36767.69500000, 
-1502684.48900000 -35357.74700000, -1506333.76800000 -35357.74700000, -1506333.76800000 -36767.69500000))"

"Multipoint"      |"POLYGON (( -1495800.62200000 -42739.24200000, -1493229.53900000 -42739.24200000, 
-1493229.53900000 -40665.78900000, -1495800.62200000 -40665.78900000, -1495800.62200000 -42739.24200000))"

"Multilinestring" |"POLYGON (( -1507411.96400000 -38094.70600000, -1498952.27200000 -38094.70600000, 
-1498952.27200000 -33201.35500000, -1507411.96400000 -33201.35500000, -1507411.96400000 -38094.70600000))"

"Multipolygon"    |"POLYGON (( -1498537.58100000 -50618.36700000, -1492068.40500000 -50618.36700000, 
-1492068.40500000 -45725.01600000, -1498537.58100000 -45725.01600000, -1498537.58100000 -50618.36700000))"

SQLite

--Create table and insert values.
CREATE TABLE envelope_test (
 geotype varchar(20)
);

SELECT AddGeometryColumn (
 NULL,
 'envelope_test',
 'g1',
 4326,
 'geometry',
 'xy',
 'null'
);

INSERT INTO ENVELOPE_TEST VALUES (
 'Point',
 st_geometry ('point (-1509734.232 -36684.757)', 102004)
);

INSERT INTO ENVELOPE_TEST VALUES (
 'Linestring',
 st_geometry ('linestring (-1511144.181 -37680.015, -1509734.232 -38841.149, -1508656.036 -39753.469)', 102004)
);

INSERT INTO ENVELOPE_TEST VALUES (
 'Polygon',
 st_geometry ('polygon ((-1506333.768 -36435.943, -1504343.252 -36767.695, -1502684.489 -35357.747, -1506333.768 -36435.943))', 102004)
);

INSERT INTO ENVELOPE_TEST VALUES (
 'Multipoint',
 st_geometry ('multipoint (-1493229.539 -40665.789, -1494141.859 -40831.665, -1495800.622 -42739.242)', 102004)
);

INSERT INTO ENVELOPE_TEST VALUES (
 'Multilinestring',
 st_geometry ('multilinestring ((-1504757.943 -33201.355, -1507411.964 -35606.561), (-1502518.613 -38094.706, -1499781.653 -37099.448, -1498952.272 -34694.241))', 102004)
);

INSERT INTO ENVELOPE_TEST VALUES (
 'Multipolygon',
 st_geometry ('multipolygon (((-1492068.405 -47300.841, -1492814.848 -45725.016, -1493975.983 -46471.459,
-1493478.354 -47798.47, -1492068.405 -47300.841), (-1497874.076 -48047.284, -1498537.581 -50618.367, -1497210.571 -50037.8,
-1497874.076 -48047.284)))', 102004)
);
--Return the polygon envelope around each geometry in well-known text.
SELECT geotype AS geometry_type, 
 st_astext (st_envelope (g1)) AS "Envelope"
 FROM envelope_test;

geometry_type   Envelope

Point           POLYGON (( -1509734.23220000 -36684.75720000, -1509734.23180000 -36684.75720000, 
-1509734.23180000 -36684.75680000, -1509734.23220000 -36684.75680000, -1509734.23220000 -36684.75720000))

Linestring      POLYGON (( -1511144.18100000 -39753.46900000, -1508656.03600000 -39753.46900000, 
-1508656.03600000 -37680.01500000, -1511144.18100000 -37680.01500000, -1511144.18100000 -39753.46900000))

Polygon         POLYGON (( -1506333.76800000 -36767.69500000, -1502684.48900000 -36767.69500000, 
-1502684.48900000 -35357.74700000, -1506333.76800000 -35357.74700000, -1506333.76800000 -36767.69500000))

Multipoint      POLYGON (( -1495800.62200000 -42739.24200000, -1493229.53900000 -42739.24200000, 
-1493229.53900000 -40665.78900000, -1495800.62200000 -40665.78900000, -1495800.62200000 -42739.24200000))

Multilinestring POLYGON (( -1507411.96400000 -38094.70600000, -1498952.27200000 -38094.70600000, 
-1498952.27200000 -33201.35500000, -1507411.96400000 -33201.35500000, -1507411.96400000 -38094.70600000))

Multipolygon    POLYGON (( -1498537.58100000 -50618.36700000, -1492068.40500000 -50618.36700000, 
-1492068.40500000 -45725.01600000, -1498537.58100000 -45725.01600000, -1498537.58100000 -50618.36700000))

相关主题

5/25/2014