使用者の手引きおよび解説書

ST_GeomFromWKB

ST_GeomFromWKB は事前割り当てのバイナリー表現と地理情報参照システム ID を引き数とし、図形オブジェクトを戻します。

構文

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

戻りタイプ

db2gse.ST_Geometry

以下の C コード断片には、 LOTS 表にデータを挿入する ODBC 関数 (地理情報エクステンダーの SQL 関数に組み込まれている) が含まれています。

作成された LOTS 表には 2 つの列があります。 LOT_ID 列はそれぞれの敷地を一意的に識別し、 LOT 複数ポリゴン列にはそれぞれの敷地の図形が含まれています。

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

ST_GeomFromWKB 関数は、WKB 表現を地理情報エクステンダーの図形に変換します。 INSERT ステートメント全体は wkb_sql char string に複写されます。 INSERT ステートメントには、 LOT_ID および 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); 


[ ページのトップ | 前ページ | 次ページ | 目次 | 索引 ]