CesiumGeoreference - jgoffeney/Cesium4Unreal GitHub Wiki

Back

Description

It is an Actor that handles mapping of the geospatial coordinates to the Unreal Engine level coordinates based on the ECEF coordinate system. It is passed into other Cesium Actor classes like DynamicPawn and Cesium3DTileset.

Coordinate Systems

East-North-Up (ENU) Coordinates

The ENU coordinate system uses Cartesian coordinates where the origin is defined by geodetic coordinates (latitude, longitude, height). The geodetic height is the distance from the point to the surface of the ellipsoid. The east and north axes are aligned with the latitude parallel and longitude meridian and Up is in meters along a normal on the ellipsoid.

Earth-Centered Earth-Fixed (ECEF) Coordinates

The ECEF coordinate system is a Cartesian system in meters where the origin is the center of the ellipsoid. The X axis passes through latitude and longitude coords of (0,0) and the Y coords of (0, 90). The Z axis passes through the north pole.

Unreal Coordinates

The Unreal coordinate system is a Cartesian system that is unique among 3D systems in that it is a left hand / Z up system. It uses centimeters as the unit.

Conversions

Cartographic

A simple struct to hold:

  • longitude in radians
  • latitude in radians
  • height in meters

Ellipsoid

The WGS84 Cesium Ellipsoid is defined with the radii (6378137.0, 6378137.0, 6356752.3142451793). On construction it initializes the following:

  • _double radii: the tuple of the initial radii
  • _double radiiSquared: the tuple of the initial radii squared
  • _double oneOverRadii: the tuple of the reciprocals of the radii
  • _double oneOverRadiiSquared: the tuple of the reciprocals of the radii squared
  • _double centerToleranceSquared: the value of 0.1

GeoTransforms

A basic class to perform geospatial coordinate transforms.

  • Initial Values
    • _Ellipsoid ellipsoid: the WGS84 ellipsoid
    • _glm:dvec3 center: the center coordinate as (0.0, 0.0, 0.0) or the provided origin
    • _glm::dmat4 georeferencedToEcef: an identity matrix
    • _glm::dmat4 ecefToGeoreferenced: an identity matrix
    • _glm::dmat4 ueAbsToEcef: an identity matrix
    • _glm::dmat4 ecefToUeAbs: an identity matrix
  • Updated Transforms

GeoTransforms.TransformLongitudeLatitudeHeightToEcef

Ellipsoid::geodeticSurfaceNormal

Find the normal vector from the center of the earth through the surface geospatial coordinate

  • Inputs
    • Cartographic
  • Function
    • cosLatitude = cos(Cartographic.latitude)
    • glm::vec3
      • X: cosLatitude * cos(Cartographic.longitude)
      • Y: cosLatitude * sin(Cartographic.longitude)
      • Z: sin(Cartographic.latitude)
  • Return
    • glm::dvec3 normalize(vector)
Ellipsoid::cartographicToCartesian

Convert the geospatial coordinates in radians / meters to Cartesian values

  • Inputs
    • Cartographic
  • Function
    • glm::dvec3 n = geodeticSurfaceNormal(Cartographic.longitude, Cartographic.latitude, Cartographic.height)
    • glm::dvec3 k = Ellisoid._radiiSquared * n
    • double gamma = sqrt(dot(n, k))
    • k /= gamma
    • n*= Cartographic.height
  • Return
    • glm::dvec3 k + n

GeoTransforms::TransformEcefToUnreal

  • Inputs
    • glm::dvec3 origin
    • glm::dvec3 ecef
  • Function
  • Return

Functions

GetDefaultGeoreference

Only a single instance is required for an application and the following statement will either get an existing instance of CesiumGeoreference or create a new one if it does not exist. The parameter is a UObject.

ACesiumGeoreference* geoReference = ACesiumGeoreference::GetDefaultGeoreference(this);

SetGeoreferenceOrigin

Takes a geospatial coordinate and moves the globe to set the Unreal origin to its location. It can be useful for accuracy to work near the Unreal origin rather than keeping the origin static and working millions of kilometers away.

TransformLongitudeLatitudeHeightToUnreal

Converts a vector of longitude, latitude and height to the Unreal x,y,z coordinates.

TransformUnrealToLongitudeLatitudeHeight

Converts a vector of Unreal x,y,z coordinates to longitude, latitude and height.

ComputeEastNorthUpToUnreal

Creates a rotation matrix to transform from the East-North-Up to Unreal

PlaceGeoreferenceOriginHere

Places the georeference origin at the camera's current location.