PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ gserialized_spgist_compress_2d()

PGDLLEXPORT Datum gserialized_spgist_compress_2d ( PG_FUNCTION_ARGS  )

Definition at line 665 of file gserialized_spgist_2d.c.

666 {
667  Datum gsdatum = PG_GETARG_DATUM(0);
668  BOX2DF *bbox_out = palloc(sizeof(BOX2DF));
669  int result = LW_SUCCESS;
670 
671  POSTGIS_DEBUG(4, "[SPGIST] 'compress' function called");
672 
673  /* Extract the index key from the argument. */
674  result = gserialized_datum_get_box2df_p(gsdatum, bbox_out);
675 
676  /* Is the bounding box valid (non-empty, non-infinite)? If not, return input uncompressed. */
677  if (result == LW_FAILURE)
678  {
679  box2df_set_empty(bbox_out);
680 
681  POSTGIS_DEBUG(4, "[SPGIST] empty geometry!");
682  PG_RETURN_POINTER(bbox_out);
683  }
684 
685  /* Check all the dimensions for finite values */
686  if ((!isfinite(bbox_out->xmax) || !isfinite(bbox_out->xmin)) ||
687  (!isfinite(bbox_out->ymax) || !isfinite(bbox_out->ymin)))
688  {
689  box2df_set_finite(bbox_out);
690 
691  POSTGIS_DEBUG(4, "[SPGIST] infinite geometry!");
692  PG_RETURN_POINTER(bbox_out);
693  }
694 
695  /* Ensure bounding box has minimums below maximums. */
696  box2df_validate(bbox_out);
697 
698  /* Return BOX2DF. */
699  POSTGIS_DEBUG(4, "[SPGIST] 'compress' function complete");
700  PG_RETURN_POINTER(bbox_out);
701 }
void box2df_set_empty(BOX2DF *a)
void box2df_set_finite(BOX2DF *a)
int gserialized_datum_get_box2df_p(Datum gsdatum, BOX2DF *box2df)
Peak into a GSERIALIZED datum to find the bounding box.
void box2df_validate(BOX2DF *b)
#define LW_FAILURE
Definition: liblwgeom.h:110
#define LW_SUCCESS
Definition: liblwgeom.h:111

References box2df_set_empty(), box2df_set_finite(), box2df_validate(), gserialized_datum_get_box2df_p(), LW_FAILURE, and LW_SUCCESS.

Here is the call graph for this function: