Whole file
geographiclib/geographiclib-python
The author described this change as “Implement fix to AddEdge/transitdirect bug in Java, JS, + Python libraries + add test case. (Already done for C++ + C; not necessary for MATLAB + Fortran.)”. It counts as a record because the check below fails on the code as it stood at 73b8bd879 and passes on 6b13b5bff, with nothing else changed between the two runs.
Fix saved2019-09-10
Sharing licenceMIT · LICENSE
Change size+3 −3
What the code was meant to do, written into the code itself as a save note
Implement fix to AddEdge/transitdirect bug in Java, JS, + Python libraries + add test case. (Already done for C++ + C; not necessary for MATLAB + Fortran.)
The change
| 67 | 67 | def _transitdirect(lon1, lon2): | |
| 68 | 68 | """Count crossings of prime meridian for AddEdge.""" | |
| 69 | 69 | # We want to compute exactly | |
| 70 | - | # int(floor(lon2 / 360)) - int(floor(lon1 / 360)) | |
| 70 | + | # int(ceil(lon2 / 360)) - int(ceil(lon1 / 360)) | |
| 71 | 71 | # Since we only need the parity of the result we can use std::remquo but | |
| 72 | 72 | # this is buggy with g++ 4.8.3 and requires C++11. So instead we do | |
| 73 | 73 | lon1 = math.fmod(lon1, 720.0); lon2 = math.fmod(lon2, 720.0) | |
| 74 | - | return ( (0 if ((lon2 >= 0 and lon2 < 360) or lon2 < -360) else 1) - | |
| 75 | - | (0 if ((lon1 >= 0 and lon1 < 360) or lon1 < -360) else 1) ) | |
| 74 | + | return ( (1 if ((lon2 <= 0 and lon2 > -360) or lon2 > 360) else 0) - | |
| 75 | + | (1 if ((lon1 <= 0 and lon1 > -360) or lon1 > 360) else 0) ) | |
| 76 | 76 | _transitdirect = staticmethod(_transitdirect) | |
| 77 | 77 | ||
| 78 | 78 | def __init__(self, earth, polyline = False): |
The check that tells the two apart
fail→pass·python/geographiclib/test/test_geodesic.py::PlanimeterTest::test_Planimeter29
Check file python/geographiclib/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 it73b8bd879f92f33f158e855ee27490e83920b24b
Broken version dated2019-09-09
Modulepython.geographiclib.polygonarea
Units changedPolygonArea
Fingerprintf96bf8706cc3169d
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).
- 2015-09-23* 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.
- 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