ST_PolyFromWKB

Définition

ST_PolyFromWKB accepte une représentation binaire connue (WKB) et un ID de référence spatiale, puis renvoie un objet ST_Polygon.

Syntaxe

Oracle

sde.st_polyfromwkb (wkb blob, srid integer)

PostgreSQL

sde.st_polyfromwkb (wkb bytea, srid integer)

SQLite

st_polyfromwkb (wkb blob, srid int32)

Type de retour

ST_Polygon

Exemple

Cet exemple illustre la façon dont ST_PolyFromWKB permet de créer un polygone à partir de sa représentation binaire connue. La géométrie est un polygone dans le système de référence spatiale 4326. Dans cet exemple, le polygone est stocké avec l'ID = 1115 dans la colonne geometry de la table sample_polys, puis la colonne wkb est mise à jour avec sa représentation WKB (à l'aide de la fonction ST_AsBinary). Enfin, la fonction ST_PolyFromWKB permet de renvoyer le multi-polygone de la colonne WKB. La table sample_polys comporte une colonne geometry, dans laquelle le polygone est stocké, et une colonne wkb dans laquelle la représentation WKB du polygone est stockée.

Dans l'instruction SELECT, la fonction ST_PointFromWKB permet de récupérer les points de la colonne 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)

Thèmes connexes

5/10/2014