[postgis-devel] Validity flag

Hugo Mercier hugo.mercier at oslandia.com
Thu Nov 15 02:21:49 PST 2018



On 15/11/2018 11:01, Sandro Santilli wrote:
> On Thu, Nov 15, 2018 at 10:41:22AM +0100, Hugo Mercier wrote:
> 
>> So we would prefer to have only one definition of validity for everyone
>> and fix validity test bugs of one or the other backend.
> 
> We already have ST_IsValid* accepting flags to specify
> which validity kind to consider. A well-known ESRI variant of
> validity (self-intersecting rings considered valid) is in particular
> used by PostGIS users in the public sector.
> For this reason I really think validity-kind is a must-have, if we
> introduce flags.
> 
> The flags argument for validity is currently an "int" type (32bits).
> A single flag is currently supported (the "ESRI" one).
> I guess we might want to add more flags for more kind of validity
> checks (Z consistency, for instance). Why not starting there, to
> find out how many flags we really need ? To me it's surely not 1bit.

I forgot this ST_IsValid variant. Ok for using this flag for different
kind of validity definitions. But, except for handling this ESRI bug, do
we need other definitions of validity ?

Are you saying for example a Polygon Z with random Z would be "valid
under the GEOS' definition of validity" ? Why is it not a bug ?

> 
>> The validity state could also be enforced by adding a type modifier,
>> like Geometry(point, 4326, valid). We do not have a strong opinion about
>> that, any pro/cons ?
> 
> How much space would we have if we use that ?

I guess as many bits as there would be in headers. In the current
version, only 2 bits is left in typmod I think.

> 
>>
>> We propose to add/modify the following functions:
>>
>> - ST_IsValid:
>>   - if the geometry has a validity flag set to Valid, do not do anything
>>   - otherwise, test if the geometry is valid.
>> - ST_Validate(geom) : calls ST_IsValid and sets the validity flag if it
>> is Valid
> 
> We have ST_MakeValid which could do that (appropriately accepting the
> same flags as ST_IsValid and friends).

Yes, but ST_MakeValid is allowed to modify the geometry to make it
valid, which is not the case of ST_Validate. What if I want to mark
valid geometries for validity without modification ?

> 
>> - ST_HasValidityFlag(geom)
>> - ST_ForceValidityFlag(geom, is_valid), force the validity flag. To be
>> used with caution.
> 
> I don't think we should allos forcing a flag as my understanding is
> that the flag would be used by SFCGAL to skip the check, which may
> in turn result in a backend crash when the input is invalid (for the
> SFCGAL expected validity kind).

Correct. I tend to agree.



More information about the postgis-devel mailing list