Guide d'utilisation et de référence

MPolyFromShape

MPolyFromShape utilise en entrée une forme de type multipolygone et un identificateur de système de références spatiales, et renvoie un multipolygone.

Syntaxe

db2gse.MPolyFromShape(ShapeMultiPolygon Blob(1m), SRID db2gse.coordref)

Type de retour

db2gse.ST_MultiPolygon

Exemples

Le fragment de code ci-après peuple la table LOTS.

La table LOTS stocke l'ID parcelle (lot_id) qui identifie chaque parcelle de manière univoque, ainsi que le multipolygone de parcelle, qui contient la géométrie de type ligne de ladite parcelle.

CREATE TABLE LOTS (  lot_id integer, lot db2gse.ST_MultiPolygon );
 
/* Create the SQL insert statement to populate the lot_id and lot. The
   question marks are parameter markers that indicate the lot_id and lot
   values that will be retrieved at runtime. */
strcpy (shp_sql,"insert into LOTS (lot_id,lot)
values (?, db2gse.MPolyFromShape (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 *)shp_sql, SQL_NTS);
 
/* Bind the lot_id integer value to the first parameter. */
pcbvalue1 = 0;
rc = SQLBindParameter (hstmt, 1, SQL_PARAM_INPUT, SQL_C_INTEGER,
   SQL_INTEGER, 0, 0, &lot_id, 0, &pcbvalue1);
 
/* Bind the lot shape to the second parameter. */
pcbvalue2 = lot_len;
rc = SQLBindParameter (hstmt, 2, SQL_PARAM_INPUT, SQL_C_BINARY,
     SQL_BLOB, lot_len, 0, lot_shape, lot_len, &pcbvalue2);
 
/* Execute the insert statement. */
rc = SQLExecute (hstmt);


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