[postgis-devel] Valid geometries

Vincent Mora vincent.mora at oslandia.com
Fri Jan 9 03:20:25 PST 2015


Hi all,

We have a discussion about geometry validity with Hugo Mercier on irc 
that raises questions of general interest. So here's a summary:

SFCGAL function check the validity of input geometries, this takes time, 
but if we don't do it the algorithm behavior can be undefined (crash, 
infinite loop).

We think that a valid geometry should have a different type than a 
geometry which validity is unknown.

A validity flag could be used in postgis to implement that, with three 
possible states: valid|invalid|unknown.

One issue is that geos and sfcgal (absolute prescision) may have 
different oppinion concerning the validity. Even if the geometry 
validity is well defined (SFS), checking if a point lies on a line is 
not the same thing for geos and SFCGAL: the latter tells you "it's 
'absolutely' not on the line", the former tells you "it's really, really 
close to the line". As a result, a segment of a polygon hole touching 
the exterior ring may cause geos to consider the geometry invalid while 
SFCGAL will consider it valid. Bottom line we need two flags, more if at 
some point someone wants to add a boost backend.

It would also be nice to be able to restrict a given table to store only 
valid geometries.

There are alternatives: having a flag specific for SFCGAL, allowing to 
set the validation policy of SFCGAL dynamically with GUC or compiling 
SFCGAL with SFCGAL_CHECK_VALIDITY turned off. But none appeals to me as 
a specific type for valid geometries does.

Which do you prefer ?

V.





More information about the postgis-devel mailing list