Problem With "Build a Flight Tracker with Cesium for Unreal"

Hello everyone. I have been working through the tutorial to build a flight tracker in unreal using cesium. I’m using Unreal version 5.4.4 which I know is much newer than the version the tutorial uses, but everything has been working so far except for one thing. In the PlaneTrack.cpp file I am getting an error on the lines where we compute the position in Unreal coordinates. This is my full PlaneTrack.cpp:

// Fill out your copyright notice in the Description page of Project Settings.


#include "PlaneTrack.h"

// Sets default values
APlaneTrack::APlaneTrack()
{
 	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;

	// Initialize the track
	SplineTrack = CreateDefaultSubobject<USplineComponent>(TEXT("SplineTrack"));
	// This lets us visualize the spline in Play mode
	SplineTrack->SetDrawDebug(true);
	// Set the color of the spline
	SplineTrack->SetUnselectedSplineSegmentColor(FLinearColor(1.f, 0.f, 0.f));
}

// Called when the game starts or when spawned
void APlaneTrack::BeginPlay()
{
	Super::BeginPlay();
	
}

// Called every frame
void APlaneTrack::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

}

void APlaneTrack::LoadSplineTrackPoints()
{
    if (this->AircraftsRawDataTable != nullptr && this->CesiumGeoreference != nullptr)
    {
        int32 PointIndex = 0;
        for (auto& row : this->AircraftsRawDataTable->GetRowMap())
        {
            FAircraftRawData* Point = (FAircraftRawData*)row.Value;
            // Get row data point in lat/long/alt and transform it into UE4 points
            double PointLatitude = Point->Latitude;
            double PointLongitude = Point->Longitude;
            double PointHeight = Point->Height;

            // Compute the position in UE coordinates
            glm::uvec3 UECoords = this->CesiumGeoreference->TransformLongitudeLatitudeHeightPositionToUnreal(glm::uvec3(PointLongitude, PointLatitude, PointHeight));
            FVector SplinePointPosition = FVector(UECoords.x, UECoords.y, UECoords.z);
            this->SplineTrack->AddSplinePointAtIndex(SplinePointPosition, PointIndex, ESplineCoordinateSpace::World, false);

            // Get the up vector at the position to orient the aircraft
            const CesiumGeospatial::Ellipsoid& Ellipsoid = CesiumGeospatial::Ellipsoid::WGS84;
            glm::dvec3 upVector = Ellipsoid.geodeticSurfaceNormal(CesiumGeospatial::Cartographic(FMath::DegreesToRadians(PointLongitude), FMath::DegreesToRadians(PointLatitude), FMath::DegreesToRadians(PointHeight)));

            // Compute the up vector at each point to correctly orient the plane
            glm::dvec4 ecefUp(upVector, 0.0);
            const GeoTransforms& geoTransforms = this->CesiumGeoreference->GetGeoTransforms();
            const glm::dmat4& ecefToUnreal = geoTransforms.GetEllipsoidCenteredToAbsoluteUnrealWorldTransform();
            glm::dvec4 unrealUp = ecefToUnreal * ecefUp;
            this->SplineTrack->SetUpVectorAtSplinePoint(PointIndex, FVector(unrealUp.x, unrealUp.y, unrealUp.z), ESplineCoordinateSpace::World, false);

            PointIndex++;
        }
        this->SplineTrack->UpdateSpline();
    }
}


This specific line is where the error occurs:

glm::uvec3 UECoords = this->CesiumGeoreference->TransformLongitudeLatitudeHeightPositionToUnreal(glm::uvec3(PointLongitude, PointLatitude, PointHeight));

Visual studio is saying ‘no suitable user-defined conversion from “glm::uvec3” (aka “glm::vec<3Ui64, unsigned int, glm::packed_highp>”) to “const FVector” exists’

I already figured out that the TransformLongitudeLatitudeHeightToUnreal() function is deprecated and is now called TransformLongitudeLatitudeHeightPositionToUnreal(), so I made that change in my code but it still gives an error and won’t compile. Any help would be greatly appreciated.

Also, is there any potential for this tutorial to be updated to work better with UE5?

Hi @Tristan_Radeka, welcome to the community!

This line:

glm::uvec3 UECoords = this->CesiumGeoreference->TransformLongitudeLatitudeHeightPositionToUnreal(glm::uvec3(PointLongitude, PointLatitude, PointHeight));

Should read:

FVector UECoords = this->CesiumGeoreference->TransformLongitudeLatitudeHeightPositionToUnreal(FVector(PointLongitude, PointLatitude, PointHeight));

Now that the Unreal types are double-precision, we can use them directly in many cases, rather than using glm types.

We of course would like to update this tutorial for UE5, but I can’t promise a timeline for that.

Hi @Kevin_Ring thank you for your quick response, this helped a lot. By updating the code as you said and regenerating the visual studio project files I was able to get it to compile and the track is now displaying when I enter play mode. I continued with the tutorial and reached another issue. I have BP_Aircraft and the MoveAircraft event all set up, and the default variables initialized in the editor. When I press ‘M’ the aircraft actor seems to just disappear rather than start moving along the track.

Before Pressing M:

After Pressing M:

You can see that the aircraft is there in the scene before I trigger the event. To my understanding, once I trigger the event the aircraft should move to the beginning of the track and start moving along it. I think the issue is something with the MoveAircraft event, because it’s clearly doing something, just not what I expect. Here is my event graph in BP_Aircraft:

If you need to see anything else to help diagnose the problem let me know, and thanks again for your help!

I was actually able to solve my problem, I had the duration set too low and the timeline not set to looping, so it would play out so fast that I just couldn’t tell what was happening. Thanks again for the help Kevin!

1 Like