408 spgInnerConsistentIn *in = (spgInnerConsistentIn *)PG_GETARG_POINTER(0);
409 spgInnerConsistentOut *out = (spgInnerConsistentOut *)PG_GETARG_POINTER(1);
411 MemoryContext old_ctx;
419 out->nNodes = in->nNodes;
420 out->nodeNumbers = (
int *)palloc(
sizeof(
int) * in->nNodes);
421 for (i = 0; i < in->nNodes; i++)
422 out->nodeNumbers[i] = i;
431 if (in->traversalValue)
432 rect_box = in->traversalValue;
436 centroid = (BOX2DF *)DatumGetPointer(in->prefixDatum);
440 out->nodeNumbers = (
int *)palloc(
sizeof(
int) * in->nNodes);
441 out->traversalValues = (
void **)palloc(
sizeof(
void *) * in->nNodes);
448 old_ctx = MemoryContextSwitchTo(in->traversalMemoryContext);
450 for (quadrant = 0; quadrant < in->nNodes; quadrant++)
455 for (i = 0; i < in->nkeys; i++)
457 StrategyNumber strategy = in->scankeys[i].sk_strategy;
459 Datum query = in->scankeys[i].sk_argument;
460 BOX2DF query_gbox_index;
463 if (DatumGetPointer(query) == NULL)
465 POSTGIS_DEBUG(4,
"[SPGIST] null query pointer (!?!), returning false");
466 PG_RETURN_BOOL(
false);
471 POSTGIS_DEBUG(4,
"[SPGIST] null query_gbox_index!");
472 PG_RETURN_BOOL(
false);
477 case RTOverlapStrategyNumber:
478 case RTContainedByStrategyNumber:
479 case RTOldContainedByStrategyNumber:
480 flag =
overlap4D(next_rect_box, &query_gbox_index);
483 case RTContainsStrategyNumber:
484 case RTSameStrategyNumber:
485 flag =
contain4D(next_rect_box, &query_gbox_index);
488 case RTLeftStrategyNumber:
489 flag = !
overRight4D(next_rect_box, &query_gbox_index);
492 case RTOverLeftStrategyNumber:
493 flag = !
right4D(next_rect_box, &query_gbox_index);
496 case RTRightStrategyNumber:
497 flag = !
overLeft4D(next_rect_box, &query_gbox_index);
500 case RTOverRightStrategyNumber:
501 flag = !
left4D(next_rect_box, &query_gbox_index);
504 case RTAboveStrategyNumber:
505 flag = !
overBelow4D(next_rect_box, &query_gbox_index);
508 case RTOverAboveStrategyNumber:
509 flag = !
below4D(next_rect_box, &query_gbox_index);
512 case RTBelowStrategyNumber:
513 flag = !
overAbove4D(next_rect_box, &query_gbox_index);
516 case RTOverBelowStrategyNumber:
517 flag = !
above4D(next_rect_box, &query_gbox_index);
521 elog(ERROR,
"unrecognized strategy: %d", strategy);
531 out->traversalValues[out->nNodes] = next_rect_box;
532 out->nodeNumbers[out->nNodes] = quadrant;
541 pfree(next_rect_box);
546 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)