We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
a = b = Point(113.9192428, 22.4876533) a_y = radians(a.y) b_y = radians(b.y) delta_x = radians(a.x - b.x) cos_x = sin(a_y) * sin(b_y) + cos(a_y) * cos(b_y) * cos(delta_x) cos_x 1.0000000000000002
acos(cos_x) couldn't be higher 1
I fixed that:
def geo_distance(a, b): """ Distance between two geo points in km. (p.x = long, p.y = lat) :param a: (Point) :param b: (Point) :return: float """ if a == b: return 0. a_y = radians(a.y) b_y = radians(b.y) delta_x = radians(a.x - b.x) cos_x = sin(a_y) * sin(b_y) + cos(a_y) * cos(b_y) * cos(delta_x) # fix python float precision 1.0000000000000002 cos_x = cos_x if cos_x < 1 else 1 return acos(cos_x) * 6370.986 # PostGIS earth radius
The text was updated successfully, but these errors were encountered:
No branches or pull requests
acos(cos_x) couldn't be higher 1
I fixed that:
The text was updated successfully, but these errors were encountered: