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

6767 def _transitdirect(lon1, lon2):
6868 """Count crossings of prime meridian for AddEdge."""
6969 # We want to compute exactly
70- # int(floor(lon2 / 360)) - int(floor(lon1 / 360))
70+ # int(ceil(lon2 / 360)) - int(ceil(lon1 / 360))
7171 # Since we only need the parity of the result we can use std::remquo but
7272 # this is buggy with g++ 4.8.3 and requires C++11. So instead we do
7373 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) )
7676 _transitdirect = staticmethod(_transitdirect)
7777
7878 def __init__(self, earth, polyline = False):

The check that tells the two apart

failpass·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