GeometryFromShape は形状と地理情報参照システム ID を引き数として、図形オブジェクトを戻します。
構文
db2gse.GeometryFromShape(ShapeGeometry 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_Polygon);
GeometryFromShape 関数は形状を地理情報エクステンダー図形に変換します。 INSERT ステートメント全体は shp_sql に複写されます。 INSERT ステートメントには、 LOT_ID および LOT データを動的に受け入れるパラメーター・マーカーが含まれています。
/* Create the SQL insert statement to populate the lot_ id and the lot columns. 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.GeometryFromShape (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 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);