]> granicus.if.org Git - postgis/commitdiff
#3159, only add boxes to geometries that are input with them
authorPaul Ramsey <pramsey@cleverelephant.ca>
Thu, 11 Jun 2015 19:20:42 +0000 (19:20 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Thu, 11 Jun 2015 19:20:42 +0000 (19:20 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@13656 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/lwgeom.c
liblwgeom/lwline.c
liblwgeom/lwlinearreferencing.c
postgis/geography_inout.c
postgis/lwgeom_functions_basic.c

index 44ca7798c608fda7dd485a3abb85971752f1bedb..a9bb312d8932ecb8f71335ee81f51fdaec66c806 100644 (file)
@@ -1524,7 +1524,7 @@ void lwgeom_swap_ordinates(LWGEOM *in, LWORD o1, LWORD o2)
        }
 
   /* only refresh bbox if X or Y changed */
-  if ( o1 < 2 || o2 < 2 ) {
+  if ( in->bbox && (o1 < 2 || o2 < 2) ) {
     lwgeom_drop_bbox(in);
     lwgeom_add_bbox(in);
   }
index 620ce820248b3e2c3200f6b3a056dd24c028188e..b787eedca3c393b5573b7e6f03338568879639b3 100644 (file)
@@ -319,8 +319,11 @@ lwline_add_lwpoint(LWLINE *line, LWPOINT *point, int where)
                return LW_FAILURE;
 
        /* Update the bounding box */
-       lwgeom_drop_bbox(lwline_as_lwgeom(line));
-       lwgeom_add_bbox(lwline_as_lwgeom(line));
+       if ( line->bbox )
+       {
+               lwgeom_drop_bbox(lwline_as_lwgeom(line));
+               lwgeom_add_bbox(lwline_as_lwgeom(line));
+       }
        
        return LW_SUCCESS;
 }
index 29bf0a9c3c14c3e179ad81bd649a0e1473ca2c40..ca4ce2f3deff6d644633104a829a59155e7580e5 100644 (file)
@@ -382,9 +382,12 @@ lwpoint_clip_to_ordinate_range(const LWPOINT *point, char ordinate, double from,
                lwcollection_add_lwgeom(lwgeom_out, lwpoint_as_lwgeom(lwp));
        }
        
-       /* Set the bbox */
-       lwgeom_drop_bbox((LWGEOM*)lwgeom_out);
-       lwgeom_add_bbox((LWGEOM*)lwgeom_out);
+       /* Set the bbox, if necessary */
+       if ( lwgeom_out->bbox )
+       {
+               lwgeom_drop_bbox((LWGEOM*)lwgeom_out);
+               lwgeom_add_bbox((LWGEOM*)lwgeom_out);
+       }
 
        return lwgeom_out;
 }
@@ -436,9 +439,12 @@ lwmpoint_clip_to_ordinate_range(const LWMPOINT *mpoint, char ordinate, double fr
                }
        }
        
-       /* Set the bbox */
-       lwgeom_drop_bbox((LWGEOM*)lwgeom_out);
-       lwgeom_add_bbox((LWGEOM*)lwgeom_out);
+       /* Set the bbox, if necessary */
+       if ( lwgeom_out->bbox )
+       {
+               lwgeom_drop_bbox((LWGEOM*)lwgeom_out);
+               lwgeom_add_bbox((LWGEOM*)lwgeom_out);
+       }
 
        return lwgeom_out;
 }
@@ -505,8 +511,12 @@ lwmline_clip_to_ordinate_range(const LWMLINE *mline, char ordinate, double from,
                                lwfree(col);
                        }
                }
-               lwgeom_drop_bbox((LWGEOM*)lwgeom_out);
-               lwgeom_add_bbox((LWGEOM*)lwgeom_out);
+               if ( lwgeom_out->bbox )
+               {
+                       lwgeom_drop_bbox((LWGEOM*)lwgeom_out);
+                       lwgeom_add_bbox((LWGEOM*)lwgeom_out);
+               }
+               
                if ( ! homogeneous )
                {
                        lwgeom_out->type = COLLECTIONTYPE;
@@ -740,7 +750,7 @@ lwline_clip_to_ordinate_range(const LWLINE *line, char ordinate, double from, do
        lwfree(q);
        lwfree(r);
 
-       if ( lwgeom_out->ngeoms > 0 )
+       if ( lwgeom_out->bbox && lwgeom_out->ngeoms > 0 )
        {
                lwgeom_drop_bbox((LWGEOM*)lwgeom_out);
                lwgeom_add_bbox((LWGEOM*)lwgeom_out);
index e615327c526b4b4e107022911d6bf8a316e3f3ae..c80662603bfc8bbe7ccd1aa3b9ac5cc0ce0ad93f 100644 (file)
@@ -597,9 +597,11 @@ Datum geography_from_geometry(PG_FUNCTION_ARGS)
        ** functions do the right thing.
        */
        lwgeom_set_geodetic(lwgeom, true);
+       
        /* Recalculate the boxes after re-setting the geodetic bit */
        lwgeom_drop_bbox(lwgeom);
        lwgeom_add_bbox(lwgeom);
+       
        g_ser = geography_serialize(lwgeom);
 
        /*
index dffd39ca8cf5ee320865599e8619784e6d61c955..45884790c9e43fe4d0d54ddda4ebcef9d595adca 100644 (file)
@@ -2536,8 +2536,11 @@ Datum LWGEOM_affine(PG_FUNCTION_ARGS)
        lwgeom_affine(lwgeom, &affine);
 
        /* COMPUTE_BBOX TAINTING */
-       lwgeom_drop_bbox(lwgeom);
-       lwgeom_add_bbox(lwgeom);
+       if ( lwgeom->bbox )
+       {
+               lwgeom_drop_bbox(lwgeom);
+               lwgeom_add_bbox(lwgeom);
+       }
        ret = geometry_serialize(lwgeom);
 
        /* Release memory */