PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ gserialized_spgist_leaf_consistent_2d()

PGDLLEXPORT Datum gserialized_spgist_leaf_consistent_2d ( PG_FUNCTION_ARGS  )

Definition at line 556 of file gserialized_spgist_2d.c.

557 {
558  spgLeafConsistentIn *in = (spgLeafConsistentIn *)PG_GETARG_POINTER(0);
559  spgLeafConsistentOut *out = (spgLeafConsistentOut *)PG_GETARG_POINTER(1);
560  BOX2DF *key = (BOX2DF *)DatumGetPointer(in->leafDatum);
561  bool flag = true;
562  int i;
563 
564  /* Quick sanity check on entry key. */
565  if (DatumGetPointer(key) == NULL)
566  {
567  POSTGIS_DEBUG(4, "[SPGIST] null index entry, returning false");
568  PG_RETURN_BOOL(false); /* NULL entry! */
569  }
570 
571  /* All tests are exact. */
572  out->recheck = false;
573 
574  /* leafDatum is what it is... */
575  out->leafValue = in->leafDatum;
576 
577  /* Perform the required comparison(s) */
578  for (i = 0; i < in->nkeys; i++)
579  {
580  StrategyNumber strategy = in->scankeys[i].sk_strategy;
581  Datum query = in->scankeys[i].sk_argument;
582  BOX2DF query_gbox_index;
583 
584  /* Quick sanity check on query argument. */
585  if (DatumGetPointer(query) == NULL)
586  {
587  POSTGIS_DEBUG(4, "[SPGIST] null query pointer (!?!), returning false");
588  PG_RETURN_BOOL(false); /* NULL query! This is screwy! */
589  }
590 
591  if (gserialized_datum_get_box2df_p(query, &query_gbox_index) == LW_FAILURE)
592  {
593  POSTGIS_DEBUG(4, "[SPGIST] null query_gbox_index!");
594  PG_RETURN_BOOL(false);
595  }
596 
597  switch (strategy)
598  {
599  case RTOverlapStrategyNumber:
600  flag = box2df_overlaps(key, &query_gbox_index);
601  break;
602 
603  case RTContainsStrategyNumber:
604  case RTOldContainsStrategyNumber:
605  flag = box2df_contains(key, &query_gbox_index);
606  break;
607 
608  case RTContainedByStrategyNumber:
609  case RTOldContainedByStrategyNumber:
610  flag = box2df_contains(&query_gbox_index, key);
611  break;
612 
613  case RTSameStrategyNumber:
614  flag = box2df_equals(key, &query_gbox_index);
615  break;
616 
617  case RTLeftStrategyNumber:
618  flag = box2df_left(key, &query_gbox_index);
619  break;
620 
621  case RTOverLeftStrategyNumber:
622  flag = box2df_overleft(key, &query_gbox_index);
623  break;
624 
625  case RTRightStrategyNumber:
626  flag = box2df_right(key, &query_gbox_index);
627  break;
628 
629  case RTOverRightStrategyNumber:
630  flag = box2df_overright(key, &query_gbox_index);
631  break;
632 
633  case RTAboveStrategyNumber:
634  flag = box2df_above(key, &query_gbox_index);
635  break;
636 
637  case RTOverAboveStrategyNumber:
638  flag = box2df_overabove(key, &query_gbox_index);
639  break;
640 
641  case RTBelowStrategyNumber:
642  flag = box2df_below(key, &query_gbox_index);
643  break;
644 
645  case RTOverBelowStrategyNumber:
646  flag = box2df_overbelow(key, &query_gbox_index);
647  break;
648 
649  default:
650  elog(ERROR, "unrecognized strategy: %d", strategy);
651  }
652 
653  /* If any check is failed, we have found our answer. */
654  if (!flag)
655  break;
656  }
657 
658  PG_RETURN_BOOL(flag);
659 }
bool box2df_left(const BOX2DF *a, const BOX2DF *b)
bool box2df_equals(const BOX2DF *a, const BOX2DF *b)
bool box2df_contains(const BOX2DF *a, const BOX2DF *b)
bool box2df_right(const BOX2DF *a, const BOX2DF *b)
bool box2df_overlaps(const BOX2DF *a, const BOX2DF *b)
bool box2df_above(const BOX2DF *a, const BOX2DF *b)
bool box2df_overbelow(const BOX2DF *a, const BOX2DF *b)
bool box2df_overright(const BOX2DF *a, const BOX2DF *b)
int gserialized_datum_get_box2df_p(Datum gsdatum, BOX2DF *box2df)
Peak into a GSERIALIZED datum to find the bounding box.
bool box2df_overabove(const BOX2DF *a, const BOX2DF *b)
bool box2df_below(const BOX2DF *a, const BOX2DF *b)
bool box2df_overleft(const BOX2DF *a, const BOX2DF *b)
#define LW_FAILURE
Definition: liblwgeom.h:79

References box2df_above(), box2df_below(), box2df_contains(), box2df_equals(), box2df_left(), box2df_overabove(), box2df_overbelow(), box2df_overlaps(), box2df_overleft(), box2df_overright(), box2df_right(), gserialized_datum_get_box2df_p(), and LW_FAILURE.

Here is the call graph for this function: