-
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
Adding check in closedLoop method to ensure no duplicate locations. #224
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.
One question on equality, otherwise looks good.
@@ -152,7 +152,11 @@ public Location center() | |||
*/ | |||
public Iterable<Location> closedLoop() | |||
{ | |||
return new MultiIterable<>(this, Iterables.from(this.first())); | |||
if (this.first() != this.last()) |
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.
Should this be !this.first().equals(this.last())
, since the two Locations can be different objects in memory, but we care about actual equality at the latitude/longitude level?
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.
yes definitely. I will update now.
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.
Looks good, thanks for the change @mgcuthbert!
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!
Description:
This is a very minor update to how the closedLoop function on the polygon object works. Previously it was simply adding the first location to the end of the iteration. This update now just checks to make sure that the last object isn't already equal to the first object, that way we are not simply adding a duplicate location at the end of the iteration.
Potential Impact:
I am not sure if there would be any impact, it is unlikely that this scenario would even be hit under normal circumstances.
Unit Test Approach:
Added a unit test that makes sure that we aren't adding the location at the end if the polygon is already closed.
Test Results:
Test cases passed correctly, and also failed correctly when the update is not included.