Skip to content

Commit 7080c35

Browse files
authored
Merge pull request #145 from nicgowans/master
Float comparison for coincident coordinates in vincenty inverse function
2 parents 4d6d0a7 + ec84ed4 commit 7080c35

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

geodepy/geodesy.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ def vincinv(lat1, lon1, lat2, lon2, ellipsoid=grs80):
180180
lon2 = angular_typecheck(lon2)
181181

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

186187
# Equation numbering is from the GDA2020 Tech Manual v1.0

geodepy/tests/test_geodesy.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ def test_vincinv(self):
7777
test2 = vincinv(lat1, lon1, lat1, lon1)
7878
self.assertEqual(test2, (0, 0, 0))
7979

80+
# Test coincident coordinates (within float precision)
81+
pl1 = (-30.645230675, 152.996285475)
82+
pl2 = (-30.645230674999997, 152.996285475)
83+
test3 = vincinv(pl1[0], pl1[1], pl2[0], pl2[1])
84+
self.assertEqual(test3, (0, 0, 0))
85+
8086
# Test DMSAngle Input
8187
ell_dist, azimuth1to2, azimuth2to1 = vincinv(lat1_DMS, lon1_DMS,
8288
lat2_DMS, lon2_DMS)

geodepy/transform.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,4 +269,3 @@ def ntv2_2d(ntv2_grid, lat, lon, forward_tf=True, method='bicubic'):
269269
tf_lon = lon + shifts[1] / 3600
270270

271271
return tf_lat, tf_lon
272-

0 commit comments

Comments
 (0)