-
Notifications
You must be signed in to change notification settings - Fork 310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add IsValid(int idx) and IsClosed to CordinateSequence #752
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tend to support this enhancement.
I'm not sure about the naming of IsValidCoordinate(int)
, I think IsCoordinateValidAt(int)
is slightly better.
Unit tests are missing
/// <summary> | ||
/// Returns whether the i'th coordinate is valid | ||
/// </summary> | ||
public virtual bool IsValidCoordinate(int i) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public sealed override bool IsValidCoordinate(int i)
src/NetTopologySuite/Geometries/Implementation/PackedCoordinateSequence.cs
Outdated
Show resolved
Hide resolved
if (double.IsInfinity(d) || double.IsNaN(d)) return false; | ||
|
||
d = GetY(i); | ||
if (double.IsInfinity(d) || double.IsNaN(d)) return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dito
|
Why is this try-catch here? Lines 203 to 210 in b2897e0
I accicdentally copied this method for the new test methods... Now I removed the try-catches from my new test methods. |
I propose to add /// <summary>
/// Tests if a value is a valid for an ordinate.
/// Valid ordinate values are finite.
/// </summary>
/// <param name="value">The ordinate value</param>
/// <returns><c>true</c> if <paramref name="value"/> has a finite value</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsValidOrdinateValue(double value)
{
#if NETSTANDARD2_1_OR_GREATER
return double.IsFinite(value);
#else
return (~BitConverter.DoubleToInt64Bits(value) & 0x7ff0000000000000L) != 0;
#endif
} to either |
Having |
Ok, I added the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for finding the other places where ordinate validity plays a role!
I've thought a bit about To prevent the creation of |
Yes, emply What do you suggest? I don't know whether it is important or not that the empty 2 of them are speifically checking the IsClosed value, so probably they are not relevant. The check in the test should be negated. |
Yes, it could use the How about putting an IsEqualAt2D to the CoordinateSequences, which checks only the X and Y coorinates and no measures? (Similar to the |
What about this PR? Should I change anything else? |
Prerequisites
Description
During the validation of the LineString object some extra Coordiate objects are created when not the default CoordinateSequence is used. (For example a PackedCoordinateSequence or a custom sequence)
It would be doog if the CoordinateSequence could validate the Nth coordinate or check whether it is closed.
This feature request/PR adds 2 new virtual methods/property to the base CoordinateSequence class to check the validity of the Nth coordiante and whether the sequence is closed without getting the actual coordinate object.
It also adds an implementation for the PackedCoordinateSequence class.