Skip to content

Commit

Permalink
Merge pull request #4612 from duvifn/fix_Cartographic_fromCartesian
Browse files Browse the repository at this point in the history
Fix cartographic from cartesian
  • Loading branch information
pjcozzi authored Nov 7, 2016
2 parents 6e39f21 + ca73a33 commit d68b910
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,4 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu
* [Tom Payne](https://github.com/twpayne)
* [Leesa Fini](https://github.com/leesafini)
* [Victor Malaret](https://github.com/malaretv)
* [David Friedman](https://github.com/duvifn)
2 changes: 1 addition & 1 deletion Source/Core/Cartographic.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ define([
return undefined;
}

var n = Cartesian3.multiplyComponents(cartesian, oneOverRadiiSquared, cartesianToCartographicN);
var n = Cartesian3.multiplyComponents(p, oneOverRadiiSquared, cartesianToCartographicN);
n = Cartesian3.normalize(n, n);

var h = Cartesian3.subtract(cartesian, p, cartesianToCartographicH);
Expand Down
16 changes: 16 additions & 0 deletions Specs/Core/CartographicSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,22 @@ defineSuite([
}).toThrowDeveloperError();
});

it('fromCartesian works with a value that is above the ellipsoid surface', function() {
var cartographic1 = Cartographic.fromDegrees(35.766989, 33.333602, 3000);
var cartesian1 = Cartesian3.fromRadians(cartographic1.longitude, cartographic1.latitude, cartographic1.height);
var cartographic2 = Cartographic.fromCartesian(cartesian1);

expect(cartographic2).toEqualEpsilon(cartographic1, CesiumMath.EPSILON8);
});

it('fromCartesian works with a value that is bellow the ellipsoid surface', function() {
var cartographic1 = Cartographic.fromDegrees(35.766989, 33.333602, -3000);
var cartesian1 = Cartesian3.fromRadians(cartographic1.longitude, cartographic1.latitude, cartographic1.height);
var cartographic2 = Cartographic.fromCartesian(cartesian1);

expect(cartographic2).toEqualEpsilon(cartographic1, CesiumMath.EPSILON8);
});

it('clone without a result parameter', function() {
var cartographic = new Cartographic(1.0, 2.0, 3.0);
var result = cartographic.clone();
Expand Down

0 comments on commit d68b910

Please sign in to comment.