/*****************************************************************************
**
** Function name:
**
** MyShapeSetUnion
**
** Description:
**
** This is an R-Tree support function which enables the
** server to use a fast method of building an R-Tree index.
**
** Special Comments:
**
** The SQL function signature for this function is
** "SetUnion (UDT, integer, pointer)". This requires an explanation:
**
** The purpose of the first argument is to provide function signature
** uniqueness, since you must declare a separate ObjectLength function
** for each subtype in that can participate in the opclass. In reality
** the server will pass an lvarchar containing an array of UDTs.
**
** The second argument is an integer containing the size of the
** array in the first arguments
**
** The third argument is declared to be an SQL pointer (i.e. void *);
** in reality it is an instance of a 'header' subtype. A 'header'
** subtype is the data structure that contains just a bounding box;
** it is the same thing as the 3rd argument of the Union support
** function. If your UDTs are variable length, this UDT instance
** will be wrapped in an mi_lvarchar. If your UDTs are fixed length
** you will get a pointer to the structure itself. In both cases
** the server allocates memory for the structure for you.
**
** Parameters:
**
** mi_lvarchar *objects Array of UDTs, wrapped in an mi_lvarchar
** mi_integer *array_size Size of array.
** void *union Pointer to resultant union shape.
** MI_FPARAM *fp UDR function parameter & state info.
**
** Return value:
**
** mi_integer MI_OK if success, MI_ERROR if problems.
**
*****************************************************************************/
UDREXPORT mi_integer
MyShapeSetUnion (mi_lvarchar *objects,
mi_integer array_size,
mi_lvarchar *union_shape,
MI_FPARAM *fp)
{
mi_lvarchar **shape_array = (mi_lvarchar **) mi_get_vardata (objects);
mi_integer i;
SHAPE_TRACE_ENTER (MyShapeSetUnion);
MyShapeUnion (shape_array[0], shape_array[0], union_shape, fp);
for (i = 1; i < array_size; i++)
{
MyShapeUnion (shape_array[i], union_shape, union_shape, fp);
}
SHAPE_TRACE_EXIT (MyShapeSetUnion);
return MI_OK;
}