Adapt to changes in c++utilities
This commit is contained in:
parent
533ecbef96
commit
245a5f6803
|
@ -1,6 +1,6 @@
|
|||
#include "./angle.h"
|
||||
|
||||
#include <c++utilities/application/failure.h>
|
||||
#include <c++utilities/misc/parseerror.h>
|
||||
#include <c++utilities/conversion/stringconversion.h>
|
||||
|
||||
#include <cmath>
|
||||
|
@ -13,8 +13,7 @@
|
|||
#endif
|
||||
|
||||
using namespace std;
|
||||
using namespace ApplicationUtilities;
|
||||
using namespace ConversionUtilities;
|
||||
using namespace CppUtilities;
|
||||
|
||||
Angle::Angle()
|
||||
: m_val(0)
|
||||
|
@ -46,14 +45,14 @@ Angle::Angle(const string &value, AngularMeasure measure)
|
|||
if (mpos == string::npos)
|
||||
m_val += stringToNumber<double>(value);
|
||||
else if (mpos >= (value.length() - 1))
|
||||
throw Failure("excepted minutes after ':' in " + value);
|
||||
throw ParseError("excepted minutes after ':' in " + value);
|
||||
else {
|
||||
m_val += stringToNumber<double>(value.substr(0, mpos));
|
||||
spos = value.find(':', mpos + 1);
|
||||
if (spos == string::npos)
|
||||
m_val += stringToNumber<double>(value.substr(mpos + 1)) / 60.0;
|
||||
else if (spos >= (value.length() - 1))
|
||||
throw Failure("excepted seconds after second ':'' in " + value);
|
||||
throw ParseError("excepted seconds after second ':'' in " + value);
|
||||
else
|
||||
m_val += (stringToNumber<double>(value.substr(mpos + 1, spos - mpos - 1)) / 60.0)
|
||||
+ (stringToNumber<double>(value.substr(spos + 1)) / 3600.0);
|
||||
|
|
15
location.cpp
15
location.cpp
|
@ -1,6 +1,6 @@
|
|||
#include "./location.h"
|
||||
|
||||
#include <c++utilities/application/failure.h>
|
||||
#include <c++utilities/misc/parseerror.h>
|
||||
#include <c++utilities/conversion/stringconversion.h>
|
||||
|
||||
#include <cmath>
|
||||
|
@ -8,8 +8,7 @@
|
|||
#include <sstream>
|
||||
|
||||
using namespace std;
|
||||
using namespace ApplicationUtilities;
|
||||
using namespace ConversionUtilities;
|
||||
using namespace CppUtilities;
|
||||
|
||||
// WGS84 Parameters
|
||||
#define WGS84_A 6378137.0 // major axis
|
||||
|
@ -54,11 +53,11 @@ Location::Location(const string &latitudeAndLongitude, Angle::AngularMeasure mea
|
|||
{
|
||||
string::size_type dpos = latitudeAndLongitude.find(',');
|
||||
if (dpos == string::npos)
|
||||
throw Failure("Pair of coordinates (latitude and longitude) required.");
|
||||
throw ParseError("Pair of coordinates (latitude and longitude) required.");
|
||||
else if (dpos >= (latitudeAndLongitude.length() - 1))
|
||||
throw Failure("No second longitude following after comma.");
|
||||
throw ParseError("No second longitude following after comma.");
|
||||
else if (latitudeAndLongitude.find(',', dpos + 1) != string::npos)
|
||||
throw Failure("More then 2 coordinates given.");
|
||||
throw ParseError("More then 2 coordinates given.");
|
||||
m_lat = Angle(latitudeAndLongitude.substr(0, dpos), measure);
|
||||
m_lon = Angle(latitudeAndLongitude.substr(dpos + 1), measure);
|
||||
}
|
||||
|
@ -199,7 +198,7 @@ Location Location::midpoint(const Location &location1, const Location &location2
|
|||
double Location::trackLength(const std::vector<Location> &track, bool circle)
|
||||
{
|
||||
if (track.size() < 2)
|
||||
throw Failure("At least two locations are required to calculate a distance.");
|
||||
throw ParseError("At least two locations are required to calculate a distance.");
|
||||
|
||||
const Location *location1 = &track.at(0);
|
||||
const Location *location2 = &track.at(1);
|
||||
|
@ -288,7 +287,7 @@ void Location::setValueByProvidedUtmWgs4Coordinates(const string &utmWgs4Coordin
|
|||
return;
|
||||
}
|
||||
}
|
||||
throw Failure("UTM coordinates incomplete.");
|
||||
throw ParseError("UTM coordinates incomplete.");
|
||||
}
|
||||
|
||||
void Location::setValueByProvidedUtmWgs4Coordinates(int zone, char zoneDesignator, double easting, double northing)
|
||||
|
|
11
main.cpp
11
main.cpp
|
@ -4,7 +4,7 @@
|
|||
#include "resources/config.h"
|
||||
|
||||
#include <c++utilities/application/argumentparser.h>
|
||||
#include <c++utilities/application/failure.h>
|
||||
#include <c++utilities/misc/parseerror.h>
|
||||
#include <c++utilities/conversion/stringbuilder.h>
|
||||
#include <c++utilities/conversion/stringconversion.h>
|
||||
|
||||
|
@ -13,8 +13,7 @@
|
|||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
using namespace ConversionUtilities;
|
||||
using namespace ApplicationUtilities;
|
||||
using namespace CppUtilities;
|
||||
|
||||
Angle::AngularMeasure inputAngularMeasure = Angle::AngularMeasure::Degree;
|
||||
Angle::OutputForm outputFormForAngles = Angle::OutputForm::Degrees;
|
||||
|
@ -103,7 +102,7 @@ int main(int argc, char *argv[])
|
|||
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.parseArgsOrExit(argc, argv);
|
||||
argparser.parseArgs(argc, argv);
|
||||
|
||||
if (inputAngularMeasureArg.isPresent()) {
|
||||
const char *inputFormat = inputAngularMeasureArg.values().front();
|
||||
|
@ -186,7 +185,7 @@ int main(int argc, char *argv[])
|
|||
cerr << "The provided numbers couldn't be parsed correctly." << endl;
|
||||
cerr << endl;
|
||||
printAngleFormatInfo(cerr);
|
||||
} catch (const Failure &ex) {
|
||||
} catch (const ParseError &ex) {
|
||||
cerr << "The provided locations/coordinates couldn't be parsed correctly: " << ex.what() << endl;
|
||||
cerr << endl;
|
||||
printAngleFormatInfo(cerr);
|
||||
|
@ -331,7 +330,7 @@ void printMapsLink(const string &filePath)
|
|||
}
|
||||
cout << "&mra=mi&mrsp=2&sz=16&z=16";
|
||||
} else {
|
||||
throw Failure("At least one location is required to generate a link.");
|
||||
throw ParseError("At least one location is required to generate a link.");
|
||||
}
|
||||
} catch (const std::ios_base::failure &failure) {
|
||||
cout << "An IO failure occured when reading file from provided path: " << failure.what() << endl;
|
||||
|
|
Loading…
Reference in New Issue