Cartesian 3 to Cartographic coordinates

3,374 views
Skip to first unread message

lydi...@visionistinc.com

unread,
Sep 27, 2013, 9:05:59 AM9/27/13
to cesiu...@googlegroups.com
Is there a way to convert cartesian3 coordinates to cartographic?

I am trying to get the position of billboards that are placed on my map, but I want to see the position in lat/long coordinates.

Thanks for your help,
Lydia

Kevin Ring

unread,
Sep 27, 2013, 9:17:45 AM9/27/13
to cesiu...@googlegroups.com



--
You received this message because you are subscribed to the Google Groups "cesium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cesium-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

lydi...@visionistinc.com

unread,
Sep 27, 2013, 10:29:01 AM9/27/13
to cesiu...@googlegroups.com, lydi...@visionistinc.com
Thank you for your quick reply. I am now running into some problems.

I currently have the latitude, longitude, and height coordinates separated into individual variables. To combine them into one (create a Cartographic element), I am using:

var billboardPosition = Cesium.Cartographic.fromDegrees(lat, long, height);

However, now, when I try converting it back to cartesian, using Cesium.Ellipsoid.cartographicToCartesian(billboardPosition), I am getting the error: 'uncaught exception: DeveloperError: scalar is required and must be a number'. I believe this is because when the Cartographic object is created, it prints like:

({longitude: -1.6360035916051352, latitude: 0.656140155737535, height: "0"})

Why is the height surrounded by quotations? Is that why Cesium thinks it's not scalar?

Thanks, again!
Lydia

Kevin Ring

unread,
Sep 27, 2013, 10:52:29 AM9/27/13
to cesiu...@googlegroups.com
Yes, I think you're right that the "0" is the problem.  Check your "height" variable.  Is it a string for some reason?

Also, fromDegrees takes longitude as the first parameter, not latitude.

Kevin


lydi...@visionistinc.com

unread,
Sep 27, 2013, 11:25:22 AM9/27/13
to cesiu...@googlegroups.com, lydi...@visionistinc.com
Thank you. I was able to solve the problem. :)

I also have another (unrelated) question about setting the color for a billboard. When a user clicks on a billboard (b1), I want to change the color of it to red. However, when the user clicks on another billboard (b2) on the same map, I want b1 to change back to it's original color. This is my code so far:

oldColor = billboard.getColor();
billboard.setColor({
red : 1.0,

On Friday, September 27, 2013 9:05:59 AM UTC-4, lydi...@visionistinc.com wrote:

lydi...@visionistinc.com

unread,
Sep 27, 2013, 11:27:19 AM9/27/13
to cesiu...@googlegroups.com, lydi...@visionistinc.com
Sorry! I didn't get to finish. Here's my code:

oldColor = billboard.getColor();
billboard.setColor({
red : 1.0,

green : 0.0,
blue : 0.0,
alpha: 1.0
})

and then in a later part, I have:
billboard.setColor(oldColor);

However, there is no change on my map. Do you know why this is?

Thank you!!
Lydia

Kevin Ring

unread,
Sep 27, 2013, 11:29:42 AM9/27/13
to cesiu...@googlegroups.com
getColor returns a reference to the color.  Then, when you set a new color, that instance gets overwritten with the new value.  In other words, oldColor changes to red when you call setColor.  To fix it, make a copy.

oldColor = billboard.getColor.clone();



Kevin Ring

unread,
Sep 27, 2013, 11:30:03 AM9/27/13
to cesiu...@googlegroups.com
Oops, that should be:

oldColor = billboard.getColor().clone();

lydi...@visionistinc.com

unread,
Sep 27, 2013, 11:36:52 AM9/27/13
to cesiu...@googlegroups.com
Thank you!! You've been a great help! :)

Lydia
Reply all
Reply to author
Forward
0 new messages