ST_PolyFromWKB

定义

ST_PolyFromWKB 以熟知二进制 (WKB) 表示和空间参考 ID 作为输入参数,返回 ST_Polygon 类型的对象。

语法

Oracle

sde.st_polyfromwkb (wkb blob, srid integer)

PostgreSQL

sde.st_polyfromwkb (wkb bytea, srid integer)

SQLite

st_polyfromwkb (wkb blob, srid int32)

返回类型

ST_Polygon

示例

本示例说明了如何使用 ST_PolyFromWKB 从熟知二进制表示创建面。几何是空间参考系统 4326 中的面。在本示例中,面存储在 sample_polys 表的几何列中且 ID = 1115,然后利用 WKB 表示对 wkb 列进行更新(使用 ST_AsBinary 函数)。最后,ST_PolyFromWKB 函数用于从 WKB 列中返回多面。sample_polys 表具有一个几何列(用于存储面)和一个 wkb 列(用于存储面的 WKB 表示)。

在下面的 SELECT 语句中,ST_PointFromWKB 函数用于从 WKB 列中获取点对象。

Oracle

CREATE TABLE sample_polys (
 id integer,
 geometry sde.st_geometry,
 wkb blob
);

INSERT INTO SAMPLE_POLYS (id, geometry) VALUES (
 1115,
 sde.st_polyfromtext ('polygon ((10.01 20.03, 10.52 40.11, 30.29 41.56, 31.78 10.74, 10.01 20.03))', 4326)
);

UPDATE SAMPLE_POLYS
 SET wkb = sde.st_asbinary (geometry)
 WHERE id = 1115;
SELECT id, sde.st_astext (sde.st_polyfromwkb (wkb, 4326)) POLYS
 FROM SAMPLE_POLYS;

ID    	POLYS

1115    POLYGON (10.01000000 20.03000000, 31.78000000 10.74000000, 30.29000000 41.56000000, 10.52000000 40.11000000, 10.01000000 20.03000000)

PostgreSQL

CREATE TABLE sample_polys (
 id integer,
 geometry sde.st_geometry,
 wkb bytea
);

INSERT INTO sample_polys (id, geometry) VALUES (
 1115,
 sde.st_polygon ('polygon  ((10.01 20.03, 10.52 40.11, 30.29 41.56, 31.78 10.74, 10.01 20.03))', 4326)
);

UPDATE sample_polys
 SET wkb = sde.st_asbinary (geometry)
 WHERE id = 1115;
SELECT id, sde.st_astext (sde.st_polyfromwkb (wkb, 4326)) 
 AS POLYS
 FROM sample_polys;

id    polys

1115    POLYGON (10.01000000 20.03000000, 31.78000000 10.74000000, 30.29000000 41.56000000, 10.52000000 40.11000000, 10.01000000 20.03000000)

SQLite

CREATE TABLE sample_polys(
 id integer,
 wkb blob
);

SELECT AddGeometryColumn(
 NULL,
 'sample_polys',
 'geometry',
 4326,
 'polygon',
 'xy',
 'null'
);

INSERT INTO sample_polys (id, geometry) VALUES (
 1115,
 st_polyfromtext ('polygon ((10.01 20.03, 10.52 40.11, 30.29 41.56, 31.78 10.74, 10.01 20.03))', 4326)
);

UPDATE sample_polys
 SET wkb = st_asbinary (geometry)
 WHERE id = 1115;
SELECT id, st_astext (st_polyfromwkb (wkb, 4326)) 
 AS "polygons"
 FROM sample_polys;

id    polygons

1115    POLYGON (10.01000000 20.03000000, 31.78000000 10.74000000, 30.29000000 41.56000000, 10.52000000 40.11000000, 10.01000000 20.03000000)

相关主题

5/25/2014