Skip to content

Commit

Permalink
Merge pull request #145 from nicgowans/master
Browse files Browse the repository at this point in the history
Float comparison for coincident coordinates in vincenty inverse function
  • Loading branch information
BatchelorJ authored Feb 14, 2023
2 parents 4d6d0a7 + ec84ed4 commit 7080c35
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
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

0 comments on commit 7080c35

Please sign in to comment.