[geos-devel] Is empty LinearRing closed?

Mateusz Łoskot mateusz at loskot.net
Thu Mar 30 17:35:07 EST 2006


Martin Davis wrote:
> But the definition of LinearRing is that the start point equals the 
> end point.   This makes the test unnecessary for a valid LinearRing.
>  However, maybe it's more general to use the explicit test.

In my opinion this test is necessary to be checked explicitly.
LinearRing is of type of LineString, so it is possible to pass
LinearRing where LineString is expected, and the other way.
So, checking "static state" of those two types may result in wrong asnwer.

Empty LineString in OGR is created explicitly as empty set of points +
collection (array) of points is UNDEFINED:

/**
 * Create an empty line string.
 */
OGRLineString::OGRLineString()
{
    nPointCount = 0;
    paoPoints = NULL;
    padfZ = NULL;
}

> As for an empty LinearRing, well, I don't know of any semantics which
>  covers this.

I think its simple to understand but quit difficult to implement this
semantic properly. Here is my understanding of the emptiness (according
to MySQL, ArcSDE impl. and OGC Simple Feature Spec.):

1. Empty geometries contain no coordinates. IOW, geometry is empty if it
does not have any coordinates.

2. Following properties of empty geometry are not defined as well:
exterior, interior, and boundary. According to ArcSDE, an empty geometry
has a NULL envelope, boundary, interior, and exterior.

3. Empty geometry is always simple.

4. I like the idea of MySQL Spatial Ext. that empty geometry has
dimension set to -1 (undefined).

5. Empty surface geometry has area equal to 0, empty curves( linestrings
and multilinestrings) have a 0 length.

NOW THE MOST IMPORTANT:
The IsEmpty function checks emptiness of geometry and returns TRUE if
the geometry is empty or FALSE if the geometry is not empty.

That clearly means it's *incorrect* to set that some type *always*
returns true or false. This behaviour is dynamic, depending on current
state of geometry (if it contains empty set of points or not).

Please, not that some of types of OGC Geometries has a logical meaning
and they are not required to be represented as accurate instance of such
type.

I mean, ArcSDE does not use LinearRing at all, but only LineString type
(exteriorRing() returns instance of LineString but not LinearRing).
Second, the LineString becomes LinearRing as OGC Simple Feaure Spec. says:

"A LinearRing is a LineString that is both closed and simple."

So, I understand this behaviour as very dynamic. LineString X can
become a LinearRing and vice versa.


> This might be an angels-on-the-head-of-a-pin kind of thing.  If you 
> don't like the JTS semantics for your particular use-case, you should
>  just implement your own test.

The semantic is clearly explained in OGC Spec. but it's implemented
incorrectly.

Cheers
-- 
Mateusz Łoskot
http://mateusz.loskot.net



More information about the geos-devel mailing list