]> granicus.if.org Git - postgis/commitdiff
Update the bbox when you alter the underlying geometry (#410) ST_SetPoint, ST_Ad
authorPaul Ramsey <pramsey@cleverelephant.ca>
Mon, 8 Mar 2010 23:28:28 +0000 (23:28 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Mon, 8 Mar 2010 23:28:28 +0000 (23:28 +0000)
dPoint, ST_RemovePoint.

git-svn-id: http://svn.osgeo.org/postgis/trunk@5384 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/lwline.c
postgis/lwgeom_functions_basic.c

index 790f9ba8cfa1f7eb147854503e5a216ffc041b80..95650aecf54cc6a584693874bc4f90dd107adebf 100644 (file)
@@ -497,8 +497,10 @@ lwline_addpoint(LWLINE *line, LWPOINT *point, unsigned int where)
        newpa = ptarray_addPoint(line->points,
                                 getPoint_internal(point->point, 0),
                                 TYPE_NDIMS(point->type), where);
+       
+       
 
-       ret = lwline_construct(line->SRID, NULL, newpa);
+       ret = lwline_construct(line->SRID, ptarray_compute_box2d(newpa), newpa);
 
        return ret;
 }
@@ -511,7 +513,7 @@ lwline_removepoint(LWLINE *line, unsigned int index)
 
        newpa = ptarray_removePoint(line->points, index);
 
-       ret = lwline_construct(line->SRID, NULL, newpa);
+       ret = lwline_construct(line->SRID, ptarray_compute_box2d(newpa), newpa);
 
        return ret;
 }
@@ -523,6 +525,12 @@ void
 lwline_setPoint4d(LWLINE *line, unsigned int index, POINT4D *newpoint)
 {
        setPoint4d(line->points, index, newpoint);
+       /* Update the box, if there is one to update */
+       if( line->bbox )
+       {
+               lwgeom_drop_bbox((LWGEOM*)line);
+               lwgeom_add_bbox((LWGEOM*)line);
+       }
 }
 
 /**
index 3724889506d06e49bf2ba8029b824a506a86f1b4..ac9102576d6ca7d75b8d41f263563a22ad6943e5 100644 (file)
@@ -3065,7 +3065,7 @@ Datum LWGEOM_addpoint(PG_FUNCTION_ARGS)
        line = lwline_deserialize(SERIALIZED_FORM(pglwg1));
 
        if ( where == -1 ) where = line->points->npoints;
-       else if ( (unsigned int)where > line->points->npoints )
+       else if ( where < 0 || where > line->points->npoints )
        {
                elog(ERROR, "Invalid offset");
                PG_RETURN_NULL();