-
Notifications
You must be signed in to change notification settings - Fork 80
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
Longitude Compare at +180 degrees #179
Conversation
Closing, will re-open when #178 is merged. Unfortunately travis checks are not reliable until that one is merged. |
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 think the statement "Longitude(179).isGreaterThan(Longitude(180))
is true" should be correct, as Longitude(180)
in reality is equal to Longitude(-180)
I disagree, I think by that logic then anything above or at -179.999 is greater than 180. This becomes an issue in I can add an |
What is your thinking? I understand wanting to keep the continuity of -180 is 180, but without treating 180 as larger in the range of Longitudes we'll get incorrect results for operations involving Rectangles with their East Side on the antiMeridian (and possibly other places). |
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.
Ok, let's move forward with this. However I think we might want more unit tests. @MikeGost any ideas of what else we could add to make sure nothing breaks?
Per offline discussion with @matthieun - I would add more tests surrounding bounding boxes and intersection/overlap calls with these. Specific cases to consider are bounding boxes that stretch across the antimeridian and ones that greater than 180 degrees but don't cross the antimeridian. |
I added a test to Rectangle that shows two different cases in which without the changes, they would fail. I confirmed this by reverting my changes and running the test. Let me know what you think. I believe the interactions displayed in the Rectangle test are the desired ones. |
Sorry for nit-picking - can we add more tests. Specifically:
|
@MikeGost Constructed with |
@jklamer - does construction matter in this case? I just wanted to verify backward compatibility across Polygons > 180 degrees and wrapping around meridian. |
Scratch that, @jklamer and I talked offline, not a viable test case. PR looks good! |
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.
Let's roll with that!
All
Longitude
s are stored as an underlyingAngle
from [-180,180). But if a location is created at 180 the Longitude representation and functionality remain 180. However when using the underlying comparison methods of the parentAngle
class, this distinction is lost as thethis.getDm7()
methods grabs the raw storedAngle
value. So that Longitude(179).isGreaterThan(Longitude(180)) is true.With this change the range methods will use the
asDm7
method, which is overridden byLongitude
to return 180 if that is what it is created with.One oddity this will create Longitude(-180).isGreaterThanOrEqualTo(Longitude(180)) will now return false, but Longitude(-180).equals(Longitude(180)) will return true as before.
EDIT UPDATE:
Reverting to using
getDm7
when the classes are different and thus have potentially differentasDm7
range /values; for instanceHeading.isLessThan(Longitude)
.