Does cesium have a utility type function that allows you to generate a cesium location (FVector) from a given latitude, longitude and height/altitude values?
I was thinking about using the Georeference object at runtime to set it’s location using the SetGeorferenceOriginLogitudeLatitudeHeight() to set it’s origin, then use the
Georeference->OriginLongitude
Georeference->OriginLatitude
Georeference->OriginHeight
values to create an FVector from that…
But, that seems like a lot of overhead. Was hoping for more of an easier approach utility function.
It’s impossible for me to say with the information you’ve provided. You haven’t told me how you implemented CreateCesiumLocationVectorFromCoords, so I can’t check that for correctness. And you haven’t told me where your CesiumGeoreference is located, so it’s impossible to say if the coordinate value it has computed, which are relative to the georeference origin, are correct.
Really sorry about that, I cut and pasted the wrong bit of code…
As you can see here, my function is just a wrapper around the cesium function you told me about.
ACesiumUtility is a small AActor class I created to wrap some of the Cesium functionality. It has a pointer references to the geo reference, sunsky, and tileset. This class was turned into a Blueprint, dragged onto the scene and populated from the various cesium variables created through the Unreal Engine Cesium panel.
The function I posted above is from another class that uses the ACesiumUtility wrapper class, I am feeding in a real world GPS coordinate value that we have when I call this function.
// Take a real world location and convert it to a cesium location
FVector ACesiumUtility::CreateCesiumLocationVectorFromCoords(float Longitude, float latitude, float altitude)
{
return CesiumGeoreference->TransformLongitudeLatitudeHeightToUnreal(FVector(Longitude, latitude, altitude));
}
I’d recommend using double instead of float for longitude / latitude / height. But otherwise that looks like it should work just fine.
I’m not sure where you’re getting your height values, but make sure they’re ellipsoidal heights, not geoid / mean sea level heights. The two can be tens of meters different, depending on where you are in the world.
Other than that, I’m not sure why your debug spheres aren’t showing up. You may have to share more of that code.
Hi Kevin,
The data we get is from a different source, they give us lat/lng/alt data in float format. Which is why I used float variables. There is really nothing I can do about that. However, I will make note of it for future reference in case I can influence some data type decisions down the road.
Oh and the reason the spheres were not showing up is because when trying to draw a debug sphere you need to supply a UWorldObject to the function… I was using GetWorld(). It was returning null for some reason, so I ended up using a different objects GetWorld() function. When I did that, my spheres started drawing correctly.
EDIT
Learned a valuable lesson… Was having a lot of issues with my heights not being right. I forgot one important step… Convert feet to meters. My altitudes/heights were in feet, not meters, as soon as I made the feet to meter calculation on each FVector, my objects starting showing up in the right locations.