Agrarsense
CoordinateConversionUtilities.cpp
Go to the documentation of this file.
1// Copyright (c) 2023 FrostBit Software Lab at the Lapland University of Applied Sciences
2//
3// This work is licensed under the terms of the MIT license.
4// For a copy, see <https://opensource.org/licenses/MIT>.
5
7
8FGeographicCoordinates UCoordinateConversionUtilities::UnrealToGeographicCoordinates(AGeoReferencingSystem* GeoReferencingSystem, const FVector& Position)
9{
10 FGeographicCoordinates GeographicCoordinates;
11
12 if (GeoReferencingSystem)
13 {
14 // Convert FVector position to FGeographicCoordinates
15 FVector ProjectedCoordinates;
16 GeoReferencingSystem->EngineToProjected(Position, ProjectedCoordinates);
17 GeoReferencingSystem->ProjectedToGeographic(ProjectedCoordinates, GeographicCoordinates);
18 }
19
20 return GeographicCoordinates;
21}
22
23FVector UCoordinateConversionUtilities::GeographicToUnrealCoordinates(AGeoReferencingSystem* GeoReferencingSystem, const FGeographicCoordinates& GeographicCoordinates)
24{
25 FVector UnrealCoordinates;
26
27 if (GeoReferencingSystem)
28 {
29 // Convert FGeographicCoordinates to FVector position
30 FVector ProjectedCoordinates;
31 GeoReferencingSystem->GeographicToProjected(GeographicCoordinates, ProjectedCoordinates);
32 GeoReferencingSystem->ProjectedToEngine(ProjectedCoordinates, UnrealCoordinates);
33 }
34
35 return UnrealCoordinates;
36}
static FGeographicCoordinates UnrealToGeographicCoordinates(AGeoReferencingSystem *GeoReferencingSystem, const FVector &Position)
static FVector GeographicToUnrealCoordinates(AGeoReferencingSystem *GeoReferencingSystem, const FGeographicCoordinates &GeographicCoordinates)