Whole file

geographiclib/geographiclib-python

The author described this change as Add planimeter reverse arctic test to catch transit bug and fix.. It counts as a record because the check below fails on the code as it stood at 1db690db5 and passes on d25401a86, with nothing else changed between the two runs.

Fix saved2022-03-08
Sharing licenceMIT · LICENSE
Change size+6 8

What the code was meant to do, written into the code itself as a save note

Add planimeter reverse arctic test to catch transit bug and fix.

The change

6161 lon12, _ = Math.AngDiff(lon1, lon2)
6262 lon1 = Math.AngNormalize(lon1)
6363 lon2 = Math.AngNormalize(lon2)
64- cross = (1 if lon1 <= 0 < lon2 and lon12 > 0
65- else (-1 if lon2 <= 0 < lon1 and lon12 < 0 else 0))
66- return cross
64+ return (1 if lon12 > 0 and ( lon1 < 0 <= lon2 or
65+ (lon1 > 0 and lon2 == 0))
66+ else (-1 if lon12 < 0 and lon2 < 0 <= lon1 else 0))
6767
6868 @staticmethod
6969 def _transitdirect(lon1, lon2):
7070 """Count crossings of prime meridian for AddEdge."""
7171 # We want to compute exactly
72- # int(ceil(lon2 / 360)) - int(ceil(lon1 / 360))
73- # Since we only need the parity of the result we can use std::remquo but
74- # this is buggy with g++ 4.8.3 and requires C++11. So instead we do
72+ # int(floor(lon2 / 360)) - int(floor(lon1 / 360))
7573 lon1 = math.fmod(lon1, 720.0); lon2 = math.fmod(lon2, 720.0)
76- return ( (1 if (-360 < lon2 <= 0 or lon2 > 360) else 0) -
77- (1 if (-360 < lon1 <= 0 or lon1 > 360) else 0) )
74+ return ( (0 if (0 <= lon2 < 360 or lon2 < -360) else 1) -
75+ (0 if (0 <= lon1 < 360 or lon1 < -360) else 1 ) )
7876
7977 @staticmethod
8078 def _areareduceA(area, area0, crossings, reverse, sign):

The check that tells the two apart

failpass·geographiclib/test/test_geodesic.py::PlanimeterTest::test_Planimeter12r

Check file 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 it1db690db53ccaebb5c8bbc6c927d0a63ecf0df13
Broken version dated2022-03-06
Modulegeographiclib.polygonarea
Units changedPolygonArea
Fingerprint6d5f4d5ddb011dd4
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