ST_PointFromWKB

定义

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

语法

Oracle

PostgreSQL

Oracle

sde.st_pointfromwkb (wkb blob, srid integer)

PostgreSQL

sde.st_pointfromwkb (wkb bytea, srid integer)

SQLite

st_pointfromwkb (wkb blob, srid int32)

返回类型

ST_Point

示例

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

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

Oracle

CREATE TABLE sample_points (
 id integer,
 geometry sde.st_point,
 wkb blob
);

INSERT INTO SAMPLE_POINTS (id, geometry) VALUES (
 10,
 sde.st_point ('point (44 14)', 4326)
);

INSERT INTO SAMPLE_POINTS (id, geometry) VALUES (
 11,
 sde.st_point ('point (24 13)', 4326)
);

UPDATE SAMPLE_POINTS
 SET wkb = sde.st_asbinary (geometry)
 WHERE id = 10;

UPDATE SAMPLE_POINTS
 SET wkb = sde.st_asbinary (geometry)
 WHERE id = 11;
SELECT id, sde.st_astext (sde.st_pointfromwkb(wkb, 4326)) POINTS
 FROM SAMPLE_POINTS;

ID POINTS

10 POINT (44.00000000 14.00000000) 
11 POINT (24.00000000 13.00000000)

PostgreSQL

CREATE TABLE sample_points (
 id integer,
 geometry sde.st_point,
 wkb bytea
);

INSERT INTO sample_points (id, geometry) VALUES (
 10,
 sde.st_point ('point (44 14)', 4326)
);

INSERT INTO sample_points (id, geometry) VALUES (
 11,
 sde.st_point ('point (24 13)', 4326)
);

UPDATE sample_points
 SET wkb = sde.st_asbinary (geometry)
 WHERE id = 10;

UPDATE sample_points
 SET wkb = sde.st_asbinary (geometry)
 WHERE id = 11;
SELECT id, sde.st_astext (sde.st_pointfromwkb(wkb, 4326)) 
 AS points
 FROM sample_points;

id points

10 POINT (44 14) 
11 POINT (24 13)

SQLite

CREATE TABLE sample_pts (
 id integer,
 wkb blob
);

SELECT AddGeometryColumn(
 NULL,
 'sample_pts',
 'geometry',
 4326,
 'point',
 'xy',
 'null'
);

INSERT INTO sample_pts (id, geometry) VALUES (
 10,
 st_point ('point (44 14)', 4326)
);

INSERT INTO sample_pts (id, geometry) VALUES (
 11,
 st_point ('point (24 13)', 4326)
);

UPDATE sample_pts
 SET wkb = st_asbinary (geometry)
 WHERE id = 10;

UPDATE sample_pts
 SET wkb = st_asbinary (geometry)
 WHERE id = 11;
SELECT id, st_astext (st_pointfromwkb(wkb, 4326)) 
 AS "points"
 FROM sample_pts;

id points

10 POINT (44.00000000 14.00000000) 
11 POINT (24.00000000 13.00000000)

相关主题

5/25/2014