Skip to content

Commit 4a113c9

Browse files
authored
Merge pull request #6163 from hanbollar/add-cartesian3-from-cartographic-method
Add cartographic to cartesian3 method
2 parents 248adb2 + 1cb08f5 commit 4a113c9

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Change Log
4040
* Fixed sandcastle Particle System example for better visual [#6132](https://github.com/AnalyticalGraphicsInc/cesium/pull/6132)
4141
* Fixed camera movement and look functions for 2D mode [#5884](https://github.com/AnalyticalGraphicsInc/cesium/issues/5884)
4242
* Fixed discrepancy between default value used and commented value for default value for halfAxes of OrientedBoundingBox. [#6147](https://github.com/AnalyticalGraphicsInc/cesium/pull/6147)
43+
* Added `Cartographic.toCartesian` to convert from Cartographic to Cartesian3. [#6163](https://github.com/AnalyticalGraphicsInc/cesium/pull/6163)
4344

4445
### 1.41 - 2018-01-02
4546

Source/Core/Cartographic.js

+17
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,23 @@ define([
146146
return result;
147147
};
148148

149+
/**
150+
* Creates a new Cartesian3 instance from a Cartographic input. The values in the inputted
151+
* object should be in radians.
152+
*
153+
* @param {Cartographic} cartographic Input to be converted into a Cartesian3 output.
154+
* @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid on which the position lies.
155+
* @param {Cartesian3} [result] The object onto which to store the result.
156+
* @returns {Cartesian3} The position
157+
*/
158+
Cartographic.toCartesian = function(cartographic, ellipsoid, result) {
159+
//>>includeStart('debug', pragmas.debug);
160+
Check.defined('cartographic', cartographic);
161+
//>>includeEnd('debug');
162+
163+
return Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, cartographic.height, ellipsoid, result);
164+
};
165+
149166
/**
150167
* Duplicates a Cartographic instance.
151168
*

Specs/Core/CartographicSpec.js

+10
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ defineSuite([
2727
expect(c.height).toEqual(3);
2828
});
2929

30+
it('toCartesian conversion from Cartographic input to Cartesian3 output', function(){
31+
var lon = CesiumMath.toRadians(150);
32+
var lat = CesiumMath.toRadians(-40);
33+
var height = 100000;
34+
var ellipsoid = Ellipsoid.WGS84;
35+
var actual = Cartographic.toCartesian(new Cartographic(lon, lat, height));
36+
var expected = ellipsoid.cartographicToCartesian(new Cartographic(lon, lat, height));
37+
expect(actual).toEqual(expected);
38+
});
39+
3040
it('fromRadians works without a result parameter', function() {
3141
var c = Cartographic.fromRadians(Math.PI/2, Math.PI/4, 100.0);
3242
expect(c.longitude).toEqual(Math.PI/2);

0 commit comments

Comments
 (0)