FNC_MBBGetValue Function | C Library Functions | Teradata Vantage - FNC_MBBGetValue - Advanced SQL Engine - Teradata Database

SQL External Routine Programming

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
June 2020
Language
English (United States)
Last Update
2021-01-24
dita:mapPath
qwr1571437338192.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1147
lifecycle
previous
Product Category
Teradata Vantage™

Purpose

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  )
GEO_HANDLE mbbHandle
A handle to an MBB type that is defined to be an input parameter to an external routine.
double* mbbBuffer
A pointer to a buffer that will hold the six double precision values that define the MBB.
int* 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);
}