Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cartographic to cartesian3 method #6163

Merged

Conversation

hanbollar
Copy link

oneliner method to shorten conversion from cartographic to cartesian3.

inside the method just calls fromRadians - instead of needing to input the cartographic values into the fromRadians specifically

@cesium-concierge
Copy link

Signed CLA is on file.

@hanbollar, thanks for the pull request! Maintainers, we have a signed CLA from @hanbollar, so you can review this at any time.

⚠️ I noticed that CHANGES.md has not been updated. If this change updates the public API in any way, fixes a bug, or makes any non-trivial update, please add a bullet point to CHANGES.md and comment on this pull request so we know it was updated. For more info, see the Pull Request Guidelines.


I am a bot who helps you make Cesium awesome! Contributions to my configuration are welcome.

🌍 🌎 🌏

@ggetz
Copy link
Contributor

ggetz commented Jan 26, 2018

Thanks @hanbollar! Please update CHANGES.md and add a test.

@mramato
Copy link
Contributor

mramato commented Jan 26, 2018

Please don't merge this until we take a closer look at the implications. While it appears like a small change, it actually creates a circular dependency and the built version of cesium will most likely have issues. Cartographic requires in scaleToGeodeticSurface, which requires in Cartesian3, which requires in Cartographic. There's a reason we never added this function.

@lilleyse
Copy link
Contributor

lilleyse commented Jan 26, 2018

For reference, this was the PR that added Cartographic.fromCartesian: #3193

Maybe the same ideas apply here?

@hanbollar
Copy link
Author

@mramato Thanks for the feedback! I swapped the location of this conversion method from the Cartesian3 file to the Cartographic file to bypass the circular include issue.

*/
Cartographic.toCartesian3 = function(cartographic, ellipsoid, result) {
//>>includeStart('debug', pragmas.debug);
if (!defined(cartographic)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block can be replaced with Check.defined('cartographic', cartographic), which is out new way of doing parameter checking.

/**
* Returns a Cartesian3 position from a {@link Cartographic} input.
*
* @param {Cartographic} Cartographic input to be converted into a Cartesian3 output.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lowercase c.

@hanbollar
Copy link
Author

@mramato Updated following your comments.

@@ -27,6 +27,16 @@ defineSuite([
expect(c.height).toEqual(3);
});

it('toCartesian3', function(){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

explain what your test is supposed to do: toCartesian3 converts a Cartographic to a Cartesian3

@@ -146,6 +146,22 @@ define([
return result;
};

/**
* Returns a Cartesian3 position from a {@link Cartographic} input.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creates a new {@link Cartesian3} instance from a Cartographic.

No need to link to Cartographic, we're already in that class.

@hanbollar
Copy link
Author

@ggetz Updated with your recommended changes.

* @param {Cartesian3} [result] The object onto which to store the result.
* @returns {Cartesian3} The position
*/
Cartographic.toCartesian3 = function(cartographic, ellipsoid, result) {
Copy link
Contributor

@ggetz ggetz Jan 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more thing, let's be consistent with fromCartesian and call this toCartesian. Also keep the wording consistent with the other functions, see https://github.com/AnalyticalGraphicsInc/cesium/pull/6163/files#diff-f2664d42919c57ae2aa0b2575097bb56R54 and https://github.com/AnalyticalGraphicsInc/cesium/pull/6163/files#diff-f2664d42919c57ae2aa0b2575097bb56R82

@hanbollar
Copy link
Author

@ggetz Thanks for the feedback - added commits to match previous conventions better

@ggetz
Copy link
Contributor

ggetz commented Jan 26, 2018

Thanks @hanbollar, I'll merge when the build passes.

@hpinkos hpinkos changed the title Add cartesian3 from cartographic method Add cartographic to cartesian3 method Jan 26, 2018
@ggetz ggetz merged commit 4a113c9 into CesiumGS:master Jan 26, 2018
@hanbollar hanbollar deleted the add-cartesian3-from-cartographic-method branch February 2, 2018 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants