Commit 7a855d8f authored by Lefebvre, Jordan's avatar Lefebvre, Jordan
Browse files

Adding toString helper for UTMCoordinate.

parent de9e42ba
Pipeline #12911 failed with stages
in 6 minutes and 15 seconds
......@@ -25,9 +25,8 @@ const std::array<char, 11> UTMZones::pos_letters = {
const std::array<short, 11> UTMZones::pos_degrees = {
{0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 84}};
const std::array<char, 11>
UTM2LatLon::southern_hemisphere = {
{'A', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'L', 'L', 'M'}};
const std::array<char, 11> UTM2LatLon::southern_hemisphere = {
{'A', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'L', 'L', 'M'}};
short UTMZones::latZoneDegree(char letter)
{
auto itr = std::find(letters.begin(), letters.end(), letter);
......@@ -136,8 +135,7 @@ double LatLon2UTM::easting() const
return 500000. + (m_K4 * m_p + m_K5 * std::pow(m_p, 3.));
}
UTMCoordinate LatLon2UTM::toUTM(
double latitude, double longitude)
UTMCoordinate LatLon2UTM::toUTM(double latitude, double longitude)
{
CoordinateConversion::validate(latitude, longitude);
UTMCoordinate utm;
......@@ -212,6 +210,14 @@ void CoordinateConversion::validate(const std::pair<double, double>& point)
CoordinateConversion::validate(point.first, point.second);
}
std::string CoordinateConversion::toString(const UTMCoordinate& utm)
{
char buff[120];
sprintf(buff, "%02d %c %f %f", utm.longitude_zone, utm.lattitude_zone,
utm.easting, utm.northing);
return std::string(buff);
}
void CoordinateConversion::validate(double latitude, double longitude)
{
radix_tagged_line("Validating (" << latitude << "," << longitude << ")");
......@@ -226,8 +232,7 @@ void CoordinateConversion::validate(double latitude, double longitude)
}
}
void UTM2LatLon::init(
const UTMCoordinate& utm)
void UTM2LatLon::init(const UTMCoordinate& utm)
{
m_arc = utm.northing / m_k0;
m_mu = m_arc /
......@@ -289,8 +294,7 @@ char UTM2LatLon::hemisphere(char latitude_zone)
}
}
std::pair<double, double> UTM2LatLon::toLatLon(
const UTMCoordinate& c)
std::pair<double, double> UTM2LatLon::toLatLon(const UTMCoordinate& c)
{
UTMCoordinate utm = c;
double latitude = 0.;
......
......@@ -12,6 +12,20 @@
namespace radix
{
struct RADIX_PUBLIC UTMCoordinate
{
// earth radius is ~40million meteres
// int will cover this
double easting;
double northing;
// 00 -> 60 longitude zones
short longitude_zone;
// Not officially part of UTM
// but frequently used with UTM
// C - > X, (A,B,Y,Z) are not used as they cover western and eastern sides
// of the Antarctic and Arctic regions
char lattitude_zone;
};
class RADIX_PUBLIC CoordinateConversion
{
public:
......@@ -32,21 +46,14 @@ class RADIX_PUBLIC CoordinateConversion
static void validate(const std::pair<double, double>& point);
/**
* @brief toString Converts UTM coordinate to string representation
* @param utm
* @return std::string "11 S 400000 5500"
*/
static std::string toString(const UTMCoordinate& utm);
}; // class CoordinateConversion
struct RADIX_PUBLIC UTMCoordinate
{
// earth radius is ~40million meteres
// int will cover this
double easting;
double northing;
// 00 -> 60 longitude zones
short longitude_zone;
// Not officially part of UTM
// but frequently used with UTM
// C - > X, (A,B,Y,Z) are not used as they cover western and eastern sides
// of the Antarctic and Arctic regions
char lattitude_zone;
};
class RADIX_PUBLIC UTMZones
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment