ST_LineFromWKB

定义

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

语法

Oracle

sde.st_linefromwkb (wkb blob, srid integer)

PostgreSQL

sde.st_linefromwkb (wkb bytea, srid integer)

SQLite

st_linefromwkb (wkb blob, srid int32)

返回类型

ST_LineString

示例

以下命令创建表 (sample_lines),并使用 ST_LineFromWKB 函数从 WKB 表示插入线。该行将被插入到包含 ID 和使用 WKB 表示的空间参考系统 4326 中的线的 sample_lines 表中。

Oracle

PostgreSQL

Oracle

CREATE TABLE sample_lines (
 id smallint,
 geometry sde.st_linestring,
 wkb blob
);

INSERT INTO SAMPLE_LINES (id, geometry) VALUES (
 1901,
 sde.st_linestring ('linestring (850 250, 850 850)', 4326)
);

INSERT INTO SAMPLE_LINES (id, geometry) VALUES (
 1902,
 sde.st_linestring ('linestring (33 2, 34 3, 35 6)', 4326)
);

UPDATE SAMPLE_LINES
 SET wkb = sde.st_asbinary (geometry)
 WHERE id = 1901;

UPDATE SAMPLE_LINES
 SET wkb = sde.st_asbinary (geometry)
 WHERE id = 1902;

SELECT id, sde.st_astext (sde.st_linefromwkb (wkb,4326)) LINE
 FROM SAMPLE_LINES;

ID   LINE 

1901 LINESTRING (850.00000000 250.00000000, 850.00000000 850.00000000) 
1902 LINESTRING (33.00000000 2.00000000, 34.00000000 3.00000000, 35.00000000 6.00000000)

PostgreSQL

CREATE TABLE sample_lines (
 id serial,
 geometry sde.st_linestring,
 wkb bytea
);

INSERT INTO sample_lines (geometry) VALUES (
 sde.st_linestring ('linestring (850 250, 850 850)', 4326)
);

INSERT INTO sample_lines (geometry) VALUES (
 sde.st_linestring ('linestring (33 2, 34 3, 35 6)', 4326)
);

--Replace ID values if necessary.
UPDATE sample_lines
 SET wkb = sde.st_asbinary (geometry)
 WHERE id = 1;

UPDATE sample_lines
 SET wkb = sde.st_asbinary (geometry)
 WHERE id = 2;

SELECT id, sde.st_astext (st_linefromwkb (wkb,4326)) 
 AS LINE
 FROM sample_lines;

id   line 

1    LINESTRING (850 250, 850 850) 
2    LINESTRING (33 2, 34 3, 35 6)

SQLite

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

SELECT AddGeometryColumn (
 NULL,
 'sample_lines',
 'geometry',
 4326,
 'linestring',
 'xy',
 'null'
);

INSERT INTO sample_lines (geometry) VALUES (
 st_linestring ('linestring (850 250, 850 850)', 4326)
);

INSERT INTO sample_lines (geometry) VALUES (
 st_linestring ('linestring (33 2, 34 3, 35 6)', 4326)
);

--Replace ID values if necessary.
UPDATE sample_lines
 SET wkb = st_asbinary (geometry)
 WHERE id = 1;

UPDATE sample_lines
 SET wkb = st_asbinary (geometry)
 WHERE id = 2;

SELECT id, st_astext (st_linefromwkb (wkb,4326)) 
 AS LINE
 FROM sample_lines;

id   LINE 

1    LINESTRING (850.00000000 250.00000000, 850.00000000 850.00000000) 
2    LINESTRING (33.00000000 2.00000000, 34.00000000 3.00000000, 35.00000000 6.00000000)

相关主题

5/25/2014