[postgis-devel] Minimum number of points in a POLYGON ring?
Martin Davis
mbdavis at refractions.net
Fri Sep 19 09:02:38 PDT 2008
Another alternative would be to detect the case where a ring has fewer
than 4 points or is not closed, and to add the start point a sufficient
number of times to make up the 4 points and close the polygon. This
still allows the geometry to be entered, it will still test as invalid
if it originally was, but it ensures that the geometry in the database
is at least structurally corrrect. This check should be pretty fast -
much faster than testing for full validity.
Mark, I'm not surprised that you found that:
(a) other spatial DBs are all over the place WRT how they enforce validity
(b) they don't document this well!
Sadly, there is no standard covering what the DB should actually be able
to store, and spatial DB documentation is woefully short on detail where
it really counts. (Except maybe for PG now that Kevin and Regina et al
are in action! 8^)
One "DB" that you missed is SDE. It has a very draconian approach to
correctness - geometries are forced to be 100% valid before they are
allowed in the DB. I'm not sure if this is still the case, but it used
to be that SDE would actually attempt to alter geometry topology to
ensure validity. There's a certain appeal to this, but ultimately I
agree with Paul - "be forgiving about what you accept and rigorous about
what you emit". Ain't no chance to fix geometry if you can't get it in
the DB.
OGC seemed to follow this maxim to a limited extent - e.g. the SFS spec
doesn't care about ring orientation (which is NOT respected in some
DBs...). However, they drew the line at ring structure - gotta have >=
4 pts & closed. Not sure why they did this - perhaps they felt that
creating this structure was easy enough that it wasn't a technical
barrier. Or more likely, they just never thought about it...
Mark Cave-Ayland wrote:
> Hi there,
>
> Having just been working on the parser again, I've just wanted to
> verify we are currently doing the check for the minimum number of
> points in a polygon ring correctly.
>
> Currently the parser enforces a minimum of 3 points in a ring - but
> given that the last point in a ring must be the same as the first
> point, do we need to increase this to 4? So in other words, is a
> polygon with no area simple?
>
> A bit of googling shows Informix believes the minimum number of points
> in a polygon should be 4 (see USE31 in
> http://publib.boulder.ibm.com/infocenter/idshelp/v10/index.jsp?topic=/com.ibm.spatial.doc/spat310.htm),
> but that doesn't distinguish between whether that is for the whole
> polygon or just an individual ring. Can anyone clarify this with the
> OGC spec?
>
>
> Many thanks,
>
> Mark.
>
--
Martin Davis
Senior Technical Architect
Refractions Research, Inc.
(250) 383-3022
More information about the postgis-devel
mailing list