Returns the length in bytes of the Well-Known Binary (WKB) representation of the Geometry.
Syntax
FNC_GeomSize_t
FNC_GeomGetWKBSize(GEO_HANDLE geoHandle)
Syntax Elements
- geoHandle
- A handle to an ST_Geometry type that is defined to be an input or output parameter to an external routine.
Usage Notes
FNC_GeomGetWKBSize gets the size of the WKB representation of the Geometry. The GEO_HANDLE for the Geometry is passed in as input and the size of the WKB representation of the Geometry is returned to the caller.
Example: Using FNC_GeomGetWKB to retrieve a ST_Geometry WKB
The following example function takes a ST_Geometry parameter and retrieves the Well-Known Binary format for the geometry. It returns the WKB retrieved as a BLOB.
CREATE FUNCTION geomUDF2(P1 st_geometry(1000))
RETURNS BLOB AS LOCATOR
NO SQL
PARAMETER STYLE SQL
DETERMINISTIC
LANGUAGE C
EXTERNAL NAME 'CS!geomUDF2!geomUDF2.c';
void geomUDF2(GEO_HANDLE *geom_handle,
LOB_RESULT_LOCATOR *return_handle,
int* indicator_thisGeom,
int* indicator_returnLOB,
char sqlstate[6],
SQL_TEXT extname[129],
SQL_TEXT specific_name[129],
SQL_TEXT error_message[257] )
{
FNC_GeomSize_t geomsize;
FNC_GeomSize_t wkbSize;
byte* wkbBuffer;
FNC_GeomSize_t wkbBufferSize;
FNC_LobLength_t actlen;
int srid;
/* Get the Geometry WKT Size */
geomsize = FNC_GeomGetWKBSize(*geom_handle);
wkbBuffer = (byte*)FNC_Malloc(geomsize);
wkbBufferSize = geomsize;
/* Get the WKB value */
FNC_GeomGetWKB(*geom_handle,wkbBuffer, wkbBufferSize,
&wkbSize, &srid);
/* Append the WKB to a LOB */
FNC_LobAppend(*return_handle, wkbBuffer, wkbBufferSize,
&actlen);
*indicator_returnLob = 0;
FNC_free(wkbBuffer);
}