[geos-devel] Is empty LinearRing closed?

Mateusz Łoskot mateusz at loskot.net
Thu Mar 30 18:17:47 EST 2006


Martin Davis wrote:
>> 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.
> 
> No, the point is that if the LinearRing is valid, isClosed always 
> returns the correct answer.  It doesn't matter where this method is 
> evaluated.

You're right that if the LinearRing is valid then it's closed.
But it can stop to be valid after some opertion, right? e.g. after user
removes end point?

Second, as far as I know, there is nothing said about that every
LinearRing is considered as a valid LinearRing automatically.

Isn't it possible to have invalid LinearRing?
IMO, isValid predicate should also use isClosed to check the validation,
shouldn't it?

That's why I think LinearRing::isClosed should not return one and the
only one possible value - true.

>> The IsEmpty function checks emptiness of geometry and returns TRUE
>>  if the geometry is empty or FALSE if the geometry is not empty.
> 
> This *IS* the way it is implemented in JTS/GEOS.

Sure.

>> So, I understand this behaviour as very dynamic. LineString X can 
>> become a LinearRing and vice versa.
> 
> Well, a LineString can't just change type into a LinearRing. But if 
> you're saying that a LineString might be closed, yes I agree and 
> JTS/GEOS will return the right answer in this case (for a LineString,
>  isClosed checks the endpoints are equal).

Yes, that's what I'm talking.
Also, the other way operation is (should be) possible: LinearRing
becomes not closed anymore then isClosed for LinearRing returns
false :-)
Would not it be correct?

> Anyway, this isn't a big deal IMHO - I'd be perfectly happy changing
>  the LinearRing method so it just uses the LIneString implementation.
> 
Yup. That's a way I have implemented my own version of OGC Spec some
time ago (closed source :-( ).

Cheers

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



More information about the geos-devel mailing list