ST_GeometryN

定义

ST_GeometryN 获取一个集合和一个整数索引,然后返回集合中的第 n 个 ST_Geometry 对象。

语法

sde.st_geometryn (mpt1 sde.st_multipoint, index integer)
sde.st_geometryn (mln1 sde.st_multilinestring, index integer)
sde.st_geometryn (mpl1 sde.st_multipolygon, index integer)

返回类型

ST_Geometry

示例

在本示例中,将创建一个多面。然后使用 ST_GeometryN 列出多面的第二个元素。

Oracle

CREATE TABLE districts (dist_id integer, shape sde.st_multipolygon);

INSERT INTO DISTRICTS (dist_id, shape) VALUES (
1,
sde.st_multipolygon ('multipolygon (((-1 -1, -1 11, 11 11, 11 -1, -1 -1),
(19 -1, 19 11, 29 9, 31 -1, 19 -1), (39 -1, 39 11, 51 11, 51 -1, 39 -1)))', 0)
);

SELECT sde.st_astext (sde.st_geometryn (shape, 2)) Second_Element
FROM DISTRICTS;

Second_Element

POLYGON  ((-1.00000000 -1.00000000, 11.00000000 -1.00000000, 11.0000000 0 11.000

PostgreSQL

CREATE TABLE districts (dist_id integer, shape sde.st_geometry);

INSERT INTO districts (dist_id, shape) VALUES (
1,
sde.st_multipolygon ('multipolygon (((-1 -1, -1 11, 11 11, 11 -1, -1 -1),
(19 -1, 19 11, 29 9, 31 -1, 19 -1), (39 -1, 39 11, 51 11, 51 -1, 39 -1)))', 0)
);

SELECT st_astext (sde.st_geometryn (shape, 2)) AS Second_Element
FROM districts;

Second_Element

POLYGON  ((39 -1, 51 -1, 51 11, 39 11, 39 -1))
9/15/2013