From cb22bbde55cdcc96a66889ef6716834eeb5ff9b8 Mon Sep 17 00:00:00 2001 From: Kangning Li Date: Sun, 14 Mar 2021 23:32:28 -0400 Subject: [PATCH 1/2] return first position when interpolating rhumblines at surface distance 0.0 --- Source/Core/EllipsoidRhumbLine.js | 4 ++++ Specs/Core/EllipsoidRhumbLineSpec.js | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/Source/Core/EllipsoidRhumbLine.js b/Source/Core/EllipsoidRhumbLine.js index bb341486083b..d7a6900fb2a8 100644 --- a/Source/Core/EllipsoidRhumbLine.js +++ b/Source/Core/EllipsoidRhumbLine.js @@ -300,6 +300,10 @@ function interpolateUsingSurfaceDistance( ellipticity, result ) { + if (distance === 0.0) { + return Cartographic.clone(start, result); + } + var ellipticitySquared = ellipticity * ellipticity; var longitude; diff --git a/Specs/Core/EllipsoidRhumbLineSpec.js b/Specs/Core/EllipsoidRhumbLineSpec.js index 1611e459d733..f02308e8f92a 100644 --- a/Specs/Core/EllipsoidRhumbLineSpec.js +++ b/Specs/Core/EllipsoidRhumbLineSpec.js @@ -1,3 +1,4 @@ +import { Cartesian3 } from "../../Source/Cesium.js"; import { Cartographic } from "../../Source/Cesium.js"; import { Ellipsoid } from "../../Source/Cesium.js"; import { EllipsoidGeodesic } from "../../Source/Cesium.js"; @@ -1023,4 +1024,27 @@ describe("Core/EllipsoidRhumbLine", function () { ) ).toBe(true); }); + + it("returns the start point when interpolating at surface distance 0.0", function () { + var p0 = new Cartesian3( + 899411.2767873341, + -5079219.747324299, + 3738850.924729517 + ); + var p1 = new Cartesian3( + 899411.0994891181, + -5079219.778719673, + 3738850.9247295167 + ); + + var ellipsoid = Ellipsoid.WGS84; + var c0 = ellipsoid.cartesianToCartographic(p0, new Cartographic()); + var c1 = ellipsoid.cartesianToCartographic(p1, new Cartographic()); + var rhumb = new EllipsoidRhumbLine(c0, c1, ellipsoid); + + var c = rhumb.interpolateUsingSurfaceDistance(0.0, new Cartographic()); + var p = ellipsoid.cartographicToCartesian(c, new Cartesian3()); + + expect(p).toEqualEpsilon(p0, CesiumMath.EPSILON7); + }); }); From 9b02112fccc7d8369d6b3ad66161b36b00b27ce1 Mon Sep 17 00:00:00 2001 From: Kangning Li Date: Mon, 15 Mar 2021 09:40:58 -0400 Subject: [PATCH 2/2] update CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index f973fdd66393..bf161ba8a959 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,6 +11,7 @@ ##### Fixes :wrench: - Fixed a regression in 1.79 that broke terrain exaggeration. [#9397](https://github.com/CesiumGS/cesium/pull/9397) +- Fixed an issue where interpolating certain small rhumblines with surface distance 0.0 would not return the expected result. [#9430](https://github.com/CesiumGS/cesium/pull/9430) ### 1.79 - 2021-03-01