From: Regina Obe Date: Mon, 24 Apr 2017 18:01:43 +0000 (+0000) Subject: ST_Subdivide loses subparts of inverted geometries patch from Darafei Praliaskouski... X-Git-Tag: 2.4.0alpha~126 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a532f2d3cba181ed571e02754fd0e080beaafa7a;p=postgis ST_Subdivide loses subparts of inverted geometries patch from Darafei Praliaskouski (Komzpa) 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 --- diff --git a/liblwgeom/lwgeom.c b/liblwgeom/lwgeom.c index 4d45ce0b5..bb5385a59 100644 --- a/liblwgeom/lwgeom.c +++ b/liblwgeom/lwgeom.c @@ -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); } diff --git a/regress/subdivide.sql b/regress/subdivide.sql index 30c941ed4..02d1d64a2 100644 --- a/regress/subdivide.sql +++ b/regress/subdivide.sql @@ -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; diff --git a/regress/subdivide_expected b/regress/subdivide_expected index 43e89ec43..c8307a660 100644 --- a/regress/subdivide_expected +++ b/regress/subdivide_expected @@ -2,3 +2,4 @@ 2|t|6|7 3|t|15|9 #3522|POINT(1 1) +https://github.com/postgis/postgis/pull/127|1600000000000000