There's a BUG in the PolygonArea::TestEdge routine in the Java
implementation of GeographicLib. The following patch fixes this:
diff --git a/java/src/main/java/net/sf/geographiclib/PolygonArea.java b/java/src/main/java/net/sf/geographiclib/PolygonArea.java
index 1e4ed1a1..b7379bcc 100644
--- a/java/src/main/java/net/sf/geographiclib/PolygonArea.java
+++ b/java/src/main/java/net/sf/geographiclib/PolygonArea.java
@@ -338,10 +338,10 @@ public class PolygonArea {
_earth.Direct(_lat1, _lon1, azi, false, s, _mask);
tempsum += g.S12;
crossings += transitdirect(_lon1, g.lon2);
+ crossings += transit(g.lon2, _lon0);
g = _earth.Inverse(g.lat2, g.lon2, _lat0, _lon0, _mask);
perimeter += g.s12;
tempsum += g.S12;
- crossings += transit(g.lon2, _lon0);
}
if ((crossings & 1) != 0)
This will be included in the next release (version 1.50).