Skip to content
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

Fix for extreme longitudes in Vincenty. #187

Closed
wants to merge 1 commit into from
Closed

Fix for extreme longitudes in Vincenty. #187

wants to merge 1 commit into from

Conversation

karldw
Copy link

@karldw karldw commented May 14, 2016

In some weird edge cases (generated by Hypothesis), the while-loop in the Vincenty code never runs.

Below, difference between the two longitudes is very close to 2π, so the condition
abs(lambda_lng - lambda_prime) > 10e-12 is not true.

from geopy.distance import vincenty
vincenty((-80, -179.999999999999), (-80.0, 180.0))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../geopy/distance.py", line 322, in __init__
    super(vincenty, self).__init__(*args, **kwargs)
  File ".../geopy/distance.py", line 115, in __init__
    kilometers += self.measure(a, b)
  File ".../geopy/distance.py", line 414, in measure
    u_sq = cos_sq_alpha * (major ** 2 - minor ** 2) / minor ** 2
UnboundLocalError: local variable 'cos_sq_alpha' referenced before assignment

In some weird edge cases (generated by Hypothesis), the while-loop in the Vincenty code never runs.

Below, difference between the two longitudes is very close to 2π, so the condition
`abs(lambda_lng - lambda_prime) > 10e-12` is not true.
```python
from geopy.distance import vincenty
vincenty((-80, -179.999999999999), (-80.0, 180.0))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../geopy/distance.py", line 322, in __init__
    super(vincenty, self).__init__(*args, **kwargs)
  File ".../geopy/distance.py", line 115, in __init__
    kilometers += self.measure(a, b)
  File ".../geopy/distance.py", line 414, in measure
    u_sq = cos_sq_alpha * (major ** 2 - minor ** 2) / minor ** 2
UnboundLocalError: local variable 'cos_sq_alpha' referenced before assignment
```
@jamesboone
Copy link

I'm getting this error and would like for this to be merged. +1

@bryan-woods
Copy link

I too am getting this error.

cffk added a commit to cffk/geopy that referenced this pull request May 6, 2017
Restore testing of distance with "make test".

Merge karldw's pull request geopy#187 and modify
test_should_recognize_equivalence_of_pos_and_neg_180_longitude to check
this bug.  This will address issue geopy#242 too.

Change test_should_compute_destination_for_half_trip_around_equator so
that it checks the path along the equator instead of over the pole and
tighten up the accuracy of this test.

Add test_miscellaneous_high_accuracy_cases for testing
distance.geodesic.
@karldw
Copy link
Author

karldw commented Jul 11, 2017

I'm closing this PR in favor of @cffk's updated #144, which fixes this issue and several others.

@karldw karldw closed this Jul 11, 2017
@KostyaEsmukov
Copy link
Member

#144 is still not merged yet, but 15ebe15 has fixed exactly this issue (but it wasn't released to PyPI yet – it will be in the upcoming 1.13.0 release).

Also linking #245 issue which is exactly the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants