]> 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 18:01:43 +0000 (18:01 +0000)
committerRegina Obe <lr@pcorp.us>
Mon, 24 Apr 2017 18:01:43 +0000 (18:01 +0000)
References #3744
changed area regress to cast to numeric so doesn't return scientific notation on windows

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

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

index 4d45ce0b5eecc1b5f804151e229b082b57fe7a2a..bb5385a594a4e40a39d20549cf74d356853fefb0 100644 (file)
@@ -1979,11 +1979,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;
        }
        
@@ -2030,15 +2030,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