ST_AsBinary

定义

ST_AsBinary 获取一个几何对象,然后返回其可识别的二进制表示。

语法

Oracle 和 PostgreSQL

sde.st_asbinary (geometry sde.st_geometry)

SQLite

st_asbinary (geometry geometryblob)

返回类型

Oracle 和 PostgreSQL

ST_Geometry

SQLite

Geometryblob

示例

本示例使用记录 1100 中 GEOMETRY 列的内容填充记录 1111 中的 WKB 列。

Oracle

CREATE TABLE sample_points (
 id integer not null, 
 geometry sde.st_geometry, 
 wkb blob
);

INSERT INTO SAMPLE_POINTS (id, geometry) VALUES (
 1100,
 sde.st_geometry ('point (10 20)', 4326)
);

INSERT INTO SAMPLE_POINTS (id, wkb) VALUES (
 1111,
 (SELECT sde.st_asbinary (geometry) FROM sample_points WHERE id = 1100)
);

SELECT id, sde.st_astext (sde.st_geomfromwkb (wkb, 4326))
 FROM SAMPLE_POINTS
 WHERE id = 1111;

ID 	     Point 
1111     POINT (10.00000000 20.00000000)

PostgreSQL

CREATE TABLE sample_points (
 id serial, 
 geometry sde.st_geometry, 
 wkb bytea);

INSERT INTO sample_points (geometry) VALUES (
 sde.st_point (10, 20, 4326)
);

INSERT INTO sample_points (wkb) VALUES (
 (SELECT sde.st_asbinary (geometry) FROM sample_points WHERE id = 1100)
);

SELECT id, sde.st_astext (sde.st_geomfromwkb (wkb, 4326))
 FROM sample_points
 WHERE id = 1111;

ID 	     st_astext
1111     POINT (10 20)

SQLite

CREATE TABLE sample_points (
 id integer primary key autoincrement not null,
 wkb blob 
);

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

INSERT INTO sample_points (geometry) VALUES (
 st_point (10, 20, 4326)
);

INSERT INTO sample_points (wkb) VALUES (
 (SELECT st_asbinary (geometry) FROM sample_points WHERE id = 1)
);

SELECT id, st_astext (st_geomfromwkb (wkb, 4326))
 FROM sample_points
 WHERE id = 2;

ID 	     st_astext
2        POINT (10.00000000 20.00000000)

相关主题

5/25/2014