]> granicus.if.org Git - postgis/commitdiff
ST_Subdivide loses subparts of inverted geometries patch from Darafei Praliaskouski...
authorRegina Obe <lr@pcorp.us>
Mon, 24 Apr 2017 20:42:05 +0000 (20:42 +0000)
committerRegina Obe <lr@pcorp.us>
Mon, 24 Apr 2017 20:42:05 +0000 (20:42 +0000)
Closes #3744 for PostGIS 2.3
changed area regress to cast to numeric so doesn't return scientific notation on windows

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

NEWS
liblwgeom/lwgeom.c
regress/subdivide.sql
regress/subdivide_expected

diff --git a/NEWS b/NEWS
index 91f086ff5cf38dd074766900d42ba64c4793ad13..549fdea5a286bac3df12a5955498348cb231e1f5 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,8 @@ YYYY/MM/DD
   - #3711, Azimuth error upon adding 2.5D edges to topology
   - #3738, raster: Using -s without -Y in raster2pgsql transforms 
            raster data instead of setting srid
+  - #3744, ST_Subdivide loses subparts of inverted geometries
+           (Darafei Praliaskouski Komzpa)
 
 PostGIS 2.3.2
 2017/01/31
index 769d00193b63c5aa27938b5e9e0e3fea8ae01e2a..54e053b42a69bd768c209370d84cb4af522852ba 100644 (file)
@@ -1950,11 +1950,11 @@ lwgeom_subdivide_recursive(const LWGEOM *geom, int maxvertices, int depth, LWCOL
                return n;
        }
        
-       /* But don't go too far. 2^25 = 33M, that's enough subdivision */
-       /* Signal callers above that we depth'ed out with a negative */
-       /* return value */
+       /* But don't go too far. 2^50 ~= 10^15, that's enough subdivision */
+       /* Just add what's left */
        if ( depth > maxdepth )
        {
+               lwcollection_add_lwgeom(col, lwgeom_clone_deep(geom));
                return 0;
        }
        
@@ -2001,15 +2001,17 @@ lwgeom_subdivide_recursive(const LWGEOM *geom, int maxvertices, int depth, LWCOL
        clipped1 = lwgeom_clip_by_rect(geom, subbox1.xmin, subbox1.ymin, subbox1.xmax, subbox1.ymax);
        clipped2 = lwgeom_clip_by_rect(geom, subbox2.xmin, subbox2.ymin, subbox2.xmax, subbox2.ymax);
        
+       ++depth;
+       
        if ( clipped1 )
        {
-               n += lwgeom_subdivide_recursive(clipped1, maxvertices, ++depth, col, &subbox1);
+               n += lwgeom_subdivide_recursive(clipped1, maxvertices, depth, col, &subbox1);
                lwgeom_free(clipped1);
        }
 
        if ( clipped2 )
        {
-               n += lwgeom_subdivide_recursive(clipped2, maxvertices, ++depth, col, &subbox2);
+               n += lwgeom_subdivide_recursive(clipped2, maxvertices, depth, col, &subbox2);
                lwgeom_free(clipped2);
        }
        
index 30c941ed44899a8660ec009c93c6d72b485b2e55..02d1d64a29c555a0ff62728be605c9247212420f 100644 (file)
@@ -24,3 +24,20 @@ FROM gs
 GROUP BY gs.full_area;
 
 SELECT '#3522', ST_AsText(ST_Subdivide(ST_GeomFromText('POINT(1 1)',4326),10));
+
+
+with inverted_geom as (
+    select ST_Difference(
+               ST_Expand('SRID=3857;POINT(0 0)' :: geometry, 20000000),
+               ST_Buffer(
+                   'SRID=3857;POINT(0 0)' :: geometry,
+                   1,
+                   1000
+               )
+           ) as geom
+)
+select 'https://github.com/postgis/postgis/pull/127', ST_Area(ST_Simplify(ST_Union(geom), 2))::numeric
+from (
+         select ST_Subdivide(geom) geom
+         from inverted_geom
+     ) z;
index 43e89ec4309e96a6c514c61c8e0eaf5e94071b71..c8307a66093e5ac3800e1ff5927b49a0fec20881 100644 (file)
@@ -2,3 +2,4 @@
 2|t|6|7
 3|t|15|9
 #3522|POINT(1 1)
+https://github.com/postgis/postgis/pull/127|1600000000000000