[Qgis-developer] Valid or invalid geom in PostGIS?

Mark Johnson mj10777 at googlemail.com
Mon Jan 16 19:01:42 PST 2017


>
> thanks for your feedback. Shouldn't this be reported by ST_IsValid also?
>

Yes, it should.

SELECT
 ST_GeomFromText('POLYGON((7 7, 77 77, 35 35,7 7))') AS bad_poly,
 ST_IsValid(ST_GeomFromText('POLYGON((7 7, 77 77, 35 35,7 7))')) AS
bad_poly_valid,
 ST_IsValidDetail(ST_GeomFromText('POLYGON((7 7, 77 77, 35 35,7 7))')) AS
bad_poly_geom,
 ST_IsValidReason(ST_GeomFromText('POLYGON((7 7, 77 77, 35 35,7 7))')) AS
bad_poly_reason;

will report:
GEOS warning: Self-intersection at or near point 7 7
(as shown when called from spatialite in a terminal)

and as the result of ST_ValidReason: Self-intersection[7 7]

I cannot find a simple sample to reproduce the second error:
- Invalid number of points in LinearRing found 3 - must be 0 or >= 4

A simple sample that produces both errors at the same time
- could possibly show if the second error possibly interferes with the first
-- causing ST_IsValid to return TRUE, which should never happen

If you could supply the offending geometry in a text file (i.e. result of
'ST_AsText(geometry)'), then this could be checked.

Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20170117/5678e034/attachment.html>


More information about the Qgis-developer mailing list