Guida di riferimento per l'utente

ST_GeomFromWKB

ST_GeomFromWKB rileva una rappresentazione WKB e un'identità del sistema di riferimento spaziale e restituisce un oggetto di geometria.

Sintassi

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

Tipo di ritorno

db2gse.ST_Geometry

Esempi

Il seguente frammento di codifica C contiene funzioni ODBC integrate alle funzioni SQL DB2 Spatial Extender che inseriscono i dati nella tabella LOTS.

La tabella LOTS è stata creata con due colonne: la colonna LOT_ID, che identifica in modo univoco ogni lotto, e la colonna LOT del multipoligono, che contiene la geometria di ciascun lotto.

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

La funzione ST_GeomFromWKB converte le rappresentazioni WKB nella geometria DB2 Spatial Extender. L'intera istruzione INSERT viene copiata nella stringa wkb_sql char. L'istruzione INSERT contiene i contrassegni di parametro per accettare i dati LOT_ID e LOT in modo dinamico.

/* 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);


[ Inizio pagina | Pagina precedente | Pagina successiva | Indice | Indice analitico ]