用户指南和参考

GeometryFromShape

GeometryFromShape 接受形状和 Spatial 参考系标识以返回几何图形对象。

语法

db2gse.GeometryFromShape(ShapeGeometry Blob(1M), cr db2gse.coordref)

返回类型

db2gse.ST_Geometry

示例

以下 C 代码段包含 ODBC 函数,这些函数嵌有将数据插入 LOTS 表的 DB2 Spatial Extender SQL 函数。

已创建了 LOTS 表,该表具有两列:LOT_ID 列和 LOT 多边形列, 前者唯一标识每个地块;后者包含每个地块的几何图形。

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

GeometryFromShape 函数将形状转换为 DB2 Spatial Extender 几何图形。将整个 INSERT 语句复制到 shp_sql。 该 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 (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);
 


[ 页的顶部 | 上一页 | 下一页 | 目录 | 索引 ]