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/09 10:37:09 UTC
[sis] 05/05: Make computation of rhumb line robust to the case where longitude difference is greater than 180°. Minor formatting.
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 101aa25a27bc44d5cbec31129b9ff38dbb4dd537
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Fri Aug 9 12:35:28 2019 +0200
Make computation of rhumb line robust to the case where longitude difference is greater than 180°.
Minor formatting.
---
.../org/apache/sis/referencing/GeodesicsOnEllipsoid.java | 2 +-
.../org/apache/sis/referencing/GeodeticCalculator.java | 15 +++++++++------
2 files changed, 10 insertions(+), 7 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 4c83231..354b678 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
@@ -971,7 +971,7 @@ class GeodesicsOnEllipsoid extends GeodeticCalculator {
final double sd = eccentricity * (sinφ1 - sinφ2);
final double sm = 1 - eccentricitySquared * (sinφ1 * sinφ2);
final double ΔΨ = log(tan(PI/4 + φ2/2) / tan(PI/4 + φ1/2) * pow((sm+sd)/(sm-sd), eccentricity/2));
- final double Δλ = λ2 - λ1;
+ final double Δλ = IEEEremainder(λ2 - λ1, 2*PI);
final double h = hypot(Δλ, ΔΨ);
final double S;
if (abs(φ1 - φ2) < LATITUDE_THRESHOLD) {
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 e860382..6efeac8 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
@@ -607,7 +607,7 @@ public class GeodeticCalculator {
*/
void computeRhumbLine() {
canComputeDistance();
- final double Δλ = λ2 - λ1;
+ final double Δλ = IEEEremainder(λ2 - λ1, 2*PI);
final double Δφ = φ2 - φ1;
final double factor;
if (abs(Δφ) < LATITUDE_THRESHOLD) {
@@ -867,12 +867,15 @@ public class GeodeticCalculator {
*/
PathBuilder(final double εx) {
super(ReferencingUtilities.getDimension(userToGeodetic.defaultCRS));
- msinαf = msinα2; λf = λ2;
- mcosαf = mcosα2; φf = φ2;
+ φf = φ2;
+ λf = λ2;
+ msinαf = msinα2;
+ mcosαf = mcosα2;
tolerance = toDegrees(εx / semiMajorAxis);
distance = geodesicDistance;
length = rhumblineLength;
- flags = validity;
+ flags = validity & (START_POINT | STARTING_AZIMUTH | END_POINT | ENDING_AZIMUTH |
+ GEODESIC_DISTANCE | RHUMBLINE_LENGTH);
}
/**
@@ -936,8 +939,8 @@ public class GeodeticCalculator {
* Restores the enclosing {@link GeodeticCalculator} to the state that it has at {@code PathBuilder} instantiation time.
*/
void reset() {
- msinα2 = msinαf; λ2 = λf;
- mcosα2 = mcosαf; φ2 = φf;
+ λ2 = λf; msinα2 = msinαf;
+ φ2 = φf; mcosα2 = mcosαf;
geodesicDistance = distance;
rhumblineLength = length;
validity = flags;