Apply clang-format

This commit is contained in:
Martchus 2017-05-01 03:40:44 +02:00
parent 6576f88608
commit 868f0fd2bd
7 changed files with 247 additions and 241 deletions

3
.gitignore vendored
View File

@ -39,3 +39,6 @@ Makefile*
# documentation # documentation
/doc /doc
# clang-format
/.clang-format

View File

@ -3,10 +3,10 @@
#include <c++utilities/application/failure.h> #include <c++utilities/application/failure.h>
#include <c++utilities/conversion/stringconversion.h> #include <c++utilities/conversion/stringconversion.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cmath> #include <cmath>
#include <iomanip>
#include <iostream>
#include <sstream>
#ifndef M_PI #ifndef M_PI
#define M_PI 3.14159265359 #define M_PI 3.14159265359
@ -16,16 +16,15 @@ using namespace std;
using namespace ApplicationUtilities; using namespace ApplicationUtilities;
using namespace ConversionUtilities; using namespace ConversionUtilities;
Angle::Angle() : Angle::Angle()
m_val(0) : m_val(0)
{ {
} }
Angle::Angle(double value, AngularMeasure measure) : Angle::Angle(double value, AngularMeasure measure)
m_val(0) : m_val(0)
{ {
switch(measure) switch (measure) {
{
case AngularMeasure::Radian: case AngularMeasure::Radian:
m_val = value; m_val = value;
break; break;
@ -34,31 +33,30 @@ Angle::Angle(double value, AngularMeasure measure) :
} }
} }
Angle::Angle(const string &value, AngularMeasure measure) : Angle::Angle(const string &value, AngularMeasure measure)
m_val(0) : m_val(0)
{ {
switch(measure) { switch (measure) {
case AngularMeasure::Radian: case AngularMeasure::Radian:
m_val += stringToNumber<double>(value); m_val += stringToNumber<double>(value);
break; break;
case AngularMeasure::Degree: case AngularMeasure::Degree: {
{
string::size_type mpos, spos = string::npos; string::size_type mpos, spos = string::npos;
mpos = value.find(':'); mpos = value.find(':');
if(mpos == string::npos) if (mpos == string::npos)
m_val += stringToNumber<double>(value); m_val += stringToNumber<double>(value);
else if(mpos >= (value.length() - 1)) else if (mpos >= (value.length() - 1))
throw Failure("excepted minutes after ':' in " + value); throw Failure("excepted minutes after ':' in " + value);
else { else {
m_val += stringToNumber<double>(value.substr(0, mpos)); m_val += stringToNumber<double>(value.substr(0, mpos));
spos = value.find(':', mpos + 1); spos = value.find(':', mpos + 1);
if(spos == string::npos) if (spos == string::npos)
m_val += stringToNumber<double>(value.substr(mpos + 1)) / 60.0; m_val += stringToNumber<double>(value.substr(mpos + 1)) / 60.0;
else if(spos >= (value.length() - 1)) else if (spos >= (value.length() - 1))
throw Failure("excepted seconds after second ':'' in " + value); throw Failure("excepted seconds after second ':'' in " + value);
else else
m_val += (stringToNumber<double>(value.substr(mpos + 1, spos - mpos - 1)) / 60.0) m_val += (stringToNumber<double>(value.substr(mpos + 1, spos - mpos - 1)) / 60.0)
+ (stringToNumber<double>(value.substr(spos + 1)) / 3600.0); + (stringToNumber<double>(value.substr(spos + 1)) / 3600.0);
} }
m_val = m_val * M_PI / 180.0; m_val = m_val * M_PI / 180.0;
break; break;
@ -83,14 +81,18 @@ bool Angle::isNull() const
void Angle::adjust0To360() void Angle::adjust0To360()
{ {
while(m_val < 0) m_val += 2.0 * M_PI; while (m_val < 0)
while(m_val > 2.0 * M_PI) m_val -= 2.0 * M_PI; m_val += 2.0 * M_PI;
while (m_val > 2.0 * M_PI)
m_val -= 2.0 * M_PI;
} }
void Angle::adjust180To180() void Angle::adjust180To180()
{ {
while(m_val > M_PI) m_val -= 2.0 * M_PI; while (m_val > M_PI)
while(m_val < -M_PI) m_val += 2.0 * M_PI; m_val -= 2.0 * M_PI;
while (m_val < -M_PI)
m_val += 2.0 * M_PI;
} }
void Angle::reverse() void Angle::reverse()
@ -104,19 +106,19 @@ string Angle::toString(OutputForm format) const
stringstream sstream(stringstream::in | stringstream::out); stringstream sstream(stringstream::in | stringstream::out);
sstream << setprecision(9); sstream << setprecision(9);
double intpart, fractpart; double intpart, fractpart;
switch(format) { switch (format) {
case OutputForm::Degrees: case OutputForm::Degrees:
sstream << degreeValue(); sstream << degreeValue();
break; break;
case OutputForm::Minutes: case OutputForm::Minutes:
if(degreeValue() < 0) if (degreeValue() < 0)
sstream << "-"; sstream << "-";
fractpart = modf(fabs(degreeValue()), &intpart); fractpart = modf(fabs(degreeValue()), &intpart);
fractpart *= 60; fractpart *= 60;
sstream << intpart << ":" << fractpart; sstream << intpart << ":" << fractpart;
break; break;
case OutputForm::Seconds: case OutputForm::Seconds:
if(degreeValue() < 0) if (degreeValue() < 0)
sstream << "-"; sstream << "-";
fractpart = modf(fabs(degreeValue()), &intpart); fractpart = modf(fabs(degreeValue()), &intpart);
sstream << intpart << ":"; sstream << intpart << ":";
@ -131,33 +133,33 @@ string Angle::toString(OutputForm format) const
return sstream.str(); return sstream.str();
} }
bool Angle::operator ==(const Angle &other) const bool Angle::operator==(const Angle &other) const
{ {
return m_val == other.m_val; return m_val == other.m_val;
} }
bool Angle::operator !=(const Angle &other) const bool Angle::operator!=(const Angle &other) const
{ {
return m_val != other.m_val; return m_val != other.m_val;
} }
Angle Angle::operator +(const Angle &other) const Angle Angle::operator+(const Angle &other) const
{ {
return Angle(m_val + other.m_val); return Angle(m_val + other.m_val);
} }
Angle Angle::operator -(const Angle &other) const Angle Angle::operator-(const Angle &other) const
{ {
return Angle(m_val - other.m_val); return Angle(m_val - other.m_val);
} }
Angle &Angle::operator +=(const Angle &other) Angle &Angle::operator+=(const Angle &other)
{ {
m_val += other.m_val; m_val += other.m_val;
return *this; return *this;
} }
Angle &Angle::operator -=(const Angle &other) Angle &Angle::operator-=(const Angle &other)
{ {
m_val -= other.m_val; m_val -= other.m_val;
return *this; return *this;

30
angle.h
View File

@ -3,22 +3,11 @@
#include <string> #include <string>
class Angle class Angle {
{
public: public:
enum class AngularMeasure enum class AngularMeasure { Radian, Degree };
{
Radian,
Degree
};
enum class OutputForm enum class OutputForm { Degrees, Minutes, Seconds, Radians };
{
Degrees,
Minutes,
Seconds,
Radians
};
Angle(); Angle();
Angle(double value, AngularMeasure measure = AngularMeasure::Radian); Angle(double value, AngularMeasure measure = AngularMeasure::Radian);
@ -32,12 +21,13 @@ public:
std::string toString() const; std::string toString() const;
std::string toString(OutputForm format) const; std::string toString(OutputForm format) const;
bool operator ==(const Angle &other) const; bool operator==(const Angle &other) const;
bool operator !=(const Angle &other) const; bool operator!=(const Angle &other) const;
Angle operator +(const Angle &other) const; Angle operator+(const Angle &other) const;
Angle operator -(const Angle &other) const; Angle operator-(const Angle &other) const;
Angle &operator +=(const Angle &other); Angle &operator+=(const Angle &other);
Angle &operator -=(const Angle &other); Angle &operator-=(const Angle &other);
private: private:
double m_val; double m_val;
}; };

View File

@ -3,65 +3,69 @@
#include <c++utilities/application/failure.h> #include <c++utilities/application/failure.h>
#include <c++utilities/conversion/stringconversion.h> #include <c++utilities/conversion/stringconversion.h>
#include <sstream>
#include <iomanip>
#include <cmath> #include <cmath>
#include <iomanip>
#include <sstream>
using namespace std; using namespace std;
using namespace ApplicationUtilities; using namespace ApplicationUtilities;
using namespace ConversionUtilities; using namespace ConversionUtilities;
// WGS84 Parameters // WGS84 Parameters
#define WGS84_A 6378137.0 // major axis #define WGS84_A 6378137.0 // major axis
#define WGS84_B 6356752.31424518 // minor axis #define WGS84_B 6356752.31424518 // minor axis
#define WGS84_F 0.0033528107 // ellipsoid flattening #define WGS84_F 0.0033528107 // ellipsoid flattening
#define WGS84_E 0.0818191908 // first eccentricity #define WGS84_E 0.0818191908 // first eccentricity
#define WGS84_EP 0.0820944379 // second eccentricity #define WGS84_EP 0.0820944379 // second eccentricity
// UTM Parameters // UTM Parameters
#define UTM_K0 0.9996 // scale factor #define UTM_K0 0.9996 // scale factor
#define UTM_FE 500000.0 // false easting #define UTM_FE 500000.0 // false easting
#define UTM_FN_N 0.0 // false northing, northern hemisphere #define UTM_FN_N 0.0 // false northing, northern hemisphere
#define UTM_FN_S 10000000.0 // false northing, southern hemisphere #define UTM_FN_S 10000000.0 // false northing, southern hemisphere
#define UTM_E2 (WGS84_E * WGS84_E) // e^2 #define UTM_E2 (WGS84_E * WGS84_E) // e^2
#define UTM_E4 (UTM_E2 * UTM_E2) // e^4 #define UTM_E4 (UTM_E2 * UTM_E2) // e^4
#define UTM_E6 (UTM_E4 * UTM_E2) // e^6 #define UTM_E6 (UTM_E4 * UTM_E2) // e^6
#define UTM_EP2 (UTM_E2 / (1 - UTM_E2)) // e'^2 #define UTM_EP2 (UTM_E2 / (1 - UTM_E2)) // e'^2
Location::Location() : Location::Location()
m_lat(0.0), : m_lat(0.0)
m_lon(0.0), , m_lon(0.0)
m_ele(0.0) , m_ele(0.0)
{} {
}
Location::Location(const Angle &latitude, const Angle &lon) : Location::Location(const Angle &latitude, const Angle &lon)
m_lat(latitude), : m_lat(latitude)
m_lon(lon), , m_lon(lon)
m_ele(0.0) , m_ele(0.0)
{} {
}
Location::Location(const string &lat, const string &lon, Angle::AngularMeasure measure) : Location::Location(const string &lat, const string &lon, Angle::AngularMeasure measure)
m_lat(Angle(lat, measure)), : m_lat(Angle(lat, measure))
m_lon(Angle(lon, measure)), , m_lon(Angle(lon, measure))
m_ele(0.0) , m_ele(0.0)
{} {
}
Location::Location(const string &latitudeAndLongitude, Angle::AngularMeasure measure) : Location::Location(const string &latitudeAndLongitude, Angle::AngularMeasure measure)
m_ele(0.0) : m_ele(0.0)
{ {
string::size_type dpos = latitudeAndLongitude.find(','); string::size_type dpos = latitudeAndLongitude.find(',');
if(dpos == string::npos) if (dpos == string::npos)
throw Failure("Pair of coordinates (latitude and longitude) required."); throw Failure("Pair of coordinates (latitude and longitude) required.");
else if(dpos >= (latitudeAndLongitude.length() - 1)) else if (dpos >= (latitudeAndLongitude.length() - 1))
throw Failure("No second longitude following after comma."); throw Failure("No second longitude following after comma.");
else if(latitudeAndLongitude.find(',', dpos + 1) != string::npos) else if (latitudeAndLongitude.find(',', dpos + 1) != string::npos)
throw Failure("More then 2 coordinates given."); throw Failure("More then 2 coordinates given.");
m_lat = Angle(latitudeAndLongitude.substr(0, dpos), measure); m_lat = Angle(latitudeAndLongitude.substr(0, dpos), measure);
m_lon = Angle(latitudeAndLongitude.substr(dpos + 1), measure); m_lon = Angle(latitudeAndLongitude.substr(dpos + 1), measure);
} }
Location::~Location() Location::~Location()
{} {
}
string Location::toString(Angle::OutputForm form) const string Location::toString(Angle::OutputForm form) const
{ {
@ -138,17 +142,20 @@ void Location::computeUtmWgs4Coordinates(int &zone, char &zoneDesignator, double
zone = int((lond + 180) / 6) + 1; zone = int((lond + 180) / 6) + 1;
if(latd >= 56.0 && latd < 64.0 && lond >= 3.0 && lond < 12.0) if (latd >= 56.0 && latd < 64.0 && lond >= 3.0 && lond < 12.0)
zone = 32; zone = 32;
// Special zones for Svalbard // Special zones for Svalbard
if(latd >= 72.0 && latd < 84.0) if (latd >= 72.0 && latd < 84.0) {
{ if (lond >= 0.0 && lond < 9.0)
if(lond >= 0.0 && lond < 9.0) zone = 31; zone = 31;
else if(lond >= 9.0 && lond < 21.0) zone = 33; else if (lond >= 9.0 && lond < 21.0)
else if(lond >= 21.0 && lond < 33.0) zone = 35; zone = 33;
else if(lond >= 33.0 && lond < 42.0) zone = 37; else if (lond >= 21.0 && lond < 33.0)
} zone = 35;
else if (lond >= 33.0 && lond < 42.0)
zone = 37;
}
zoneDesignator = computeUtmZoneDesignator(); zoneDesignator = computeUtmZoneDesignator();
@ -159,26 +166,21 @@ void Location::computeUtmWgs4Coordinates(int &zone, char &zoneDesignator, double
double N = a / sqrt(1 - eccSquared * sin(latr) * sin(latr)); double N = a / sqrt(1 - eccSquared * sin(latr) * sin(latr));
double T = tan(latr) * tan(latr); double T = tan(latr) * tan(latr);
double C = eccPrimeSquared * cos(latr) * cos(latr); double C = eccPrimeSquared * cos(latr) * cos(latr);
double A = cos(latr) * (lonr-lonOriginr); double A = cos(latr) * (lonr - lonOriginr);
double M = a * ((1 - eccSquared / 4 - 3 * eccSquared * eccSquared / 64 double M = a * ((1 - eccSquared / 4 - 3 * eccSquared * eccSquared / 64 - 5 * eccSquared * eccSquared * eccSquared / 256) * latr
- 5 * eccSquared * eccSquared * eccSquared / 256) * latr - (3 * eccSquared / 8 + 3 * eccSquared * eccSquared / 32 + 45 * eccSquared * eccSquared * eccSquared / 1024) * sin(2 * latr)
- (3 * eccSquared / 8 + 3 * eccSquared*eccSquared / 32 + (15 * eccSquared * eccSquared / 256 + 45 * eccSquared * eccSquared * eccSquared / 1024) * sin(4 * latr)
+ 45 * eccSquared * eccSquared * eccSquared / 1024)*sin(2 * latr) - (35 * eccSquared * eccSquared * eccSquared / 3072) * sin(6 * latr));
+ (15 * eccSquared * eccSquared / 256
+ 45 * eccSquared * eccSquared*eccSquared / 1024) * sin(4 * latr)
- (35 * eccSquared * eccSquared * eccSquared/3072) * sin(6 * latr));
east = static_cast<double> east = static_cast<double>(
(k0 * N * (A + (1 - T + C) * A * A * A / 6 k0 * N * (A + (1 - T + C) * A * A * A / 6 + (5 - 18 * T + T * T + 72 * C - 58 * eccPrimeSquared) * A * A * A * A * A / 120) + 500000.0);
+ (5 - 18 * T + T * T + 72 * C - 58 * eccPrimeSquared) * A * A * A * A * A / 120)
+ 500000.0);
north = static_cast<double> north = static_cast<double>(
(k0 * (M + N * tan(latr) k0 * (M
* (A * A / 2 + (5 - T + 9 * C + 4 * C * C) * A * A * A *A / 24 + N * tan(latr) * (A * A / 2 + (5 - T + 9 * C + 4 * C * C) * A * A * A * A / 24
+ (61 - 58 * T + T * T + 600 * C - 330 * eccPrimeSquared) * A * A * A * A * A * A / 720))); + (61 - 58 * T + T * T + 600 * C - 330 * eccPrimeSquared) * A * A * A * A * A * A / 720)));
if(latd < 0) if (latd < 0)
north += 10000000.0; north += 10000000.0;
} }
@ -191,27 +193,25 @@ Location Location::midpoint(const Location &location1, const Location &location2
double lond = lon2 - lon1; double lond = lon2 - lon1;
double x = cos(lat2) * cos(lond); double x = cos(lat2) * cos(lond);
double y = cos(lat2) * sin(lond); double y = cos(lat2) * sin(lond);
return Location( return Location(Angle(atan2(sin(lat1) + sin(lat2), sqrt((cos(lat1) + x) * (cos(lat1) + x) + y * y))), Angle(lon1 + atan2(y, cos(lat1) + x)));
Angle(atan2(sin(lat1) + sin(lat2), sqrt((cos(lat1) + x) * (cos(lat1) + x) + y * y))),
Angle(lon1 + atan2(y, cos(lat1) + x)));
} }
double Location::trackLength(const std::vector<Location> &track, bool circle) double Location::trackLength(const std::vector<Location> &track, bool circle)
{ {
if(track.size() < 2) if (track.size() < 2)
throw Failure("At least two locations are required to calculate a distance."); throw Failure("At least two locations are required to calculate a distance.");
const Location *location1 = &track.at(0); const Location *location1 = &track.at(0);
const Location *location2 = &track.at(1); const Location *location2 = &track.at(1);
double distance = location1->distanceTo(*location2); double distance = location1->distanceTo(*location2);
for(std::vector<Location>::const_iterator i = track.cbegin() + 2, end = track.cend(); i != end; ++i) { for (std::vector<Location>::const_iterator i = track.cbegin() + 2, end = track.cend(); i != end; ++i) {
location1 = location2; location1 = location2;
location2 = &(*i); location2 = &(*i);
distance += location1->distanceTo(*location2); distance += location1->distanceTo(*location2);
} }
if(circle) if (circle)
distance += track.front().distanceTo(track.back()); distance += track.front().distanceTo(track.back());
return distance; return distance;
@ -230,35 +230,56 @@ Angle Location::angularDistance(double distance)
char Location::computeUtmZoneDesignator() const char Location::computeUtmZoneDesignator() const
{ {
double l = m_lat.degreeValue(); double l = m_lat.degreeValue();
if ((84 >= l) && (l >= 72)) return 'X'; if ((84 >= l) && (l >= 72))
else if ((72 > l) && (l >= 64)) return 'W'; return 'X';
else if ((64 > l) && (l >= 56)) return 'V'; else if ((72 > l) && (l >= 64))
else if ((56 > l) && (l >= 48)) return 'U'; return 'W';
else if ((48 > l) && (l >= 40)) return 'T'; else if ((64 > l) && (l >= 56))
else if ((40 > l) && (l >= 32)) return 'S'; return 'V';
else if ((32 > l) && (l >= 24)) return 'R'; else if ((56 > l) && (l >= 48))
else if ((24 > l) && (l >= 16)) return 'Q'; return 'U';
else if ((16 > l) && (l >= 8)) return 'P'; else if ((48 > l) && (l >= 40))
else if (( 8 > l) && (l >= 0)) return 'N'; return 'T';
else if (( 0 > l) && (l >= -8)) return 'M'; else if ((40 > l) && (l >= 32))
else if ((-8 > l) && (l >= -16)) return 'L'; return 'S';
else if((-16 > l) && (l >= -24)) return 'K'; else if ((32 > l) && (l >= 24))
else if((-24 > l) && (l >= -32)) return 'J'; return 'R';
else if((-32 > l) && (l >= -40)) return 'H'; else if ((24 > l) && (l >= 16))
else if((-40 > l) && (l >= -48)) return 'G'; return 'Q';
else if((-48 > l) && (l >= -56)) return 'F'; else if ((16 > l) && (l >= 8))
else if((-56 > l) && (l >= -64)) return 'E'; return 'P';
else if((-64 > l) && (l >= -72)) return 'D'; else if ((8 > l) && (l >= 0))
else if((-72 > l) && (l >= -80)) return 'C'; return 'N';
else return '\0'; else if ((0 > l) && (l >= -8))
return 'M';
else if ((-8 > l) && (l >= -16))
return 'L';
else if ((-16 > l) && (l >= -24))
return 'K';
else if ((-24 > l) && (l >= -32))
return 'J';
else if ((-32 > l) && (l >= -40))
return 'H';
else if ((-40 > l) && (l >= -48))
return 'G';
else if ((-48 > l) && (l >= -56))
return 'F';
else if ((-56 > l) && (l >= -64))
return 'E';
else if ((-64 > l) && (l >= -72))
return 'D';
else if ((-72 > l) && (l >= -80))
return 'C';
else
return '\0';
} }
void Location::setValueByProvidedUtmWgs4Coordinates(const string &utmWgs4Coordinates) void Location::setValueByProvidedUtmWgs4Coordinates(const string &utmWgs4Coordinates)
{ {
string::size_type epos = utmWgs4Coordinates.find('E'); string::size_type epos = utmWgs4Coordinates.find('E');
if(epos != 0 && epos != string::npos) { if (epos != 0 && epos != string::npos) {
string::size_type npos = utmWgs4Coordinates.find('N', epos); string::size_type npos = utmWgs4Coordinates.find('N', epos);
if(npos < (utmWgs4Coordinates.length() - 1) && npos != string::npos) { if (npos < (utmWgs4Coordinates.length() - 1) && npos != string::npos) {
int zone = stringToNumber<int>(utmWgs4Coordinates.substr(0, epos - 1)); int zone = stringToNumber<int>(utmWgs4Coordinates.substr(0, epos - 1));
char zoneDesignator = utmWgs4Coordinates.at(epos - 1); char zoneDesignator = utmWgs4Coordinates.at(epos - 1);
double east = stringToNumber<double>(utmWgs4Coordinates.substr(epos + 1, npos - epos - 1)); double east = stringToNumber<double>(utmWgs4Coordinates.substr(epos + 1, npos - epos - 1));
@ -281,21 +302,19 @@ void Location::setValueByProvidedUtmWgs4Coordinates(int zone, char zoneDesignato
double x = easting - 500000.0; //remove 500,000 meter offset for longitude double x = easting - 500000.0; //remove 500,000 meter offset for longitude
double y = northing; double y = northing;
if((zoneDesignator - 'N') < 0) if ((zoneDesignator - 'N') < 0)
//remove 10,000,000 meter offset used for southern hemisphere //remove 10,000,000 meter offset used for southern hemisphere
y -= 10000000.0; y -= 10000000.0;
//+3 puts origin in middle of zone //+3 puts origin in middle of zone
double longOriginr = Angle((zone - 1) * 6 - 180 + 3, Angle::AngularMeasure::Degree).radianValue(); double longOriginr = Angle((zone - 1) * 6 - 180 + 3, Angle::AngularMeasure::Degree).radianValue();
eccPrimeSquared = (eccSquared)/(1-eccSquared); eccPrimeSquared = (eccSquared) / (1 - eccSquared);
double M = y / k0; double M = y / k0;
double mu = M / (a * (1 - eccSquared / 4 - 3 * eccSquared * eccSquared / 64 double mu = M / (a * (1 - eccSquared / 4 - 3 * eccSquared * eccSquared / 64 - 5 * eccSquared * eccSquared * eccSquared / 256));
-5 * eccSquared * eccSquared * eccSquared / 256));
double phi1Rad = mu + ((3 * e1 / 2 - 27 * e1 * e1 * e1 / 32) * sin(2 * mu) double phi1Rad = mu + ((3 * e1 / 2 - 27 * e1 * e1 * e1 / 32) * sin(2 * mu) + (21 * e1 * e1 / 16 - 55 * e1 * e1 * e1 * e1 / 32) * sin(4 * mu)
+ (21 * e1 * e1 / 16 - 55 * e1 * e1 * e1 * e1 / 32) * sin(4 * mu) + (151 * e1 * e1 * e1 / 96) * sin(6 * mu));
+ (151 * e1 * e1 * e1 / 96) * sin(6 * mu));
double N1 = a / sqrt(1 - eccSquared * sin(phi1Rad) * sin(phi1Rad)); double N1 = a / sqrt(1 - eccSquared * sin(phi1Rad) * sin(phi1Rad));
double T1 = tan(phi1Rad) * tan(phi1Rad); double T1 = tan(phi1Rad) * tan(phi1Rad);
@ -303,16 +322,14 @@ void Location::setValueByProvidedUtmWgs4Coordinates(int zone, char zoneDesignato
double R1 = a * (1 - eccSquared) / pow(1 - eccSquared * sin(phi1Rad) * sin(phi1Rad), 1.5); double R1 = a * (1 - eccSquared) / pow(1 - eccSquared * sin(phi1Rad) * sin(phi1Rad), 1.5);
double D = x / (N1 * k0); double D = x / (N1 * k0);
m_lat = Angle(phi1Rad - ((N1 * tan(phi1Rad) / R1) m_lat = Angle(phi1Rad - ((N1 * tan(phi1Rad) / R1) * (D * D / 2 - (5 + 3 * T1 + 10 * C1 - 4 * C1 * C1 - 9 * eccPrimeSquared) * D * D * D * D / 24
* (D * D / 2 + (61 + 90 * T1 + 298 * C1 + 45 * T1 * T1 - 252 * eccPrimeSquared - 3 * C1 * C1) * D * D
-(5 + 3 * T1 + 10 * C1 - 4 * C1 * C1 - 9 * eccPrimeSquared) * D * D * D * D / 24 * D * D * D * D / 720)));
+(61 + 90 * T1 + 298 * C1 + 45 * T1 * T1 - 252 * eccPrimeSquared
-3 * C1 * C1) * D * D * D * D * D * D / 720)));
m_lat.adjust180To180(); m_lat.adjust180To180();
m_lon = Angle(((D - (1 + 2 * T1 + C1) * D * D * D / 6 m_lon = Angle(
+(5 - 2 * C1 + 28 * T1 - 3 * C1 * C1 + 8 * eccPrimeSquared + 24 * T1 * T1) ((D - (1 + 2 * T1 + C1) * D * D * D / 6 + (5 - 2 * C1 + 28 * T1 - 3 * C1 * C1 + 8 * eccPrimeSquared + 24 * T1 * T1) * D * D * D * D * D / 120)
* D * D * D * D * D / 120) / cos(phi1Rad))
/ cos(phi1Rad)) + longOriginr); + longOriginr);
m_lon.adjust180To180(); m_lon.adjust180To180();
} }

View File

@ -3,17 +3,12 @@
#include "./angle.h" #include "./angle.h"
#include <vector>
#include <string> #include <string>
#include <vector>
class Location class Location {
{
public: public:
enum class GeographicCoordinateSystem enum class GeographicCoordinateSystem { LatitudeAndLongitude, UTMWGS84 };
{
LatitudeAndLongitude,
UTMWGS84
};
Location(); Location();
Location(const Angle &lat, const Angle &lon); Location(const Angle &lat, const Angle &lon);
@ -42,6 +37,7 @@ public:
static double trackLength(const std::vector<Location> &track, bool circle = false); static double trackLength(const std::vector<Location> &track, bool circle = false);
static double earthRadius(); static double earthRadius();
static Angle angularDistance(double distance); static Angle angularDistance(double distance);
protected: protected:
private: private:
Angle m_lat; Angle m_lat;

141
main.cpp
View File

@ -8,9 +8,9 @@
#include <c++utilities/conversion/stringconversion.h> #include <c++utilities/conversion/stringconversion.h>
#include <c++utilities/io/catchiofailure.h> #include <c++utilities/io/catchiofailure.h>
#include <iostream>
#include <fstream>
#include <cstring> #include <cstring>
#include <fstream>
#include <iostream>
using namespace std; using namespace std;
using namespace ConversionUtilities; using namespace ConversionUtilities;
@ -22,7 +22,7 @@ SystemForLocations inputSystemForLocations = SystemForLocations::LatitudeLongitu
SystemForLocations outputSystemForLocations = SystemForLocations::LatitudeLongitude; SystemForLocations outputSystemForLocations = SystemForLocations::LatitudeLongitude;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
try { try {
SET_APPLICATION_INFO; SET_APPLICATION_INFO;
@ -37,20 +37,24 @@ int main(int argc, char *argv[])
distance.appendValueName("location 1"); distance.appendValueName("location 1");
distance.appendValueName("location 2"); distance.appendValueName("location 2");
Argument trackLength("track-length", 't', "Computes the approximate length in meters of a track given by a file containing trackpoints separated by new lines."); Argument trackLength("track-length", 't',
"Computes the approximate length in meters of a track given by a file containing trackpoints separated by new lines.");
Argument fileArg("file", 'f', "Specifies the file containing the track points"); Argument fileArg("file", 'f', "Specifies the file containing the track points");
fileArg.setRequiredValueCount(1); fileArg.setRequiredValueCount(1);
fileArg.appendValueName("path"); fileArg.appendValueName("path");
fileArg.setRequired(true); fileArg.setRequired(true);
Argument circle("circle", '\0', "If present the distance between the first and the last trackpoints will be added to the total track length."); Argument circle(
trackLength.setSubArguments({&fileArg, &circle}); "circle", '\0', "If present the distance between the first and the last trackpoints will be added to the total track length.");
trackLength.setSubArguments({ &fileArg, &circle });
Argument bearing("bearing", 'b', "Computes the approximate initial bearing East of true North when traveling along the shortest path between the given locations."); Argument bearing("bearing", 'b',
"Computes the approximate initial bearing East of true North when traveling along the shortest path between the given locations.");
bearing.setRequiredValueCount(2); bearing.setRequiredValueCount(2);
bearing.appendValueName("location 1"); bearing.appendValueName("location 1");
bearing.appendValueName("location 2"); bearing.appendValueName("location 2");
Argument fbearing("final-bearing", '\0', "Computes the approximate final bearing East of true North when traveling along the shortest path between the given locations."); Argument fbearing("final-bearing", '\0',
"Computes the approximate final bearing East of true North when traveling along the shortest path between the given locations.");
fbearing.setRequiredValueCount(2); fbearing.setRequiredValueCount(2);
fbearing.appendValueName("location 1"); fbearing.appendValueName("location 1");
fbearing.appendValueName("location 2"); fbearing.appendValueName("location 2");
@ -66,26 +70,31 @@ int main(int argc, char *argv[])
destination.appendValueName("distance"); destination.appendValueName("distance");
destination.appendValueName("bearing"); destination.appendValueName("bearing");
Argument gmapsLink("gmaps-link", '\0', "Generates a Google Maps link for all locations given by a file containing locations separated by new lines."); Argument gmapsLink(
"gmaps-link", '\0', "Generates a Google Maps link for all locations given by a file containing locations separated by new lines.");
gmapsLink.setRequiredValueCount(1); gmapsLink.setRequiredValueCount(1);
gmapsLink.appendValueName("path"); gmapsLink.appendValueName("path");
Argument inputAngularMeasureArg("input-angular-measure", 'i', "Use this option to specify the angular measure you use to provide angles (degree or radian; default is degree)."); Argument inputAngularMeasureArg("input-angular-measure", 'i',
"Use this option to specify the angular measure you use to provide angles (degree or radian; default is degree).");
inputAngularMeasureArg.setRequiredValueCount(1); inputAngularMeasureArg.setRequiredValueCount(1);
inputAngularMeasureArg.appendValueName("angular measure"); inputAngularMeasureArg.appendValueName("angular measure");
inputAngularMeasureArg.setCombinable(true); inputAngularMeasureArg.setCombinable(true);
Argument outputFormForAnglesArg("output-angle-form", 'o', "Use this option to specify the output form for angles (degrees, minutes, seconds or radians; default is degrees)."); Argument outputFormForAnglesArg("output-angle-form", 'o',
"Use this option to specify the output form for angles (degrees, minutes, seconds or radians; default is degrees).");
outputFormForAnglesArg.setRequiredValueCount(1); outputFormForAnglesArg.setRequiredValueCount(1);
outputFormForAnglesArg.appendValueName("form"); outputFormForAnglesArg.appendValueName("form");
outputFormForAnglesArg.setCombinable(true); outputFormForAnglesArg.setCombinable(true);
Argument inputSystemForLocationsArg("input-location-system", '\0', "Use this option to specify the geographic system you use to provide locations (latitude&longitue or UTM-WGS84)."); Argument inputSystemForLocationsArg("input-location-system", '\0',
"Use this option to specify the geographic system you use to provide locations (latitude&longitue or UTM-WGS84).");
inputSystemForLocationsArg.setRequiredValueCount(1); inputSystemForLocationsArg.setRequiredValueCount(1);
inputSystemForLocationsArg.appendValueName("system"); inputSystemForLocationsArg.appendValueName("system");
inputSystemForLocationsArg.setCombinable(true); inputSystemForLocationsArg.setCombinable(true);
Argument outputSystemForLocationsArg("output-location-system", '\0', "Use this option to specify which geographic system is used to display locations (latitude&longitue or UTM-WGS84)."); Argument outputSystemForLocationsArg("output-location-system", '\0',
"Use this option to specify which geographic system is used to display locations (latitude&longitue or UTM-WGS84).");
outputSystemForLocationsArg.setRequiredValueCount(1); outputSystemForLocationsArg.setRequiredValueCount(1);
outputSystemForLocationsArg.appendValueName("system"); outputSystemForLocationsArg.appendValueName("system");
outputSystemForLocationsArg.setCombinable(true); outputSystemForLocationsArg.setCombinable(true);
@ -93,14 +102,15 @@ int main(int argc, char *argv[])
HelpArgument help(argparser); HelpArgument help(argparser);
Argument version("version", 'v', "Shows the version of this application."); Argument version("version", 'v', "Shows the version of this application.");
argparser.setMainArguments({&help, &convert, &distance, &trackLength, &bearing, &fbearing, &midpoint, &destination, &gmapsLink, &inputAngularMeasureArg, &outputFormForAnglesArg, &inputSystemForLocationsArg, &outputSystemForLocationsArg, &version}); argparser.setMainArguments({ &help, &convert, &distance, &trackLength, &bearing, &fbearing, &midpoint, &destination, &gmapsLink,
&inputAngularMeasureArg, &outputFormForAnglesArg, &inputSystemForLocationsArg, &outputSystemForLocationsArg, &version });
argparser.parseArgs(argc, argv); argparser.parseArgs(argc, argv);
if(inputAngularMeasureArg.isPresent()) { if (inputAngularMeasureArg.isPresent()) {
const char *inputFormat = inputAngularMeasureArg.values().front(); const char *inputFormat = inputAngularMeasureArg.values().front();
if(!strcmp(inputFormat, "radian")) { if (!strcmp(inputFormat, "radian")) {
inputAngularMeasure = Angle::AngularMeasure::Radian; inputAngularMeasure = Angle::AngularMeasure::Radian;
} else if(!strcmp(inputFormat, "degree")) { } else if (!strcmp(inputFormat, "degree")) {
inputAngularMeasure = Angle::AngularMeasure::Degree; inputAngularMeasure = Angle::AngularMeasure::Degree;
} else { } else {
cerr << "Invalid angular measure given, see --help." << endl; cerr << "Invalid angular measure given, see --help." << endl;
@ -108,15 +118,15 @@ int main(int argc, char *argv[])
} }
} }
if(outputFormForAnglesArg.isPresent()) { if (outputFormForAnglesArg.isPresent()) {
const char *outputFormat = outputFormForAnglesArg.values().front(); const char *outputFormat = outputFormForAnglesArg.values().front();
if(!strcmp(outputFormat, "degrees")) { if (!strcmp(outputFormat, "degrees")) {
outputFormForAngles = Angle::OutputForm::Degrees; outputFormForAngles = Angle::OutputForm::Degrees;
} else if(!strcmp(outputFormat, "minutes")) { } else if (!strcmp(outputFormat, "minutes")) {
outputFormForAngles = Angle::OutputForm::Minutes; outputFormForAngles = Angle::OutputForm::Minutes;
} else if(!strcmp(outputFormat, "seconds")) { } else if (!strcmp(outputFormat, "seconds")) {
outputFormForAngles = Angle::OutputForm::Seconds; outputFormForAngles = Angle::OutputForm::Seconds;
} else if(!strcmp(outputFormat, "radians")) { } else if (!strcmp(outputFormat, "radians")) {
outputFormForAngles = Angle::OutputForm::Radians; outputFormForAngles = Angle::OutputForm::Radians;
} else { } else {
cerr << "Invalid output form for angles given, see --help." << endl; cerr << "Invalid output form for angles given, see --help." << endl;
@ -124,11 +134,11 @@ int main(int argc, char *argv[])
} }
} }
if(inputSystemForLocationsArg.isPresent()) { if (inputSystemForLocationsArg.isPresent()) {
const char *inputFormat = inputSystemForLocationsArg.values().front(); const char *inputFormat = inputSystemForLocationsArg.values().front();
if(!strcmp(inputFormat, "latitude&longitue")) { if (!strcmp(inputFormat, "latitude&longitue")) {
inputSystemForLocations = SystemForLocations::LatitudeLongitude; inputSystemForLocations = SystemForLocations::LatitudeLongitude;
} else if(!strcmp(inputFormat, "UTM-WGS84")) { } else if (!strcmp(inputFormat, "UTM-WGS84")) {
inputSystemForLocations = SystemForLocations::UTMWGS84; inputSystemForLocations = SystemForLocations::UTMWGS84;
} else { } else {
cerr << "Invalid geographic coordinate system given, see --help." << endl; cerr << "Invalid geographic coordinate system given, see --help." << endl;
@ -136,11 +146,11 @@ int main(int argc, char *argv[])
} }
} }
if(outputSystemForLocationsArg.isPresent()) { if (outputSystemForLocationsArg.isPresent()) {
const char *outputSystem = outputSystemForLocationsArg.values().front(); const char *outputSystem = outputSystemForLocationsArg.values().front();
if(!strcmp(outputSystem, "latitude&longitue")) { if (!strcmp(outputSystem, "latitude&longitue")) {
outputSystemForLocations = SystemForLocations::LatitudeLongitude; outputSystemForLocations = SystemForLocations::LatitudeLongitude;
} else if(!strcmp(outputSystem, "UTM-WGS84")) { } else if (!strcmp(outputSystem, "UTM-WGS84")) {
outputSystemForLocations = SystemForLocations::UTMWGS84; outputSystemForLocations = SystemForLocations::UTMWGS84;
} else { } else {
cerr << "Invalid geographic coordinate system given, see --help." << endl; cerr << "Invalid geographic coordinate system given, see --help." << endl;
@ -149,40 +159,40 @@ int main(int argc, char *argv[])
} }
try { try {
if(help.isPresent()) { if (help.isPresent()) {
cout << endl; cout << endl;
printAngleFormatInfo(cout); printAngleFormatInfo(cout);
} else if(version.isPresent()) { } else if (version.isPresent()) {
cout << APP_VERSION; cout << APP_VERSION;
} else if(convert.isPresent()) { } else if (convert.isPresent()) {
printConversion(convert.values().front()); printConversion(convert.values().front());
} else if(distance.isPresent()) { } else if (distance.isPresent()) {
printDistance(distance.values()[0], distance.values()[1]); printDistance(distance.values()[0], distance.values()[1]);
} else if(trackLength.isPresent()) { } else if (trackLength.isPresent()) {
printTrackLength(fileArg.values().front(), circle.isPresent()); printTrackLength(fileArg.values().front(), circle.isPresent());
} else if(bearing.isPresent()) { } else if (bearing.isPresent()) {
printBearing(bearing.values()[0], bearing.values()[1]); printBearing(bearing.values()[0], bearing.values()[1]);
} else if(fbearing.isPresent()) { } else if (fbearing.isPresent()) {
printFinalBearing(fbearing.values()[0], fbearing.values()[1]); printFinalBearing(fbearing.values()[0], fbearing.values()[1]);
} else if(midpoint.isPresent()) { } else if (midpoint.isPresent()) {
printMidpoint(midpoint.values()[0], midpoint.values()[1]); printMidpoint(midpoint.values()[0], midpoint.values()[1]);
} else if(destination.isPresent()) { } else if (destination.isPresent()) {
printDestination(destination.values()[0], destination.values()[1], destination.values()[2]); printDestination(destination.values()[0], destination.values()[1], destination.values()[2]);
} else if(gmapsLink.isPresent()) { } else if (gmapsLink.isPresent()) {
printMapsLink(gmapsLink.values().front()); printMapsLink(gmapsLink.values().front());
} else { } else {
cerr << "No arguments given. See --help for available commands."; cerr << "No arguments given. See --help for available commands.";
} }
} catch(const ConversionException &) { } catch (const ConversionException &) {
cerr << "The provided numbers couldn't be parsed correctly." << endl; cerr << "The provided numbers couldn't be parsed correctly." << endl;
cerr << endl; cerr << endl;
printAngleFormatInfo(cerr); printAngleFormatInfo(cerr);
} catch(const Failure &ex) { } catch (const Failure &ex) {
cerr << "The provided locations/coordinates couldn't be parsed correctly: " << ex.what() << endl; cerr << "The provided locations/coordinates couldn't be parsed correctly: " << ex.what() << endl;
cerr << endl; cerr << endl;
printAngleFormatInfo(cerr); printAngleFormatInfo(cerr);
} }
} catch(const Failure &ex) { } catch (const Failure &ex) {
cerr << "Unable to parse arguments. " << ex.what() << endl << "See --help for available commands."; cerr << "Unable to parse arguments. " << ex.what() << endl << "See --help for available commands.";
} }
@ -190,15 +200,15 @@ int main(int argc, char *argv[])
return 0; return 0;
} }
Location locationFromString(const string &userInput) Location locationFromString(const string &userInput)
{ {
switch(inputSystemForLocations) { switch (inputSystemForLocations) {
case SystemForLocations::UTMWGS84: { case SystemForLocations::UTMWGS84: {
Location l; Location l;
l.setValueByProvidedUtmWgs4Coordinates(userInput); l.setValueByProvidedUtmWgs4Coordinates(userInput);
return l; return l;
} default: }
default:
return Location(userInput, inputAngularMeasure); return Location(userInput, inputAngularMeasure);
} }
} }
@ -208,13 +218,13 @@ vector<Location> locationsFromFile(const string &path)
// prepare reading // prepare reading
fstream file; fstream file;
file.open(path, ios_base::in); file.open(path, ios_base::in);
if(!file) if (!file)
IoUtilities::throwIoFailure(("Unable to open the file \"" + path + "\".").data()); IoUtilities::throwIoFailure(("Unable to open the file \"" + path + "\".").data());
file.exceptions(ios_base::badbit); file.exceptions(ios_base::badbit);
string line; string line;
vector<Location> locations; vector<Location> locations;
while(getline(file, line)) { while (getline(file, line)) {
if(line.empty() || line.at(0) == '#') if (line.empty() || line.at(0) == '#')
continue; // skip empty lines and comments continue; // skip empty lines and comments
locations.push_back(locationFromString(line)); locations.push_back(locationFromString(line));
} }
@ -230,7 +240,8 @@ void printAngleFormatInfo(ostream &os)
os << "[+-]DDD.DDDDD\n"; os << "[+-]DDD.DDDDD\n";
os << "[+-]DDD:MM.MMMMM\n"; os << "[+-]DDD:MM.MMMMM\n";
os << "[+-]DDD:MM:SS.SSSSS\n"; os << "[+-]DDD:MM:SS.SSSSS\n";
os << "D indicates degrees, M indicates minutes of arc, and S indicates seconds of arc (1 minute = 1/60th of a degree, 1 second = 1/3600th of a degree).\n"; os << "D indicates degrees, M indicates minutes of arc, and S indicates seconds of arc (1 minute = 1/60th of a degree, 1 second = 1/3600th of a "
"degree).\n";
os << "You can use the following form where R indicates radians, if you use --input-angle-measure radian:\n"; os << "You can use the following form where R indicates radians, if you use --input-angle-measure radian:\n";
os << "[+-]RRR.RRRRR"; os << "[+-]RRR.RRRRR";
@ -238,7 +249,7 @@ void printAngleFormatInfo(ostream &os)
void printConversion(const string &coordinates) void printConversion(const string &coordinates)
{ {
if(coordinates.find(',') == string::npos && coordinates.find('N') == string::npos && coordinates.find('E') == string::npos) if (coordinates.find(',') == string::npos && coordinates.find('N') == string::npos && coordinates.find('E') == string::npos)
cout << Angle(coordinates, inputAngularMeasure).toString(outputFormForAngles); cout << Angle(coordinates, inputAngularMeasure).toString(outputFormForAngles);
else else
printLocation(locationFromString(coordinates)); printLocation(locationFromString(coordinates));
@ -246,13 +257,12 @@ void printConversion(const string &coordinates)
void printDistance(const std::string &locationstr1, const std::string &locationstr2) void printDistance(const std::string &locationstr1, const std::string &locationstr2)
{ {
printDistance(locationFromString(locationstr1) printDistance(locationFromString(locationstr1).distanceTo(locationFromString(locationstr2)));
.distanceTo(locationFromString(locationstr2)));
} }
void printDistance(double distance) void printDistance(double distance)
{ {
if(distance > 1000) if (distance > 1000)
cout << (distance / 1000.0) << " km"; cout << (distance / 1000.0) << " km";
else else
cout << distance << " m"; cout << distance << " m";
@ -264,7 +274,7 @@ void printTrackLength(const string &filePath, bool circle)
vector<Location> locations(locationsFromFile(filePath)); vector<Location> locations(locationsFromFile(filePath));
printDistance(Location::trackLength(locations, circle)); printDistance(Location::trackLength(locations, circle));
cout << " (" << locations.size() << " trackpoints)"; cout << " (" << locations.size() << " trackpoints)";
} catch(...) { } catch (...) {
const char *what = ::IoUtilities::catchIoFailure(); const char *what = ::IoUtilities::catchIoFailure();
cout << "An IO failure occured when reading file from provided path: " << what << endl; cout << "An IO failure occured when reading file from provided path: " << what << endl;
} }
@ -272,23 +282,17 @@ void printTrackLength(const string &filePath, bool circle)
void printBearing(const string &locationstr1, const string &locationstr2) void printBearing(const string &locationstr1, const string &locationstr2)
{ {
cout << locationFromString(locationstr1).initialBearingTo( cout << locationFromString(locationstr1).initialBearingTo(locationFromString(locationstr2)).toString(outputFormForAngles) << endl;
locationFromString(locationstr2))
.toString(outputFormForAngles) << endl;
} }
void printFinalBearing(const string &locationstr1, const string &locationstr2) void printFinalBearing(const string &locationstr1, const string &locationstr2)
{ {
cout << locationFromString(locationstr1).finalBearingTo( cout << locationFromString(locationstr1).finalBearingTo(locationFromString(locationstr2)).toString(outputFormForAngles) << endl;
locationFromString(locationstr2))
.toString(outputFormForAngles) << endl;
} }
void printMidpoint(const string &locationstr1, const string &locationstr2) void printMidpoint(const string &locationstr1, const string &locationstr2)
{ {
printLocation(Location::midpoint( printLocation(Location::midpoint(locationFromString(locationstr1), locationFromString(locationstr2)));
locationFromString(locationstr1),
locationFromString(locationstr2)));
} }
void printDestination(const string &locationstr, const string &distancestr, const string &bearingstr) void printDestination(const string &locationstr, const string &distancestr, const string &bearingstr)
@ -301,7 +305,7 @@ void printDestination(const string &locationstr, const string &distancestr, cons
void printLocation(const Location &location) void printLocation(const Location &location)
{ {
switch(outputSystemForLocations) { switch (outputSystemForLocations) {
case SystemForLocations::LatitudeLongitude: case SystemForLocations::LatitudeLongitude:
cout << location.toString(outputFormForAngles); cout << location.toString(outputFormForAngles);
break; break;
@ -311,21 +315,20 @@ void printLocation(const Location &location)
} }
} }
void printMapsLink(const string &filePath) void printMapsLink(const string &filePath)
{ {
try { try {
vector<Location> locations(locationsFromFile(filePath)); vector<Location> locations(locationsFromFile(filePath));
if(locations.size() > 0) { if (locations.size() > 0) {
cout << "https://maps.google.de/maps?saddr="; cout << "https://maps.google.de/maps?saddr=";
const Angle::OutputForm outputForm = Angle::OutputForm::Degrees; const Angle::OutputForm outputForm = Angle::OutputForm::Degrees;
cout << locations.front().toString(outputForm); cout << locations.front().toString(outputForm);
if(locations.size() > 1) { if (locations.size() > 1) {
cout << "&daddr="; cout << "&daddr=";
cout << locations.at(1).toString(outputForm); cout << locations.at(1).toString(outputForm);
} }
if(locations.size() > 2) { if (locations.size() > 2) {
for(vector<Location>::const_iterator i = locations.cbegin() + 2, end = locations.cend(); i != end; ++i) { for (vector<Location>::const_iterator i = locations.cbegin() + 2, end = locations.cend(); i != end; ++i) {
cout << "+to:"; cout << "+to:";
cout << i->toString(outputForm); cout << i->toString(outputForm);
} }
@ -334,7 +337,7 @@ void printMapsLink(const string &filePath)
} else { } else {
throw Failure("At least one location is required to generate a link."); throw Failure("At least one location is required to generate a link.");
} }
} catch(...) { } catch (...) {
const char *what = ::IoUtilities::catchIoFailure(); const char *what = ::IoUtilities::catchIoFailure();
cout << "An IO failure occured when reading file from provided path: " << what << endl; cout << "An IO failure occured when reading file from provided path: " << what << endl;
} }

7
main.h
View File

@ -8,11 +8,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
enum class SystemForLocations enum class SystemForLocations { LatitudeLongitude, UTMWGS84 };
{
LatitudeLongitude,
UTMWGS84
};
extern Angle::AngularMeasure inputAngularMeasure; extern Angle::AngularMeasure inputAngularMeasure;
extern Angle::OutputForm outputFormForAngles; extern Angle::OutputForm outputFormForAngles;
@ -35,5 +31,4 @@ void printDestination(const std::string &locationstr, const std::string &distanc
void printLocation(const Location &location); void printLocation(const Location &location);
void printMapsLink(const std::string &filePath); void printMapsLink(const std::string &filePath);
#endif // MAIN_H_INCLUDED #endif // MAIN_H_INCLUDED