Returns a buffer containing four double precision values representing the xmin, ymin, xmax, and ymax coordinates that define an MBR (minimum bounding rectangle) type.
Syntax
void FNC_MBRGetValue(GEO_HANDLE mbrHandle, double * mbrBuffer, int * mbrSize )
Syntax Elements
- mbrHandle
- A handle to an MBR type that is defined to be an input parameter to an external routine.
- mbrBuffer
- A pointer to a buffer that will hold the four double precision values that define the MBR.
- mbrSize
- Size in bytes of the value returned in the mbrBuffer buffer.
Usage Notes
FNC_MBRGetValue retrieves the xmin, ymin, xmax, and ymax values of an MBR type. The values are returned in the mbrBuffer as four double precision values. The caller of the function needs to allocate sufficient memory for the mbrBuffer buffer to hold four double precision values.
Example: Using FNC calls to get an MBR type value
The following function takes an MBR type parameter and returns an array of four double precision values representing the xmin, ymin, xmax, and ymax values that define the MBR.
CREATE TYPE MBR_ARRAY AS DOUBLE PRECISION ARRAY[4];
CREATE FUNCTION mbrUDF1(P1 MBR)
RETURNS MBR_ARRAY
NO SQL
PARAMETER STYLE SQL
DETERMINISTIC
LANGUAGE C
EXTERNAL NAME 'CS!mbrUDF1!mbrUDF1.c';
void mbrUDF1 (GEO_HANDLE* mbr_handle,
ARRAY_HANDLE* resultArray,
int* indicator_thismbr,
int* indicator_Result,
char sqlstate[6],
SQL_TEXT extname[129],
SQL_TEXT specific_name[129],
SQL_TEXT error_message[257] )
{
double* mbrBuffer;
int returnSize;
int mbrBufferSize;
array_info_t arrayInfo;
bounds_t arrayScope[FNC_MAXARRAYDIMENSIONS];
NullBitVecType *NullBitVector;
mbrBufferSize = 4 * SIZEOF_DOUBLE_PRECISION;
mbrBuffer = (double*)FNC_Malloc(mbrBufferSize);
/* Get the MBR value */
FNC_MBRGetValue(*mbr_handle,mbrBuffer,&returnSize);
/* get element type information for the ARRAY */
FNC_GetArrayTypeInfo(*((ARRAY_HANDLE*)resultArray),
&arrayInfo,
arrayScope);
/* Allocate a new NullBitVector */
NullBitVector = (NullBitVecType*)FNC_malloc(1);
/* Set array elements within the range. */
FNC_SetArrayElementsWithMultiValues(
*((ARRAY_HANDLE*)resultArray),
arrayScope,
(void*)mbrBuffer,
mbrBufferSize, NullBitVector,1);
*indicator_Result = 0;
FNC_free(NullBitVector);
FNC_free(mbrBuffer);
}