844{
845 GISTENTRY *entry_in = (GISTENTRY*)PG_GETARG_POINTER(0);
846 GISTENTRY *entry_out = NULL;
847 BOX2DF bbox_out;
849
850 POSTGIS_DEBUG(4, "[GIST] 'compress' function called");
851
852
853
854
855
856 if ( ! entry_in->leafkey )
857 {
858 POSTGIS_DEBUG(4, "[GIST] non-leafkey entry, returning input unaltered");
859 PG_RETURN_POINTER(entry_in);
860 }
861
862 POSTGIS_DEBUG(4, "[GIST] processing leafkey input");
863 entry_out = palloc(sizeof(GISTENTRY));
864
865
866
867
868
869 if ( DatumGetPointer(entry_in->key) == NULL )
870 {
871 POSTGIS_DEBUG(4, "[GIST] leafkey is null");
872 gistentryinit(*entry_out, (Datum) 0, entry_in->rel,
873 entry_in->page, entry_in->offset, false);
874 POSTGIS_DEBUG(4, "[GIST] returning copy of input");
875 PG_RETURN_POINTER(entry_out);
876 }
877
878
880
882 {
883
884 POSTGIS_DEBUG(4, "[GIST] leafkey is null");
885 gistentryinit(*entry_out, (Datum) 0, entry_in->rel,
886 entry_in->page, entry_in->offset, false);
887 POSTGIS_DEBUG(4, "[GIST] returning copy of input");
888 PG_RETURN_POINTER(entry_out);
889 }
890
891
893 {
894 gistentryinit(*entry_out, PointerGetDatum(
box2df_copy(&bbox_out)),
895 entry_in->rel, entry_in->page, entry_in->offset, false);
896
897 POSTGIS_DEBUG(4, "[GIST] empty geometry!");
898 PG_RETURN_POINTER(entry_out);
899 }
900
901 POSTGIS_DEBUGF(4,
"[GIST] got entry_in->key: %s",
box2df_to_string(&bbox_out));
902
903
904 if ( ! isfinite(bbox_out.xmax) || ! isfinite(bbox_out.xmin) ||
905 ! isfinite(bbox_out.ymax) || ! isfinite(bbox_out.ymin) )
906 {
908 gistentryinit(*entry_out, PointerGetDatum(
box2df_copy(&bbox_out)),
909 entry_in->rel, entry_in->page, entry_in->offset, false);
910
911 POSTGIS_DEBUG(4, "[GIST] infinite geometry!");
912 PG_RETURN_POINTER(entry_out);
913 }
914
915
917
918
919 gistentryinit(*entry_out, PointerGetDatum(
box2df_copy(&bbox_out)),
920 entry_in->rel, entry_in->page, entry_in->offset, false);
921
922
923 POSTGIS_DEBUG(4, "[GIST] 'compress' function complete");
924 PG_RETURN_POINTER(entry_out);
925}
char result[OUT_DOUBLE_BUFFER_SIZE]
static char * box2df_to_string(const BOX2DF *a)
bool box2df_is_empty(const BOX2DF *a)
void box2df_set_finite(BOX2DF *a)
int gserialized_datum_get_box2df_p(Datum gsdatum, BOX2DF *box2df)
BOX2DF * box2df_copy(BOX2DF *b)
void box2df_validate(BOX2DF *b)