PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ gserialized_spgist_compress_2d()

PGDLLEXPORT Datum gserialized_spgist_compress_2d ( PG_FUNCTION_ARGS  )

Definition at line 663 of file gserialized_spgist_2d.c.

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

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: