Open jnyrup opened 4 years ago
Well it's a dilema here. I don't know what was the intended behavior when the project was initiated. It may be for that reason : when LineStrings are not closed, this will break some systems (SQL Server is strict on that for instance).
But comparing until the 10th decimal digit (as DoubleComparer does) is fair enough to state it's the same coordinate. We are talking about micrometers here.
More over equality with double is something variable upon where the code is executed and strict equality should be replaced by difference is below double.Epsilon. So the DoubleComparer is a good choice here, as it checks for equality for acceptable ranges.
So I think we could remove this strict equality check and prefer the DoubleComparer.
We then may add candies for strict closeness such as EnsureIsClosed()
which can replace last position by exactly the start position only if DoubleComparer states that they are equal.
If anyone watching this thinks it's a bad idea please comment down here.
And by the way, thanks for your implication @jnyrup !
Two instances of
Position
are considered equal when theirLatitude
,Longitude
andAltitude
are approximately equal using aDoubleComparer
.LineString.IsClosed
considers an instance to be closed ifLatitude
,Longitude
andAltitude
of its first and lastIPosition
coordinate are exactly equals.This seems to be potential inconsistent when constructing a
LineString
withPosition
asIPosition
.Is that intended behavior?