Skip to content

Commit

Permalink
Merge pull request #9430 from CesiumGS/rhumblineDistance0
Browse files Browse the repository at this point in the history
Return first position when interpolating rhumblines at surface distance 0.0
  • Loading branch information
lilleyse authored Mar 15, 2021
2 parents ab3dc91 + 9b02112 commit 56ab450
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions Source/Core/EllipsoidRhumbLine.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,10 @@ function interpolateUsingSurfaceDistance(
ellipticity,
result
) {
if (distance === 0.0) {
return Cartographic.clone(start, result);
}

var ellipticitySquared = ellipticity * ellipticity;

var longitude;
Expand Down
24 changes: 24 additions & 0 deletions Specs/Core/EllipsoidRhumbLineSpec.js
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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);
});
});

0 comments on commit 56ab450

Please sign in to comment.