410 spgInnerConsistentIn *in = (spgInnerConsistentIn *)PG_GETARG_POINTER(0);
411 spgInnerConsistentOut *out = (spgInnerConsistentOut *)PG_GETARG_POINTER(1);
413 MemoryContext old_ctx;
421 out->nNodes = in->nNodes;
422 out->nodeNumbers = (
int *)palloc(
sizeof(
int) * in->nNodes);
423 for (i = 0; i < in->nNodes; i++)
424 out->nodeNumbers[i] = i;
433 if (in->traversalValue)
434 rect_box = in->traversalValue;
438 centroid = (BOX2DF *)DatumGetPointer(in->prefixDatum);
442 out->nodeNumbers = (
int *)palloc(
sizeof(
int) * in->nNodes);
443 out->traversalValues = (
void **)palloc(
sizeof(
void *) * in->nNodes);
450 old_ctx = MemoryContextSwitchTo(in->traversalMemoryContext);
452 for (quadrant = 0; quadrant < in->nNodes; quadrant++)
457 for (i = 0; i < in->nkeys; i++)
459 StrategyNumber strategy = in->scankeys[i].sk_strategy;
461 Datum query = in->scankeys[i].sk_argument;
462 BOX2DF query_gbox_index;
465 if (DatumGetPointer(query) == NULL)
467 POSTGIS_DEBUG(4,
"[SPGIST] null query pointer (!?!), returning false");
468 PG_RETURN_BOOL(
false);
473 POSTGIS_DEBUG(4,
"[SPGIST] null query_gbox_index!");
474 PG_RETURN_BOOL(
false);
479 case RTOverlapStrategyNumber:
480 case RTContainedByStrategyNumber:
481 case RTOldContainedByStrategyNumber:
482 flag =
overlap4D(next_rect_box, &query_gbox_index);
485 case RTContainsStrategyNumber:
486 case RTSameStrategyNumber:
487 flag =
contain4D(next_rect_box, &query_gbox_index);
490 case RTLeftStrategyNumber:
491 flag = !
overRight4D(next_rect_box, &query_gbox_index);
494 case RTOverLeftStrategyNumber:
495 flag = !
right4D(next_rect_box, &query_gbox_index);
498 case RTRightStrategyNumber:
499 flag = !
overLeft4D(next_rect_box, &query_gbox_index);
502 case RTOverRightStrategyNumber:
503 flag = !
left4D(next_rect_box, &query_gbox_index);
506 case RTAboveStrategyNumber:
507 flag = !
overBelow4D(next_rect_box, &query_gbox_index);
510 case RTOverAboveStrategyNumber:
511 flag = !
below4D(next_rect_box, &query_gbox_index);
514 case RTBelowStrategyNumber:
515 flag = !
overAbove4D(next_rect_box, &query_gbox_index);
518 case RTOverBelowStrategyNumber:
519 flag = !
above4D(next_rect_box, &query_gbox_index);
523 elog(ERROR,
"unrecognized strategy: %d", strategy);
533 out->traversalValues[out->nNodes] = next_rect_box;
534 out->nodeNumbers[out->nNodes] = quadrant;
543 pfree(next_rect_box);
548 MemoryContextSwitchTo(old_ctx);
int gserialized_datum_get_box2df_p(Datum gsdatum, BOX2DF *box2df)
Peak into a GSERIALIZED datum to find the bounding box.
static bool right4D(RectBox *rect_box, BOX2DF *query)
static bool overRight4D(RectBox *rect_box, BOX2DF *query)
static bool overlap4D(RectBox *rect_box, BOX2DF *query)
static bool overAbove4D(RectBox *rect_box, BOX2DF *query)
static bool above4D(RectBox *rect_box, BOX2DF *query)
static RectBox * nextRectBox(RectBox *rect_box, BOX2DF *centroid, uint8 quadrant)
static RectBox * initRectBox(void)
static bool contain4D(RectBox *rect_box, BOX2DF *query)
static bool left4D(RectBox *rect_box, BOX2DF *query)
static bool below4D(RectBox *rect_box, BOX2DF *query)
static bool overBelow4D(RectBox *rect_box, BOX2DF *query)
static bool overLeft4D(RectBox *rect_box, BOX2DF *query)
Datum centroid(PG_FUNCTION_ARGS)