FNC_MBBGetValue Function | C Library Functions | Teradata Vantage - FNC_MBBGetValue - Analytics Database - Teradata Vantage

SQL External Routine Programming

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2023-07-11
dita:mapPath
iiv1628111441820.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
B035-1147
lifecycle
latest
Product Category
Teradata Vantageā„¢

Returns a buffer containing six double precision values representing the xmin, ymin, zmin, xmax, ymax, and zmax coordinates that define an MBB (minimum bounding box) type.

Syntax

void
FNC_MBBGetValue(GEO_HANDLE    mbbHandle,
                double *      mbbBuffer,
                int *         mbbSize  )

Syntax Elements

mbbHandle
A handle to an MBB type that is defined to be an input parameter to an external routine.
mbbBuffer
A pointer to a buffer that will hold the six double precision values that define the MBB.
mbbSize
Size in bytes of the value returned in the mbbBuffer buffer.

Usage Notes

FNC_MBBGetValue retrieves the xmin, ymin, zmin, xmax, ymax, and zmax values of an MBB type. The values are returned in the mbbBuffer as six double precision values. The caller of the function needs to allocate sufficient memory for the mbbBuffer buffer to hold six double precision values.

Example: Using FNC calls to get an MBB type value

The following function takes an MBB type parameter and returns an array of six double precision values representing the xmin, ymin, zmin, xmax, ymax, and zmax values that define the MBB.

CREATE TYPE MBB_ARRAY AS DOUBLE PRECISION ARRAY[6];
CREATE FUNCTION mbbUDF1(P1 MBB)
RETURNS MBB_ARRAY
NO SQL
PARAMETER STYLE SQL
DETERMINISTIC
LANGUAGE C
EXTERNAL NAME 'CS!mbbUDF1!mbbUDF1.c';

void mbbUDF1 (GEO_HANDLE* mbb_handle,
              ARRAY_HANDLE* resultArray,
              int* indicator_thismbb,
              int* indicator_Result,
              char       sqlstate[6],
              SQL_TEXT   extname[129],
              SQL_TEXT   specific_name[129],
              SQL_TEXT   error_message[257] )
{
     double* mbbBuffer;
     int returnSize;
     int mbbBufferSize;
     array_info_t arrayInfo;
     bounds_t arrayScope[FNC_MAXARRAYDIMENSIONS];
     NullBitVecType    *NullBitVector;

     mbbBufferSize = 6 * SIZEOF_DOUBLE_PRECISION;
     mbbBuffer = (double*)FNC_Malloc(mbbBufferSize);
     /* Get the MBB value */
      FNC_MBBGetValue(*mbb_handle,mbbBuffer,&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*)mbbBuffer,
                       mbbBufferSize, NullBitVector,1);

    *indicator_Result = 0;
     FNC_free(NullBitVector);
     FNC_free(mbbBuffer);
}