422 spgPickSplitIn *in = (spgPickSplitIn *)PG_GETARG_POINTER(0);
423 spgPickSplitOut *out = (spgPickSplitOut *)PG_GETARG_POINTER(1);
426 double *lowXs = palloc(
sizeof(
double) * in->nTuples);
427 double *highXs = palloc(
sizeof(
double) * in->nTuples);
428 double *lowYs = palloc(
sizeof(
double) * in->nTuples);
429 double *highYs = palloc(
sizeof(
double) * in->nTuples);
430 double *lowZs = palloc(
sizeof(
double) * in->nTuples);
431 double *highZs = palloc(
sizeof(
double) * in->nTuples);
432 BOX3D *box = DatumGetBox3DP(in->datums[0]);
433 int32_t srid = box->
srid;
436 for (i = 0; i < in->nTuples; i++)
438 BOX3D *box = DatumGetBox3DP(in->datums[i]);
440 lowXs[i] = box->
xmin;
441 highXs[i] = box->
xmax;
442 lowYs[i] = box->
ymin;
443 highYs[i] = box->
ymax;
444 lowZs[i] = box->
zmin;
445 highZs[i] = box->
zmax;
455 median = in->nTuples / 2;
468 out->hasPrefix =
true;
469 out->prefixDatum = Box3DPGetDatum(
centroid);
472 out->nodeLabels = NULL;
474 out->mapTuplesToNodes = palloc(
sizeof(
int) * in->nTuples);
475 out->leafTupleDatums = palloc(
sizeof(Datum) * in->nTuples);
481 for (i = 0; i < in->nTuples; i++)
483 BOX3D *box = DatumGetBox3DP(in->datums[i]);
486 out->leafTupleDatums[i] = Box3DPGetDatum(box);
487 out->mapTuplesToNodes[i] = octant;
static int compareDoubles(const void *a, const void *b)
static uint8 getOctant(BOX3D *centroid, BOX3D *inBox)
Datum centroid(PG_FUNCTION_ARGS)