[geos-devel] Problem with convex hull generating bad polygons (I think)

Martin Davis mtnclimb at telus.net
Wed Apr 17 08:05:52 PDT 2013


Yes, you do need to explicitly check validity - the WKT reader does not 
enforce validity.  This is because:
(a) validity checking is expensive, and may not always be needed
(b) some use cases require reading the geometry regardless of whether it 
is valid

This is a general principle with JTS/GEOS, by the way.  Geometries 
created manually or by external input must be checked for validity and 
then handled appropriately - the library methods do not do this 
automatically.  However, you can assume that any geometry created by 
library operations is valid.

On 4/16/2013 11:23 PM, Richard Frith-Macdonald wrote:
> On 17 Apr 2013, at 06:45, Martin Davis wrote:
>
>> ConvexHull does not require validity of the input - it only operates on the raw vertices of the input.  And it should always produce a valid output (which will be a polygon in the case of three or more non-collinear points).
>>
>> Could the TopologyException come from the Union operation, not the ConvexHull?  Union definitely *does* require valid inputs, and if the inputs are not valid it almost always throws a TopologyException.
> Thanks ... that confirms my suspicion that I must somehow be getting bad inputs ... I'm now doing the tedious work of adding calls to GEOSisValid() for all input sources and before/after various operatiosn in my code, to track down were the invalid geometry is coming from.   Almost all input in my code comes is handled via the WKT reader, and I had assumed that this would produce a nul geometry if the input text didn't contain a valid geometry, but it seems this may not be the case, and I need to check validity of the geometry explicitly after parsing the WKT.
>
> _______________________________________________
> geos-devel mailing list
> geos-devel at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/geos-devel
>
>



More information about the geos-devel mailing list