From abbcae8432ebcfd280927610a05ebe8ed8e9a693 Mon Sep 17 00:00:00 2001 From: AJ Ashton Date: Thu, 25 May 2017 18:45:27 -0400 Subject: [PATCH] Sieve: avoid feeding non-polygons into ST_DumpRings --- postgis-vt-util.sql | 4 ++-- src/Sieve.sql | 4 ++-- test/sql-test.sh | 7 +++++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/postgis-vt-util.sql b/postgis-vt-util.sql index 32c37a5..d9291de 100644 --- a/postgis-vt-util.sql +++ b/postgis-vt-util.sql @@ -439,7 +439,7 @@ $func$ with exploded as ( -- First use ST_Dump to explode the input multipolygon -- to individual polygons. - select (ST_Dump(g)).geom + select (ST_Dump(ST_CollectionExtract(g, 3))).geom ), rings as ( -- Next use ST_DumpRings to turn all of the inner and outer rings -- into their own separate polygons. @@ -459,7 +459,7 @@ $func$ with exploded as ( -- First use ST_Dump to explode the input multipolygon -- to individual polygons. - select (ST_Dump(g)).geom + select (ST_Dump(ST_CollectionExtract(g, 3))).geom ), rings as ( -- Next use ST_DumpRings to turn all of the inner and outer rings -- into their own separate polygons. diff --git a/src/Sieve.sql b/src/Sieve.sql index d32cc21..4379902 100644 --- a/src/Sieve.sql +++ b/src/Sieve.sql @@ -17,7 +17,7 @@ $func$ with exploded as ( -- First use ST_Dump to explode the input multipolygon -- to individual polygons. - select (ST_Dump(g)).geom + select (ST_Dump(ST_CollectionExtract(g, 3))).geom ), rings as ( -- Next use ST_DumpRings to turn all of the inner and outer rings -- into their own separate polygons. @@ -37,7 +37,7 @@ $func$ with exploded as ( -- First use ST_Dump to explode the input multipolygon -- to individual polygons. - select (ST_Dump(g)).geom + select (ST_Dump(ST_CollectionExtract(g, 3))).geom ), rings as ( -- Next use ST_DumpRings to turn all of the inner and outer rings -- into their own separate polygons. diff --git a/test/sql-test.sh b/test/sql-test.sh index 1f885e5..b2c2acc 100755 --- a/test/sql-test.sh +++ b/test/sql-test.sh @@ -105,6 +105,13 @@ tf ST_AsText "Sieve(ST_GeomFromText('MULTIPOLYGON(\ ((200 200,200 202,202 202,202 200,200 200)),\ ((300 300,300 350,350 350,350 300,300 300)))'),10)" \ "MULTIPOLYGON(((0 0,0 100,100 100,100 0,0 0),(50 50,60 50,60 60,50 60,50 50)),((300 300,300 350,350 350,350 300,300 300)))" +tf ST_AsText "Sieve(ST_GeomFromText('GEOMETRYCOLLECTION(\ + LINESTRING(-10 -10, -10 -100),\ + MULTIPOLYGON(\ + ((0 0,0 100,100 100,100 0,0 0),(10 10,12 10,12 12,10 12,10 10),(50 50,60 50,60 60,50 60,50 50)),\ + ((200 200,200 202,202 202,202 200,200 200)),\ + ((300 300,300 350,350 350,350 300,300 300))))'),10)" \ + "MULTIPOLYGON(((0 0,0 100,100 100,100 0,0 0),(50 50,60 50,60 60,50 60,50 50)),((300 300,300 350,350 350,350 300,300 300)))" # SmartShrink tf floor "ST_Area(SmartShrink(ST_Buffer(ST_MakePoint(0,0),5000),0.5,true))" \