[postgis-devel] Invalid output from ST_BuildArea()

Mark Cave-Ayland mark.cave-ayland at siriusit.co.uk
Thu Sep 18 07:34:03 PDT 2008


Hi folks,

I've just committed some new code to the parser in SVN trunk that adds 
the same simple checks that we perform upon conversion from WKT/WKB to 
LWGEOM to the conversion back from LWGEOM to WKT/WKB: in other words 
ensure polygon rings are closed and have > 3 points, linestrings have > 
2 points and circularstrings have > 3 points and an odd number points.

Now rather interestingly this has thrown up a series of regressions in 
regress_bdpoly, and looking at the diff it's fairly easy to see why:

*** 1,19 ****
! BuildArea|SRID=2;POLYGON((0 0 10,0 10 8,10 10 6,10 0 4,0 0 2))
...
--- 1,19 ----
! ERROR:  geometry contains non-closed rings

Ah. It's a polygon with a ring where the first point != last point. So 
in other words, it seems that the ST_BuildArea()/BuildArea() functions 
are capable of producing invalid geometries :(

Given that it appears to be the Z coordinate which is incorrect, I'm 
wondering if this is related to the "what does GEOS with the Z 
coordinate?" discussion currently happening on the GEOS list. Maybe the 
conversion checks from LWGEOM to WKT/WKB need to be loosened so that 
they only make use of 2 dimensions?


Thoughts?

Mark.

-- 
Mark Cave-Ayland
Sirius Corporation - The Open Source Experts
http://www.siriusit.co.uk
T: +44 870 608 0063



More information about the postgis-devel mailing list