ST_MPolyFromWKB

Définition

ST_MPointFromWKB accepte une représentation binaire connue (WKB) de type ST_MultiPolygon et un ID de référence spatiale pour retourner un objet ST_MultiPolygon

Syntaxe

Oracle

sde.st_mpolyfromwkb (wkb blob, srid integer)

PostgreSQL

sde.st_mpolyfromwkb (wkb bytea, srid integer)

SQLite

st_mpolyfromwkb (wkb blob, srid int32)

Type de retour

ST_MultiPolygon

Exemple

Cet exemple illustre comment ST_MPolyFromWKB peut être utilisé pour créer un multi-polygone à partir de sa représentation binaire connue. La géométrie est un multi-polygone dans le système de référence spatiale 4326. Dans cet exemple, le multi-polygone est stocké avec l'ID = 10 dans la colonne geometry de la table sample_mpolys, puis la colonne wkb est mise à jour avec sa représentation binaire connue (à l'aide de la fonction ST_AsBinary). Enfin, la fonction ST_MPolyFromWKB est utilisée pour retourner l'objet multipolygon de la colonne wkb. La table sample_mpolys comporte une colonne geometry dans laquelle l'objet multipolygon est stocké, et une colonne wkb dans laquelle la représentation WKB de l'objet multipolygon est stockée.

L'instruction SELECT inclut la fonction ST_MPolyFromWKB, qui permet de récupérer le multipolygone de la colonne WKB.

Oracle

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

INSERT INTO SAMPLE_MPOLYS (id, geometry) VALUES (
 10,
 sde.st_multipolygon ('multipolygon (((1 72, 4 79, 5 76, 1 72), (10 20, 10 40, 30 41, 10 20), (9 43, 7 44, 6 47, 9 43)))', 4326)
);

UPDATE SAMPLE_MPOLYS
 SET wkb = sde.st_asbinary (geometry)
 WHERE id = 10;
SELECT id, sde.st_astext (sde.st_mpolyfromwkb (wkb,4326)) MULTIPOLYGON
 FROM SAMPLE_MPOLYS
 WHERE id = 10;

ID   MULTIPOLYGON

10   MULTIPOLYGON (((10.00000000 20.00000000, 30.00000000 41.00000000, 10.00000000 40.00000000, 10.00000000 20.00000000)), (1.00000000 72.00000000, 5.00000000 76.00000000, 4.00000000 79.0000000, 1.00000000 72,00000000)), (9.00000000 43.00000000, 6.00000000 47.00000000, 7.00000000 44.00000000, 9.00000000 43.00000000 )))

PostgreSQL

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

INSERT INTO sample_mpolys (id, geometry) VALUES (
 10,
 sde.st_multipolygon ('multipolygon (((1 72, 4 79, 5 76, 1 72), (10 20, 10 40, 30 41, 10 20), (9 43, 7 44, 6 47, 9 43)))', 4326)
);

UPDATE sample_mpolys
 SET wkb = sde.st_asbinary (geometry)
 WHERE id = 10;
SELECT id, sde.st_astext (sde.st_mpolyfromwkb (wkb,4326)) 
 AS MULTIPOLYGON
 FROM sample_mpolys
 WHERE id = 10;

id   multipolygon

10   MULTIPOLYGON (((10 20, 30 41, 10 40, 10 20)),
 ((1 72, 5 76, 4 79, 1 72)), ((9 43, 6 47, 7 44, 9 43)))

SQLite

CREATE TABLE sample_mpolys (
 id integer,
 wkb blob
);

SELECT AddGeometryColumn(
 NULL,
 'sample_mpolys',
 'geometry',
 4326,
 'multipolygon',
 'xy',
 'null'
);

INSERT INTO SAMPLE_MPOLYS (id, geometry) VALUES (
 10,
 st_multipolygon ('multipolygon (((1 72, 4 79, 5 76, 1 72), (10 20, 10 40, 30 41, 10 20), (9 43, 7 44, 6 47, 9 43)))', 4326)
);

UPDATE SAMPLE_MPOLYS
 SET wkb = st_asbinary (geometry)
 WHERE id = 10;
SELECT id, st_astext (st_mpolyfromwkb (wkb,4326)) 
 AS "Multipolygon"
 FROM sample_mpolys
 WHERE id = 10;

id   Multipolygon

10   MULTIPOLYGON ((( 10.00000000 20.00000000, 30.00000000 41.00000000, 10.00000000 40.00000000, 10.00000000 20.00000000)),
 ((1.00000000 72.00000000, 5.00000000 76.00000000, 4.00000000 79.00000000, 1.00000000 72.00000000)), 
 ((9.00000000 43.00000000, 6.00000000 47.00000000, 7.00000000 44.00000000, 9.00000000 43.00000000)))

Thèmes connexes

5/10/2014