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/08/07 15:52:22 UTC
[sis] 01/02: Add tests for the rhumb line equatorial case.
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
commit b8aa208c3845ad43609119cffff679e0b5d044e5
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Tue Aug 6 08:13:53 2019 +0200
Add tests for the rhumb line equatorial case.
---
.../sis/referencing/GeodesicsOnEllipsoid.java | 30 +++++++++++--------
.../sis/referencing/GeodesicsOnEllipsoidTest.java | 35 +++++++++++++++++++++-
2 files changed, 51 insertions(+), 14 deletions(-)
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/GeodesicsOnEllipsoid.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/GeodesicsOnEllipsoid.java
index 838f05d..9a2fc18 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/GeodesicsOnEllipsoid.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/GeodesicsOnEllipsoid.java
@@ -938,24 +938,31 @@ class GeodesicsOnEllipsoid extends GeodeticCalculator {
/**
* Computes rhumb line using series expansion.
*
- * <p><b>Source:</b> G.G. Bennett, 1996. <a href="https://doi.org/10.1017/S0373463300013151">Practical
- * Rhumb Line Calculations on the Spheroid</a>. J. Navigation 49(1), 112--119.</p>
+ * <p><b>Source:</b> G.G. Bennett, 1996. <a href="https://doi.org/10.1017/S0373463300013151">
+ * Practical Rhumb Line Calculations on the Spheroid</a>. J. Navigation 49(1), 112--119.</p>
*/
@Override
- void computeRhumbLine() {
+ final void computeRhumbLine() {
canComputeDistance();
final double Δλ = λ2 - λ1;
final double Ψ1 = Ψ(φ1); // Bennett equation 1.
final double Ψ2 = Ψ(φ2);
final double ΔΨ = Ψ2 - Ψ1;
final double azimuth = atan2(Δλ, ΔΨ);
- final double m1 = m(φ1);
- final double m2 = m(φ2);
- final double φm = (φ1 + φ2)/2;
- final double sinφ = sin(φm);
- double S = (m2 - m1) / cos(azimuth);
- if (φ1 == φ2) {
- S = Δλ * cos(φm) / (sin(azimuth) * (1 - eccentricitySquared*(sinφ*sinφ))); // Bennett equation 4.
+ final double S;
+ if (abs(φ1 - φ2) < LATITUDE_THRESHOLD) {
+ final double φm = (φ1 + φ2)/2;
+ final double sinφ = sin(φm);
+ S = Δλ * cos(φm) / (sin(azimuth) * sqrt(1 - eccentricitySquared*(sinφ*sinφ))); // Bennett equation 4.
+ } else {
+ final double m1 = m(φ1);
+ final double m2 = m(φ2);
+ S = (m2 - m1) / cos(azimuth);
+ if (STORE_LOCAL_VARIABLES) {
+ store("m₁", m1);
+ store("m₂", m2);
+ store("Δm", m2 - m1);
+ }
}
rhumblineLength = S * (semiMinor / axisRatio); // TODO: compute semiMajor only once.
if (STORE_LOCAL_VARIABLES) {
@@ -963,9 +970,6 @@ class GeodesicsOnEllipsoid extends GeodeticCalculator {
store("Ψ₁", Ψ1);
store("Ψ₂", Ψ2);
store("ΔΨ", ΔΨ);
- store("m₁", m1);
- store("m₂", m2);
- store("Δm", m2 - m1);
store("C", azimuth);
}
}
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodesicsOnEllipsoidTest.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodesicsOnEllipsoidTest.java
index aa4ad94..80c27a1 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodesicsOnEllipsoidTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodesicsOnEllipsoidTest.java
@@ -507,7 +507,7 @@ public final strictfp class GeodesicsOnEllipsoidTest extends GeodeticCalculatorT
}
/**
- * Tests {@link GeodesicsOnEllipsoid#getRhumblineLength()} using the example given in Bennett (1996) appendix.
+ * Tests {@link GeodesicsOnEllipsoid#getRhumblineLength()} using the example 1 given in Bennett (1996) appendix.
*/
@Test
public void testRhumblineLength() {
@@ -533,4 +533,37 @@ public final strictfp class GeodesicsOnEllipsoidTest extends GeodeticCalculatorT
assertValueEquals("C", 0, 54.9900, 1E-4, true);
assertEquals("distance", 4507.7 * NAUTICAL_MILE, distance, 0.05 * NAUTICAL_MILE);
}
+
+ /**
+ * Tests {@link GeodesicsOnEllipsoid#getRhumblineLength()} using the example 3 given in Bennett (1996) appendix.
+ */
+ @Test
+ public void testRhumblineNearlyEquatorial() {
+ createTracked();
+ verifyParametersForWGS84();
+ testedEarth.setStartGeographicPoint(-52-47.8/60, -97-31.6/60);
+ testedEarth.setEndGeographicPoint (-53-10.8/60, -41-34.6/60);
+ final double distance = testedEarth.getRhumblineLength();
+ assertValueEquals("Δλ", 0, 55+57.0 / 60, 1E-11, true);
+ assertValueEquals("Ψ₁", 0, -3725.18 / (10800/PI), 1E-5, false);
+ assertValueEquals("Ψ₂", 0, -3763.30 / (10800/PI), 1E-5, false);
+ assertValueEquals("ΔΨ", 0, -38.12 / (10800/PI), 1E-5, false);
+ assertValueEquals("C", 0, 90.6505, 1E-4, true);
+ assertEquals("distance", 2028.9 * NAUTICAL_MILE, distance, 0.05 * NAUTICAL_MILE);
+ }
+
+ /**
+ * Tests {@link GeodesicsOnEllipsoid#getRhumblineLength()} using the example 4 given in Bennett (1996) appendix.
+ */
+ @Test
+ public void testRhumblineEquatorial() {
+ createTracked();
+ verifyParametersForWGS84();
+ testedEarth.setStartGeographicPoint(48+45.0/60, -61-31.1/60);
+ testedEarth.setEndGeographicPoint (48+45.0/60, 5+13.2/60);
+ final double distance = testedEarth.getRhumblineLength();
+ assertValueEquals("Δλ", 0, 4004.3 / 60, 1E-11, true);
+ assertValueEquals("C", 0, 90.0, 1E-4, true);
+ assertEquals("distance", 2649.9 * NAUTICAL_MILE, distance, 0.1 * NAUTICAL_MILE);
+ }
}