]> granicus.if.org Git - postgis/commitdiff
Fix ST_Envelope() and ST_Expand() so that they use double precision arithmetic rather...
authorMark Cave-Ayland <mark.cave-ayland@siriusit.co.uk>
Wed, 30 Dec 2009 14:52:52 +0000 (14:52 +0000)
committerMark Cave-Ayland <mark.cave-ayland@siriusit.co.uk>
Wed, 30 Dec 2009 14:52:52 +0000 (14:52 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@5080 b70326c6-7e19-0410-871a-916f4a2858ee

postgis/lwgeom_functions_basic.c
regress/sql-mm-circularstring_expected
regress/sql-mm-compoundcurve_expected
regress/tickets_expected

index 29e7a3d31a37c2ebb75293514dc87db8b9729c0c..6a75d67529dd4f6ab218c6896cf8476e5c032ea6 100644 (file)
@@ -2536,7 +2536,7 @@ Datum LWGEOM_expand(PG_FUNCTION_ARGS)
 {
        PG_LWGEOM *geom = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
        double d = PG_GETARG_FLOAT8(1);
-       BOX2DFLOAT4 box;
+       BOX3D box3d;
        POINT2D *pts = lwalloc(sizeof(POINT2D)*5);
        POINTARRAY *pa[1];
        LWPOLY *poly;
@@ -2546,7 +2546,7 @@ Datum LWGEOM_expand(PG_FUNCTION_ARGS)
        POSTGIS_DEBUG(2, "LWGEOM_expand called.");
 
        /* get geometry box  */
-       if ( ! getbox2d_p(SERIALIZED_FORM(geom), &box) )
+       if ( ! compute_serialized_box3d_p(SERIALIZED_FORM(geom), &box3d) )
        {
                /* must be an EMPTY geometry */
                PG_RETURN_POINTER(geom);
@@ -2556,19 +2556,19 @@ Datum LWGEOM_expand(PG_FUNCTION_ARGS)
        SRID = lwgeom_getsrid(SERIALIZED_FORM(geom));
 
        /* expand it */
-       expand_box2d(&box, d);
+       expand_box3d(&box3d, d);
 
        /* Assign coordinates to POINT2D array */
-       pts[0].x = box.xmin;
-       pts[0].y = box.ymin;
-       pts[1].x = box.xmin;
-       pts[1].y = box.ymax;
-       pts[2].x = box.xmax;
-       pts[2].y = box.ymax;
-       pts[3].x = box.xmax;
-       pts[3].y = box.ymin;
-       pts[4].x = box.xmin;
-       pts[4].y = box.ymin;
+       pts[0].x = box3d.xmin;
+       pts[0].y = box3d.ymin;
+       pts[1].x = box3d.xmin;
+       pts[1].y = box3d.ymax;
+       pts[2].x = box3d.xmax;
+       pts[2].y = box3d.ymax;
+       pts[3].x = box3d.xmax;
+       pts[3].y = box3d.ymin;
+       pts[4].x = box3d.xmin;
+       pts[4].y = box3d.ymin;
 
        /* Construct point array */
        pa[0] = lwalloc(sizeof(POINTARRAY));
@@ -2577,7 +2577,7 @@ Datum LWGEOM_expand(PG_FUNCTION_ARGS)
        pa[0]->npoints = 5;
 
        /* Construct polygon  */
-       poly = lwpoly_construct(SRID, box2d_clone(&box), 1, pa);
+       poly = lwpoly_construct(SRID, ptarray_compute_box2d(pa[0]), 1, pa);
 
        /* Construct PG_LWGEOM  */
        result = pglwgeom_serialize((LWGEOM *)poly);
@@ -2676,26 +2676,24 @@ Datum LWGEOM_envelope(PG_FUNCTION_ARGS)
        {
                LWPOLY *poly;
                POINT2D *pts = lwalloc(sizeof(POINT2D)*5);
-               BOX2DFLOAT4 box2d;
-               getbox2d_p(SERIALIZED_FORM(geom), &box2d);
 
                /* Assign coordinates to POINT2D array */
-               pts[0].x = box2d.xmin;
-               pts[0].y = box2d.ymin;
-               pts[1].x = box2d.xmin;
-               pts[1].y = box2d.ymax;
-               pts[2].x = box2d.xmax;
-               pts[2].y = box2d.ymax;
-               pts[3].x = box2d.xmax;
-               pts[3].y = box2d.ymin;
-               pts[4].x = box2d.xmin;
-               pts[4].y = box2d.ymin;
+               pts[0].x = box.xmin;
+               pts[0].y = box.ymin;
+               pts[1].x = box.xmin;
+               pts[1].y = box.ymax;
+               pts[2].x = box.xmax;
+               pts[2].y = box.ymax;
+               pts[3].x = box.xmax;
+               pts[3].y = box.ymin;
+               pts[4].x = box.xmin;
+               pts[4].y = box.ymin;
 
                /* Construct point array */
                pa = pointArray_construct((uchar *)pts, 0, 0, 5);
 
                /* Construct polygon  */
-               poly = lwpoly_construct(SRID, box2d_clone(&box2d), 1, &pa);
+               poly = lwpoly_construct(SRID, ptarray_compute_box2d(pa), 1, &pa);
 
                /* Serialize polygon */
                ser = lwpoly_serialize(poly);
index 2ba6cca744df0ca6b2f9c08a4f262c981082a582..6c45ea683aad8da81826f007b38b519f76fd70e1 100644 (file)
@@ -94,13 +94,13 @@ ERROR:  Exception in LWGEOM2GEOS: curved geometry not supported.
 ERROR:  Exception in LWGEOM2GEOS: curved geometry not supported.
 ERROR:  Exception in LWGEOM2GEOS: curved geometry not supported.
 ERROR:  Exception in LWGEOM2GEOS: curved geometry not supported.
-envelope01|POLYGON((0 0,0 1.41421366,0.58578646 1.41421366,0.58578646 0,0 0))
+envelope01|POLYGON((0 0,0 1.41421356,0.58578644 1.41421356,0.58578644 0,0 0))
 envelope01|POLYGON((-5 0,-5 5,15 5,15 0,-5 0))
-envelope02|POLYGON((0 0,0 1.41421366,0.58578646 1.41421366,0.58578646 0,0 0))
+envelope02|POLYGON((0 0,0 1.41421356,0.58578644 1.41421356,0.58578644 0,0 0))
 envelope02|POLYGON((-5 0,-5 5,15 5,15 0,-5 0))
-envelope03|POLYGON((0 0,0 1.41421366,0.58578646 1.41421366,0.58578646 0,0 0))
+envelope03|POLYGON((0 0,0 1.41421356,0.58578644 1.41421356,0.58578644 0,0 0))
 envelope03|POLYGON((-5 0,-5 5,15 5,15 0,-5 0))
-envelope04|POLYGON((0 0,0 1.41421366,0.58578646 1.41421366,0.58578646 0,0 0))
+envelope04|POLYGON((0 0,0 1.41421356,0.58578644 1.41421356,0.58578644 0,0 0))
 envelope04|POLYGON((-5 0,-5 5,15 5,15 0,-5 0))
 astext01|CIRCULARSTRING(0 0,0.267949192431123 1,0.585786437626905 1.4142135623731)
 astext01|CIRCULARSTRING(-5 0,0 5,5 0,10 -5,15 0)
@@ -142,13 +142,13 @@ ERROR:  Exception in LWGEOM2GEOS: curved geometry not supported.
 ERROR:  Exception in LWGEOM2GEOS: curved geometry not supported.
 ERROR:  Exception in LWGEOM2GEOS: curved geometry not supported.
 ERROR:  Exception in LWGEOM2GEOS: curved geometry not supported.
-envelope01|POLYGON((0 0,0 1.41421366,0.58578646 1.41421366,0.58578646 0,0 0))
+envelope01|POLYGON((0 0,0 1.41421356,0.58578644 1.41421356,0.58578644 0,0 0))
 envelope01|POLYGON((-5 0,-5 5,15 5,15 0,-5 0))
-envelope02|POLYGON((0 0,0 1.41421366,0.58578646 1.41421366,0.58578646 0,0 0))
+envelope02|POLYGON((0 0,0 1.41421356,0.58578644 1.41421356,0.58578644 0,0 0))
 envelope02|POLYGON((-5 0,-5 5,15 5,15 0,-5 0))
-envelope03|POLYGON((0 0,0 1.41421366,0.58578646 1.41421366,0.58578646 0,0 0))
+envelope03|POLYGON((0 0,0 1.41421356,0.58578644 1.41421356,0.58578644 0,0 0))
 envelope03|POLYGON((-5 0,-5 5,15 5,15 0,-5 0))
-envelope04|POLYGON((0 0,0 1.41421366,0.58578646 1.41421366,0.58578646 0,0 0))
+envelope04|POLYGON((0 0,0 1.41421356,0.58578644 1.41421356,0.58578644 0,0 0))
 envelope04|POLYGON((-5 0,-5 5,15 5,15 0,-5 0))
 public.circularstring.the_geom_4d effectively removed.
 public.circularstring.the_geom_3dz effectively removed.
index da5b6b24d055bca1fb16f4d90c26eb6e0d7e49bb..e935b8f1f0896a6181368378cdc825246447042a 100644 (file)
@@ -54,10 +54,10 @@ ERROR:  Exception in LWGEOM2GEOS: curved geometry not supported.
 ERROR:  Exception in LWGEOM2GEOS: curved geometry not supported.
 ERROR:  Exception in LWGEOM2GEOS: curved geometry not supported.
 ERROR:  Exception in LWGEOM2GEOS: curved geometry not supported.
-envelope01|POLYGON((0 0,0 1.41421366,2 1.41421366,2 0,0 0))
-envelope02|POLYGON((0 0,0 1.41421366,2 1.41421366,2 0,0 0))
-envelope03|POLYGON((0 0,0 1.41421366,2 1.41421366,2 0,0 0))
-envelope04|POLYGON((0 0,0 1.41421366,2 1.41421366,2 0,0 0))
+envelope01|POLYGON((0 0,0 1.41421356,2 1.41421356,2 0,0 0))
+envelope02|POLYGON((0 0,0 1.41421356,2 1.41421356,2 0,0 0))
+envelope03|POLYGON((0 0,0 1.41421356,2 1.41421356,2 0,0 0))
+envelope04|POLYGON((0 0,0 1.41421356,2 1.41421356,2 0,0 0))
 astext01|COMPOUNDCURVE(CIRCULARSTRING(0 0,0.267949192431123 1,0.585786437626905 1.4142135623731),(0.585786437626905 1.4142135623731,2 0,0 0))
 astext02|COMPOUNDCURVE(CIRCULARSTRING(0 0,0.267949192431123 1,0.585786437626905 1.4142135623731),(0.585786437626905 1.4142135623731,2 0,0 0))
 astext03|COMPOUNDCURVE(CIRCULARSTRING(0 0,0.267949192431123 1,0.585786437626905 1.4142135623731),(0.585786437626905 1.4142135623731,2 0,0 0))
@@ -82,10 +82,10 @@ ERROR:  Exception in LWGEOM2GEOS: curved geometry not supported.
 ERROR:  Exception in LWGEOM2GEOS: curved geometry not supported.
 ERROR:  Exception in LWGEOM2GEOS: curved geometry not supported.
 ERROR:  Exception in LWGEOM2GEOS: curved geometry not supported.
-envelope01|POLYGON((0 0,0 1.41421366,2 1.41421366,2 0,0 0))
-envelope02|POLYGON((0 0,0 1.41421366,2 1.41421366,2 0,0 0))
-envelope03|POLYGON((0 0,0 1.41421366,2 1.41421366,2 0,0 0))
-envelope04|POLYGON((0 0,0 1.41421366,2 1.41421366,2 0,0 0))
+envelope01|POLYGON((0 0,0 1.41421356,2 1.41421356,2 0,0 0))
+envelope02|POLYGON((0 0,0 1.41421356,2 1.41421356,2 0,0 0))
+envelope03|POLYGON((0 0,0 1.41421356,2 1.41421356,2 0,0 0))
+envelope04|POLYGON((0 0,0 1.41421356,2 1.41421356,2 0,0 0))
 public.compoundcurve.the_geom_4d effectively removed.
 public.compoundcurve.the_geom_3dz effectively removed.
 public.compoundcurve.the_geom_3dm effectively removed.
index 574d385530424156fc57f5e3d3e09bb267dc8f43..69fceb56665a536ef41b7188deab2bbfa9443cd8 100644 (file)
@@ -4,7 +4,7 @@
 t
 ERROR:  AddGeometryColumns() - invalid SRID
 #44|t|t
-#58|POLYGON((220187.375 150406.421875,220187.375 150506.71875,220288.828125 150506.71875,220288.828125 150406.421875,220187.375 150406.421875))
+#58|POLYGON((220187.382089758 150406.434743975,220187.382089758 150506.717070259,220288.81590723 150506.717070259,220288.81590723 150406.434743975,220187.382089758 150406.434743975))
 ERROR:  geometry_to_gml2: 'CurvePolygon' geometry type not supported
 #66|CIRCULARSTRING(0 0,1 1,2 2)
 #68a|MULTIPOINT(1 3,4 5)