[postgis-users] Re: Re: Errors in geometry. (TECHER David)
Martin Davis
mbdavis at refractions.net
Tue Apr 17 08:58:46 PDT 2007
You're correct that isValid internally identifies the type of the
validation error that was found. This information is exposed in GEOS
too, I suspect (since it is available in JTS) But there doesn't seem to
be any PostGIS function which exposes this. What's probably needed is a
function with a signature like: int validate(Geometry), which would
validate the geometry and return a code indicating the error type.
There's actually even more information available from the validator. It
reports the spatial location of the error (where possible). The trick
here would be how to report both the error type and the error location
out of a function. Perhaps PostgresQL has some clever language
constructs that could do this (e.g. an array or record?).
Oracle Spatial has a similar function called
VALIDATE_GEOMETRY_WITH_CONTEXT, which reports the path to the component
in the geometry that is the cause of the error. This can sometimes be
even more useful than a location, since there can be more than one
component at a given location. The return value simply returns a string
which must be parsed to obtain the error code and the path (a bit
cheesy, but may not as bad as it sounds if functions are provided to
parse out the components).
Finally, a further option which might be useful is to report ALL
validation errors in a geometry (or at least as many as possible). For
instance, polygons may have multiple self-intersections. Currently, the
validation code only reports the first error found.
Martin
Jennehag Åke wrote:
>
> Hi!
>
> Thanks for the reply. But it wont help me. I want to get the type off
> error as it is printed out in the message window. isvalid(geom)
> function only reports back true or false (true if the geom is ok and
> false if it has any problem.) I want to know what the problem is with
> the geometry. Apparently there is some way to report this, otherwise I
> don't know there the messages (see below) comes from. I'm actually
> looking for the function that prints out the error. I have search the
> documentation for this but I have not found anything.
>
>
> ....
> NOTICE: Too few points in geometry component
> NOTICE: Self-intersection
> NOTICE: Self-intersection
> ....
>
> It seams that each error that are reported back with the isvalid(geom)
> function has an description in the message window, but I'm not sure.
>
> If I try this query:
>
> SELECT gid , asgml(geom) FROM bishkekeni WHERE gid < 500;
>
> Then I don't get any 'NOTICE: [error]' in the message window, so it
> must be connected with the isvalid() function. But as I wrote before,
> I'm interested in knowing what is wrong with a particular geometry, is
> it self-intersecting or ....
>
> Regards
>
> Åke Jennehag
>
>
>
> >Date: Mon, 16 Apr 2007 20:17:33 +0200
>
> >From: TECHER David <davidtecher at yahoo.fr>
>
> >Subject: Re: [postgis-users] Errors in geometry.
>
> >To: PostGIS Users Discussion <postgis-users at postgis.refractions.net>
>
> >Message-ID: <4623BDBD.3020708 at yahoo.fr>
>
> >Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> >Perhaps by adding a column
>
> >ALTER TABLE .. ADD COLUMN is_valid boolean;
>
> >UPDATE ... SET is_valid=isvalid(the_geom)
>
> >then
>
> >SELECT gid, asgml(geom) FROM bishkekeni WHERE NOT is_valid = ...
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
--
Martin Davis
Senior Technical Architect
Refractions Research, Inc.
(250) 383-3022
More information about the postgis-users
mailing list