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

Float comparison for coincident coordinates in vincenty inverse function #145

Merged
merged 6 commits into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion geodepy/geodesy.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ def vincinv(lat1, lon1, lat2, lon2, ellipsoid=grs80):
lon2 = angular_typecheck(lon2)

# Exit if the two input points are the same
if lat1 == lat2 and lon1 == lon2:
tolerance = 0.0000000001
if abs(lat1 - lat2) < tolerance and abs(lon1 - lon2) < tolerance:
return 0, 0, 0

# Equation numbering is from the GDA2020 Tech Manual v1.0
Expand Down
6 changes: 6 additions & 0 deletions geodepy/tests/test_geodesy.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ def test_vincinv(self):
test2 = vincinv(lat1, lon1, lat1, lon1)
self.assertEqual(test2, (0, 0, 0))

# Test coincident coordinates (within float precision)
pl1 = (-30.645230675, 152.996285475)
pl2 = (-30.645230674999997, 152.996285475)
test3 = vincinv(pl1[0], pl1[1], pl2[0], pl2[1])
self.assertEqual(test3, (0, 0, 0))

# Test DMSAngle Input
ell_dist, azimuth1to2, azimuth2to1 = vincinv(lat1_DMS, lon1_DMS,
lat2_DMS, lon2_DMS)
Expand Down
1 change: 0 additions & 1 deletion geodepy/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,4 +269,3 @@ def ntv2_2d(ntv2_grid, lat, lon, forward_tf=True, method='bicubic'):
tf_lon = lon + shifts[1] / 3600

return tf_lat, tf_lon