]> granicus.if.org Git - postgis/commitdiff
Infinite coordinate geoms omitted from index
authorSandro Santilli <strk@keybit.net>
Thu, 3 Jun 2004 07:58:11 +0000 (07:58 +0000)
committerSandro Santilli <strk@keybit.net>
Thu, 3 Jun 2004 07:58:11 +0000 (07:58 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@570 b70326c6-7e19-0410-871a-916f4a2858ee

postgis_gist_72.c

index 6e0805127912b30fd8e855d7e7eaf5585114f456..7bc13da26c46a36d44c2a4ffc5eb6704091e275f 100644 (file)
@@ -11,6 +11,9 @@
  *
  **********************************************************************
  * $Log$
+ * Revision 1.15  2004/06/03 07:58:11  strk
+ * Infinite coordinate geoms omitted from index
+ *
  * Revision 1.14  2004/06/02 23:54:09  strk
  * Made equality checks the default in picksplit to catch also NaN results (INF geoms)
  *
@@ -139,6 +142,7 @@ Datum ggeometry_compress(PG_FUNCTION_ARGS)
 {
        GISTENTRY *entry=(GISTENTRY*)PG_GETARG_POINTER(0);
        GISTENTRY *retval;
+       double checkinf;
 
        if ( entry->leafkey)
        {
@@ -162,18 +166,24 @@ Datum ggeometry_compress(PG_FUNCTION_ARGS)
                                // dont bother adding this to the index
                                PG_RETURN_POINTER(entry);
                        }
-                       else
+
+                       checkinf = in->bvol.URT.x - in->bvol.URT.y -
+                               in->bvol.LLB.x - in->bvol.LLB.y;
+                       if ( isnan(checkinf) || checkinf == INFINITY ||
+                               checkinf == -INFINITY )
                        {
-                               r = convert_box3d_to_box(&in->bvol);
-                               if ( in != (GEOMETRY*)DatumGetPointer(entry->key) )
-                               {
-                                       pfree( in );
-                               }
+                               //elog(NOTICE, "found infinite geometry");
+                               PG_RETURN_POINTER(entry);
+                       }
 
-                               gistentryinit(*retval, PointerGetDatum(r), entry->rel, entry->page,
-                                       entry->offset, sizeof(BOX), FALSE);
+                       r = convert_box3d_to_box(&in->bvol);
+                       if ( in != (GEOMETRY*)DatumGetPointer(entry->key) )
+                       {
+                               pfree( in );
                        }
 
+                       gistentryinit(*retval, PointerGetDatum(r), entry->rel, entry->page, entry->offset, sizeof(BOX), FALSE);
+
                }
                else
                {
@@ -197,7 +207,7 @@ Datum ggeometry_consistent(PG_FUNCTION_ARGS)
     BOX                thebox;
        bool result;
 
-       /*
+   /*
     ** if entry is not leaf, use rtree_internal_consistent,
     ** else use rtree_leaf_consistent
     */
@@ -217,7 +227,7 @@ Datum ggeometry_consistent(PG_FUNCTION_ARGS)
        fflush( stdout );
 #endif
 
-    if ( ! (DatumGetPointer(entry->key) != NULL && query) )
+       if ( ! (DatumGetPointer(entry->key) != NULL && query) )
                PG_RETURN_BOOL(FALSE);
 
        convert_box3d_to_box_p( &(query->bvol) , &thebox);
@@ -469,6 +479,18 @@ gbox_picksplit(PG_FUNCTION_ARGS)
                        pageunion.low.y = cur->low.y;
        }
 
+       if (
+               pageunion.low.y == -INFINITY ||
+               pageunion.low.y == -INFINITY ||
+               pageunion.high.y == -INFINITY ||
+               pageunion.high.y == INFINITY ||
+               pageunion.low.x == -INFINITY ||
+               pageunion.low.x == -INFINITY ||
+               pageunion.high.x == -INFINITY ||
+               pageunion.high.x == INFINITY 
+       ) elog(NOTICE, "infinite pageunion");
+
+
        nbytes = (maxoff + 2) * sizeof(OffsetNumber);
        listL = (OffsetNumber *) palloc(nbytes);
        listR = (OffsetNumber *) palloc(nbytes);