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
| 61 | 61 | lon12, _ = Math.AngDiff(lon1, lon2) | |
| 62 | 62 | lon1 = Math.AngNormalize(lon1) | |
| 63 | 63 | 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)) | |
| 67 | 67 | ||
| 68 | 68 | @staticmethod | |
| 69 | 69 | def _transitdirect(lon1, lon2): | |
| 70 | 70 | """Count crossings of prime meridian for AddEdge.""" | |
| 71 | 71 | # 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)) | |
| 75 | 73 | 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 ) ) | |
| 78 | 76 | ||
| 79 | 77 | @staticmethod | |
| 80 | 78 | def _areareduceA(area, area0, crossings, reverse, sign): |
The check that tells the two apart
fail→pass·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
- 2025-08-21Fix bug in geodesic inverse solution for very prolate ellipsoids.
- 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-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