You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2019/05/15 08:33:10 UTC
[sis] branch geoapi-4.0 updated: When building a geodesic path, may need to add or remove 360° to the target longitude depending on the heading.
This is an automated email from the ASF dual-hosted git repository.
desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git
The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
new 6e8bbee When building a geodesic path, may need to add or remove 360° to the target longitude depending on the heading.
6e8bbee is described below
commit 6e8bbee051fda7acc18eab4e153b66515851be10
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Wed May 15 10:32:31 2019 +0200
When building a geodesic path, may need to add or remove 360° to the target longitude depending on the heading.
---
.../java/org/apache/sis/referencing/GeodeticCalculator.java | 13 +++++++++----
.../org/apache/sis/referencing/GeodeticCalculatorTest.java | 2 +-
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/GeodeticCalculator.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/GeodeticCalculator.java
index bd24a79..27b4687 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/GeodeticCalculator.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/GeodeticCalculator.java
@@ -534,10 +534,10 @@ public class GeodeticCalculator {
* <li>The first point is {@link #getStartPoint()}.</li>
* <li>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.</li>
- * <li>The curve passes at least by the midway point.</li>
+ * <li>The point B(½) in the middle of the Bézier curve is a point of the geodesic path.</li>
* <li>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.</li>
- * <li>The last point is {@link #getEndPoint()}.</li>
+ * <li>The last point is {@link #getEndPoint()}, potentially with 360° added or subtracted to the longitude.</li>
* </ol>
*
* <b>Limitations:</b>
@@ -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));
}