Merged
Conversation
jenhagg
reviewed
Oct 16, 2020
| site_coords = (x.from_lat, x.from_lon) | ||
| place2_coords = (x.to_lat, x.to_lon) | ||
| return geopy.distance.vincenty(site_coords, place2_coords).km | ||
| return haversine((x.from_lat, x.from_lon), (x.to_lat, x.to_lon)) * 1.60934 |
Collaborator
There was a problem hiding this comment.
Could we use a constant here? mi_to_km = 1.60934
jenhagg
approved these changes
Oct 16, 2020
Collaborator
jenhagg
left a comment
There was a problem hiding this comment.
Awesome, thanks for cleaning this up.
6f53f52 to
fce9060
Compare
rouille
approved these changes
Oct 16, 2020
Collaborator
rouille
left a comment
There was a problem hiding this comment.
Thanks for cleaning this up
fce9060 to
afd24c6
Compare
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Reduce number/scope of required dependencies.
geopyis "a Python client for several popular geocoding web services.geopymakes it easy for Python developers to locate the coordinates of addresses, cities, countries, and landmarks across the globe using third-party geocoders and other data sources." We are using it to calculate the distance between two points.What is the code doing
In
distance.py,great_circle_distancetakes a series with {from_lat, from_lon, to_lat, to_lon} and returns the distance between the two points. As far as I can tell, it's used only from within PostREISE. I've refactored it to use thehaversinefunction/formula instead, and deleted thegeopyimport and requirements.Validation
Over our entire grid, the maximum length difference between vincenty and haversine methods is 0.4 miles, for a 211 mile line. The largest relative difference appears to be 0.4% on a zero-length line (floating point cruft?).
(run with develop):
Time to review
5 minutes.