GPX coordinates to overlay route onto cesium map

Hi there! I’m a Unity XR developer but new to the world of geodata :slight_smile:

I would like to prototype a fun idea where I load in a GPX file, and then parse it to get all the coordinates of my route to overlay it onto the world terrain. My question is A) is there GPX support B) if not, is there a way I can visualize these points seperately somehow? What would be the best way to do so? Is there slmething like world terrain coordinate points?

Thanks!!

I tried parsing my GPX file to get the coordinates, assigning the Cesium Globe Anchor to my objects and folling in the coordinates but not the height, which remains at zero. Is there something I potentially missed?

Hi @xrdevrob, welcome to the community!

There’s no built-in support for GPX, so you’ll either need to develop that bit or find a library that can do it (I’d imagine such a thing exists in the C# ecosystem, but I haven’t looked myself).

I believe the GPX contains longitude / latitude / height, so you’ll next need to convert those to Unity world coordinates. That process has been covered many times in this forum, but the gist of it is to use CesiumWgs84Ellipsoid.LongitudeLatitudeHeightToEarthCenteredEarthFixed to convert the longitude / latitude / height to ECEF (note that longitude is first!) and then pass the ECEF coordinates to the TransformEarthCenteredEarthFixedPositionToUnity method on your CesiumGeoreference instance.

Once you have the Unity world coordinates, you can visualize the points using whatever you like from the normal Unity bag of tricks.

2 Likes