Whole file
geographiclib/geographiclib-python
The author described this change as “* Fix geodesic inversion so that nan + point on equator or pole returns all nans. Update tests to check this. * Fix bug in gedistance.m in handling equatorial lines.”. It counts as a record because the check below fails on the code as it stood at 4e778cb92 and passes on 72d34d4d4, with nothing else changed between the two runs.
Fix saved2015-09-23
Sharing licenceMIT · LICENSE
Change size+3 −2
What the code was meant to do, written into the code itself as a save note
* Fix geodesic inversion so that nan + point on equator or pole returns all nans. Update tests to check this. * Fix bug in gedistance.m in handling equatorial lines.
The change
| 694 | 694 | lat1 = Math.AngRound(Math.LatFix(lat1)) | |
| 695 | 695 | lat2 = Math.AngRound(Math.LatFix(lat2)) | |
| 696 | 696 | # Swap points so that point with higher (abs) latitude is point 1 | |
| 697 | - | swapp = 1 if abs(lat1) >= abs(lat2) else -1 | |
| 697 | + | # If one latitude is a nan, then it becomes lat1. | |
| 698 | + | swapp = -1 if abs(lat1) < abs(lat2) else 1 | |
| 698 | 699 | if swapp < 0: | |
| 699 | 700 | lonsign *= -1 | |
| 700 | 701 | lat2, lat1 = lat1, lat2 | |
| ⋯ | |||
| 982 | 983 | ||
| 983 | 984 | def CheckPosition(lat, lon): | |
| 984 | 985 | """Check that lat and lon are legal and return normalized lon""" | |
| 985 | - | if not (abs(lat) <= 90): | |
| 986 | + | if abs(lat) > 90: | |
| 986 | 987 | raise ValueError("latitude " + str(lat) + " not in [-90, 90]") | |
| 987 | 988 | # if not Math.isfinite(lon): | |
| 988 | 989 | # raise ValueError("longitude " + str(lon) + " not a finite number") | |
The check that tells the two apart
fail→pass·python/test/test_geodesic.py::GeodSolveTest::test_GeodSolve55
Check file python/test/test_geodesic.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before it4e778cb920c05355908c9f1a7a1f7ff88f218183
Broken version dated2015-09-23
Modulepython.geographiclib.geodesic
Units changedGeodesic
Fingerprintb77134c4d9d05388
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.
Other bugs found in geographiclib/geographiclib-python
- 2025-08-21Fix bug in geodesic inverse solution for very prolate ellipsoids.
- 2022-03-08Add planimeter reverse arctic test to catch transit bug and fix.
- 2021-07-28Fix bug where a geodesic with lat1 = 0 and lat2 = nan was treated as equatorial (bug found 2021-07-26).
- 2019-09-10Implement fix to AddEdge/transitdirect bug in Java, JS, + Python libraries + add test case. (Already done for C++ + C; not necessary for MATLAB + Fortran.)
- 2015-09-17* Create and install geographiclib.js and geographiclib.min.js. * Complete the unit tests for Java and JavaScript packages. * Introduce GeodesicMask.STANDARD into Java package. * Fix bug in normalizat