• The first point is {@link #getStartPoint()}.
• *
• The beginning of the curve (more specifically, the tangent at starting point) is oriented toward the direction given * by {@linkplain #getStartingAzimuth()}, adjusted for the map projection (if any) deformation at that location.
• - *
• The curve passes at least by the midway point.
• + *
• The point B(½) in the middle of the Bézier curve is a point of the geodesic path.
• *
• The end of the curve (more specifically, the tangent at ending point) is oriented toward the direction given by * {@linkplain #getEndingAzimuth()}, adjusted for the map projection (if any) deformation at that location.
• - *
• The last point is {@link #getEndPoint()}.
• + *
• The last point is {@link #getEndPoint()}, potentially with 360° added or subtracted to the longitude.
• * * * Limitations: @@ -564,10 +564,15 @@ public class GeodeticCalculator { } } tolerance *= (180/PI) / radius; // Angular tolerance in degrees. - final double d1, x1, y1, d2, x2, y2; // Parameters for the Bezier curve. + double d1, x1, y1, d2, x2, y2; // Parameters for the Bezier curve. + x2 = λ2; + final double sign = signum(α1); + if (sign == signum(λ1 - x2)) { + x2 += 2*PI * sign; // We need λ₁ < λ₂ if heading east, or λ₁ > λ₂ if heading west. + } final double[] transformed = new double[ReferencingUtilities.getDimension(userToGeodetic.defaultCRS)]; d1 = slope(α1, geographic(φ1, λ1).inverseTransform(transformed)); x1 = transformed[0]; y1 = transformed[1]; - d2 = slope(α2, geographic(φ2, λ2).inverseTransform(transformed)); x2 = transformed[0]; y2 = transformed[1]; + d2 = slope(α2, geographic(φ2, x2).inverseTransform(transformed)); x2 = transformed[0]; y2 = transformed[1]; final double sφ2 = φ2; // Save setting before modification. final double sλ2 = λ2; final double sα2 = α2; diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticCalculatorTest.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticCalculatorTest.java index 25f0d54..1a5c9a2 100644 --- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticCalculatorTest.java +++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticCalculatorTest.java @@ -187,7 +187,7 @@ public final strictfp class GeodeticCalculatorTest extends TestCase { c.setEndPoint ( 31.4, 121.8); // Shanghai final Shape path = c.toGeodesicPath2D(1000); assertPointEquals( -71.6, -33.0, ShapeUtilities.pointOnBezier(path, 0)); - assertPointEquals( 121.8, 31.4, ShapeUtilities.pointOnBezier(path, 1)); + assertPointEquals(-238.2, 31.4, ShapeUtilities.pointOnBezier(path, 1)); // λ₂ = 121.8° - 360° assertPointEquals(-159.2, -6.8, ShapeUtilities.pointOnBezier(path, 0.5)); }