Guide d'utilisation et de référence

ST_GeomFromWKB

ST_GeomFromWKB utilise en entrée une représentation de type binaire connue (WKB) et un identificateur de système de références spatiales, et renvoie un objet de type géométrie.

Syntaxe

db2gse.ST_GeomFromWKB(WKBGeometry Blob(1M), SRID db2gse.coordref)

Type de retour

db2gse.ST_Geometry

Exemples

Le fragment de code C présenté ci-dessous contient des fonctions ODBC imbriquées dans des fonctions SQL Extension Spatiale qui insèrent des données dans la table LOTS.

La table LOTS a été créée avec deux colonnes : la colonne LOT_ID qui identifie chaque parcelle de façon univoque et la colonne des multipolygones LOT, qui contient la géométrie de chaque parcelle.

CREATE TABLE LOTS ( lot_id   integer,
                    lot      db2gse.ST_MultiPolygon);

La fonction ST_GeomFromWKB convertit les représentations WKB en géométrie Extension Spatiale. La totalité de l'instruction INSERT est copiée dans une chaîne de caractères de type wkb_sql. L'instruction INSERT contient des marqueurs de paramètre permettant d'accepter dynamiquement les données LOT_ID et LOT.

/* Create the SQL insert statement to populate the lot id and the
   lot multipolygon. The question marks are parameter markers that
   indicate the lot_id and lot values that will be retrieved at
   runtime. */
strcpy (wkb_sql,"insert into LOTS (lot_id, lot) values (?,
db2gse.ST_GeomFromWKB
 
(cast(? as blob(1m)),
db2gse.coordref()..srid(0)))");
 
/* Allocate memory for the SQL statement handle and associate the
   statement handle with the connection handle. */
rc = SQLAllocStmt (handle, &hstmt);
 
/* Prepare the SQL statement for execution. */
rc = SQLPrepare (hstmt, (unsigned char *)wkb_sql, SQL_NTS);
 
/* Bind the integer key value to the first parameter. */
pcbvalue1 = 0;
rc = SQLBindParameter (hstmt, 1, SQL_PARAM_INPUT, SQL_C_SLONG,
     SQL_INTEGER, 0, 0, &lot_id, 0, &pcbvalue1);
 
/* Bind the shape to the second parameter. */
pcbvalue2 = blob_len;
rc = SQLBindParameter (hstmt, 2, SQL_PARAM_INPUT, SQL_C_BINARY,
     SQL_BLOB, blob_len, 0, shape_blob, blob_len, &pcbvalue2);
 
/* Execute the insert statement. */
rc = SQLExecute (hstmt);


[ Début de page | Page précédente | Page suivante | Table des matières | Index ]