hivemind 1.0.0
Loading...
Searching...
No Matches
coordinate_converter.cpp
Go to the documentation of this file.
2
4{
5
6 // ResetOrigin will manage that rest of the function always work with the
7 // same origin. The size parameter represent the size of the coordinate
8 // system.
9 void
11 {
12 auto& instance = GetInstance();
13 instance.m_Size = size;
14 instance.m_OriginGeographical = { geoCoord.Latitude,
15 geoCoord.Longitude };
16 instance.m_Origin.Reset(geoCoord.Latitude, geoCoord.Longitude, 0);
17 }
18
19 // This function convert a geographical coordinate to a cartesian
20 // coordinate.
23 {
24 auto& instance = GetInstance();
25 double x, y, z;
26 instance.m_Origin.Forward(geoCoord.Latitude, geoCoord.Longitude, 0, x,
27 y, z);
28 return { x, y, z };
29 }
30
31 // This function convert a cartesian coordinate to a geographical coordinate
34 {
35 auto& instance = GetInstance();
36 double lat, lon, alt;
37 instance.m_Origin.Reverse(cartCoord.X, cartCoord.Y, cartCoord.Z, lat,
38 lon, alt);
39 return { lat, lon };
40 }
41
42 // This function return the origin to hivemind.
45 {
46 auto& instance = GetInstance();
47 return instance.m_OriginGeographical;
48 }
49
50 // This function convert from a symmetric coordinate system to an
51 // asynmmetric coordinate system. The size parameter represent the size of
52 // the coordinate system.
55 {
56 auto& instance = GetInstance();
57 symmetric.X = symmetric.X + (instance.m_Size / 2);
58 symmetric.Y = -symmetric.Y + (instance.m_Size / 2);
59 return symmetric;
60 }
61
62 // This function convert from an asymmetric coordinate system to a
63 // synmmetric coordinate system. The size parameter represent the size of
64 // the coordinate system.
67 {
68 auto& instance = GetInstance();
69 asymmetric.X = asymmetric.X - (instance.m_Size / 2);
70 asymmetric.Y = -asymmetric.Y + (instance.m_Size / 2);
71 return asymmetric;
72 }
73
74 // Hivemind are using UTM33N and therefore are this hardcoded in the call to
75 // geographiclib. For scalability and easier maintenance this should be able
76 // to configured.
79 {
80 Core::UTMCoordinate utmCoord;
81 GeographicLib::UTMUPS::Forward(GeoCoord.Latitude, GeoCoord.Longitude,
82 utmCoord.Zone,
83 utmCoord.IsNorthHemisphere,
84 utmCoord.Easting, utmCoord.Northing, 33);
85 return utmCoord;
86 }
87
88 // This function convert from UTM coordinates to geographical coordinates.
91 {
92 Core::GeographicalCoordinate geoCoord(0, 0);
93 GeographicLib::UTMUPS::Reverse(
94 UTMCoord.Zone, UTMCoord.IsNorthHemisphere, UTMCoord.Easting,
95 UTMCoord.Northing, geoCoord.Latitude, geoCoord.Longitude);
96 return geoCoord;
97 }
98
99} // namespace CoordinateConverter
static Core::GeographicalCoordinate UTMToGeographic(Core::UTMCoordinate UTMCoord)
Function used to convert a UTM coordinate to a geographical coordinate.
static void ResetOrigin(Core::GeographicalCoordinate geoCoord, int size)
Sets the origin coordinate to use with relative coordinates.
static Core::CartesianCoordinate SymmetricToAsymmetric(Core::CartesianCoordinate symmetric)
Function used to convert a coordinate in a symmetric coordinate system to a coordinate in an asymmetr...
static Core::UTMCoordinate GeographicToUTM(Core::GeographicalCoordinate GeoCoord)
Function used to convert a geographical coordinate to a UTM coordinate.
static Core::GeographicalCoordinate CartesianToGeographical(Core::CartesianCoordinate cartCoord)
\biref Function used to convert a cartesian coordinate to a geograpical coordinate
static Core::GeographicalCoordinate GetOrigin()
static Core::CartesianCoordinate AsymmetricToSymmetric(Core::CartesianCoordinate asymmetric)
Function used to convert a coordinate in an asymmetric cooridnate system to a coordinate in a symmetr...
static CoordConv & GetInstance()
Get the single instance of CoordConv.
static Core::CartesianCoordinate GeographicalToCartesian(Core::GeographicalCoordinate geoCoord)
Function used to convert a geographical coordinate to a cartesian coordinate.
A structure that represents a cartesian coordinate.
Definition: types.h:12
A structure that represents a geographic coordinate.
Definition: types.h:29
\ A structure that represents a coordinate in the Universal Transverse Mercator coordinate system
Definition: types.h:46
bool IsNorthHemisphere
Definition: types.h:56
double Easting
Definition: types.h:54
double Northing
Definition: types.h:54