How do you add meter offset to
I have a data file that I’m iterating over, it has 6 DOF data in it, but the latitude, longitude, altitude data from the source file is in meter offsets from origin. So basically, in the beginning everything in the source file starts out at 0,0,0. Over time, the values increase in meters.
I thought I could just add the meter data to the original lat/long/alt but that does not seem to work as I had hoped.
curLat = CesiumGeoreference->OriginLatitude + curSourcePoint.DOF_Latitude;
curLng = CesiumGeoreference->OriginLongitude + curSourcePoint.DOF_Longitude;
curAlt = CesiumGeoreference->OriginHeight + curSourcePoint.DOF_Altitude;
then run it through
glm::dvec3 ueCoords = this->CesiumGeoreference->TransformLongitudeLatitudeHeightToUnreal( glm::dvec3( curLat, curLng, curAlt) );
But, I’m getting some WAY off numbers out of that. So, my question is pretty simple, I hope, how do you add meter offset values to a CesumgeoReference original lat/long/alt
You’ll probably need to be a bit clearer about what exactly these meter offsets from the origin represent. For example, a longitude offset in meters… We can assume that a value of 1000 here means 1000 meters East of the origin. But does that follow Earth curvature as well? Imagine a vector at the origin that points East. If we follow that vector for 1000 meters, we’ll end up at a higher altitude above the Earth than we started, because of the Earth curvature. So maybe we travel 1000 meters East but maintain a constant altitude by following a curved path? Or maybe 1000 meters doesn’t even really mean meters. If these are Easting and Northing values, then we’re talking about “meters” in a projected coordinate system roughly based on meters at the equator (I think, it may depend on the projection), so a single projected meter at a higher latitude will be less than a meter in the real world.
So, it’s essential to define the meaning of your coordinate system precisely before we can try to use them in computations.
Basically, wherever the CesiumgeoReference is, I need to start from there and fly a drone. My file consists of thousands of points in it. Each point will contain a new offset in meters from the drones start point.
I have it working in a flat UE level no problem, but now I need to modify it so that we can use it with cesium. Follow the curvature of the earth. Realistically, we could probably do it all in one tile, or even in a UE level, but we want to use a Cesium map/world.
So, if I have a CesiumgeoRef object and original data is at
Original Latitude : -37.766681
Original Longitude : 144.93267
Original Altitude : 25
I need to be able to add from that start point, a new offset in meters for each new data point I get out of the pre recorded file.
So, my first point I may have an offset of 1.2 meters lat, .0567 meters long and maybe 1.4 meters altitude.
Then the next data point will build on that. Every row in the file has a different offset from origin for each of the DOF.
Does that help clarify? Do you guys have a built in function to do this? Add an offset for each value?
No, you haven’t resolved the ambiguity. But if you don’t care too much about the details needed to achieve precise locations, it’s easy to do: just add your offsets after you convert to Unity coordinates.
// Note that longitude is first!
// Also note that this is just going to return (0.0, 0.0, 0.0)
// because the whole point of the CesiumGeoreference is to make the
// given longitude/latitude/height the origin of the UE coordinate system.
glm::dvec3 ueOrigin = this->CesiumGeoreference->TransformLongitudeLatitudeHeightToUnreal(glm::dvec3(
// UE coordinates are East (X), South (Y), Up (Z)
glm::dvec3 ueOffset =
curSourcePoint.DOF_Altitude) * 100.0;
Now you can use that
ueOffset as the coordinates of the object in Unreal world coordinates.
* 100.0 is necessary because UE coordinates are in centimeters, whereas your offsets are in meters.
The negative sign on the latitude is necessary because latitude is positive to the North but the UE coordinate Y axis is positive to the South.