[postgis-tickets] [PostGIS] #2307: ST_MakeValid outputs invalid geometries
PostGIS
trac at osgeo.org
Tue May 7 15:19:19 PDT 2013
#2307: ST_MakeValid outputs invalid geometries
--------------------------+-------------------------------------------------
Reporter: dmiranda | Owner: pramsey
Type: defect | Status: new
Priority: high | Milestone: PostGIS 2.0.4
Component: postgis | Version: 2.0.x
Keywords: st_makevalid |
--------------------------+-------------------------------------------------
Calling ST_MakeValid on certain geometries outputs garbage.
The resulting geometries are invalid, and their bounding boxes go all the
way to the lat,long=(0,0) (the "made valid" polygons are thousands of
kilometers larger than the original geometries).
I believe this issue to be of high priority because the behaviour is
unexpected and in most cases there are no warnings to be seen. In my
particular case, this issue prevents the use of ST_MakeValid altogether.
**** Test environment ****
Postgresql 9.2.4 with Postgis 2.0.3 on Ubuntu 12.04.2
SELECT version() -> "PostgreSQL 9.2.4 on x86_64-unknown-linux-gnu,
compiled by gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3, 64-bit"
SELECT postgis_full_version() -> "POSTGIS="2.0.3 r11128"
GEOS="3.3.8-CAPI-1.7.8" PROJ="Rel. 4.8.0, 6 March 2012" GDAL="GDAL 1.9.2,
released 2012/10/08" LIBXML="2.8.0" RASTER"
**** How to reproduce ****
-- sample data:
CREATE TABLE test (gid serial NOT NULL, geom Geometry);
INSERT INTO test (geom) values
('0106000020E6100000010000000103000000010000000
A0000004B7DA956B99844C0DB0790FE8B4D1DC010BA74A9AF9444C049AFFC5B8C4D1DC03FC6CC6
90D9844C0DD67E5628C4D1DC07117B56B0D9844C0C80ABA67C45E1DC0839166ABAF9444C0387D4
568C45E1DC010BA74A9AF9444C049AFFC5B8C4D1DC040C3CD74169444C0362EC0608C4D1DC07C1
A3B77169444C0DC3ADB40B2641DC03AAE5F68B99844C0242948DEB1641DC04B7DA956B99844C0D
B0790FE8B4D1DC0'::geometry);
-- The following outputs 'f':
SELECT ST_IsValid(geom) FROM test;
-- The following also outputs 'f', with no warnings:
SELECT ST_IsValid(ST_MakeValid(geom)) FROM test;
-- The following outputs "t", no warnings.
SELECT ST_IsValid(ST_MakeValid(ST_MakeValid(geom))) FROM test;
-- The following outputs very different bounding boxes:
SELECT Box2D(ST_MakeValid(ST_MakeValid(geom))), Box2D(geom) FROM test;
-- outputs "BOX(
-41.193158194274 -41.193158194274,
6.95325424073808e-310 6.95325424070132e-310)";
"BOX(-41.193158194274 -7.34833623254846,
-41.1569353108121 -7.32572934869855)"
**** additional information ****
I have not tested this with earlier versions of postgis nor with the
latest svn download.
I have also found out that Box2D() returns wrong bounding boxes, but since
the geometries are invalid, I am not submitting a bug report for that.
I have attached a total of 103 examples in which st_makevalid produces
invalid geometries, both in CSV format and SQL dump.
--
Ticket URL: <http://trac.osgeo.org/postgis/ticket/2307>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.
More information about the postgis-tickets
mailing list