From cfa8b1f0dd6f781cd12932658d30dac3104bf1d2 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Thu, 27 Jun 2013 09:45:28 -0400 Subject: [PATCH] Moving coordinate auxiliary functions into the appropriate place --- DataStructures/Coordinate.h | 30 +++++++++++++++++++++++++++++- Descriptors/DescriptionFactory.cpp | 2 +- Util/StringUtil.h | 28 ---------------------------- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/DataStructures/Coordinate.h b/DataStructures/Coordinate.h index bc6328991..11ae3069e 100644 --- a/DataStructures/Coordinate.h +++ b/DataStructures/Coordinate.h @@ -21,6 +21,8 @@ or see http://www.gnu.org/licenses/agpl.txt. #ifndef COORDINATE_H_ #define COORDINATE_H_ +#include "../Util/StringUtil.h" + #include #include #include @@ -87,7 +89,7 @@ inline double ApproximateDistance(const _Coordinate &c1, const _Coordinate &c2) return ApproximateDistance( c1.lat, c1.lon, c2.lat, c2.lon ); } -inline double ApproximateDistanceByEuclid(const _Coordinate &c1, const _Coordinate &c2) { +inline double ApproximateEuclideanDistance(const _Coordinate &c1, const _Coordinate &c2) { assert(c1.lat != INT_MIN); assert(c1.lon != INT_MIN); assert(c2.lat != INT_MIN); @@ -105,4 +107,30 @@ inline double ApproximateDistanceByEuclid(const _Coordinate &c1, const _Coordina return d; } +static inline void convertInternalLatLonToString(const int value, std::string & output) { + char buffer[100]; + buffer[10] = 0; // Nullterminierung + char* string = printInt< 10, 5 >( buffer, value ); + output = string; +} + +static inline void convertInternalCoordinateToString(const _Coordinate & coord, std::string & output) { + std::string tmp; + convertInternalLatLonToString(coord.lon, tmp); + output = tmp; + output += ","; + convertInternalLatLonToString(coord.lat, tmp); + output += tmp; + output += " "; +} +static inline void convertInternalReversedCoordinateToString(const _Coordinate & coord, std::string & output) { + std::string tmp; + convertInternalLatLonToString(coord.lat, tmp); + output = tmp; + output += ","; + convertInternalLatLonToString(coord.lon, tmp); + output += tmp; + output += " "; +} + #endif /* COORDINATE_H_ */ diff --git a/Descriptors/DescriptionFactory.cpp b/Descriptors/DescriptionFactory.cpp index b1f2f8538..63e8883eb 100644 --- a/Descriptors/DescriptionFactory.cpp +++ b/Descriptors/DescriptionFactory.cpp @@ -91,7 +91,7 @@ void DescriptionFactory::Run(const SearchEngine &sEngine, const unsigned zoomLev /** starts at index 1 */ pathDescription[0].length = 0; for(unsigned i = 1; i < pathDescription.size(); ++i) { - pathDescription[i].length = ApproximateDistanceByEuclid(pathDescription[i-1].location, pathDescription[i].location); + pathDescription[i].length = ApproximateEuclideanDistance(pathDescription[i-1].location, pathDescription[i].location); } double lengthOfSegment = 0; diff --git a/Util/StringUtil.h b/Util/StringUtil.h index 951a21c4a..3c1b590f1 100644 --- a/Util/StringUtil.h +++ b/Util/StringUtil.h @@ -21,8 +21,6 @@ or see http://www.gnu.org/licenses/agpl.txt. #ifndef STRINGUTIL_H_ #define STRINGUTIL_H_ - -#include "../DataStructures/Coordinate.h" #include "../typedefs.h" #include @@ -95,32 +93,6 @@ static inline void doubleToStringWithTwoDigitsBehindComma(const double value, st output = buffer ; } -static inline void convertInternalLatLonToString(const int value, std::string & output) { - char buffer[100]; - buffer[10] = 0; // Nullterminierung - char* string = printInt< 10, 5 >( buffer, value ); - output = string; -} - -static inline void convertInternalCoordinateToString(const _Coordinate & coord, std::string & output) { - std::string tmp; - convertInternalLatLonToString(coord.lon, tmp); - output = tmp; - output += ","; - convertInternalLatLonToString(coord.lat, tmp); - output += tmp; - output += " "; -} -static inline void convertInternalReversedCoordinateToString(const _Coordinate & coord, std::string & output) { - std::string tmp; - convertInternalLatLonToString(coord.lat, tmp); - output = tmp; - output += ","; - convertInternalLatLonToString(coord.lon, tmp); - output += tmp; - output += " "; -} - inline void replaceAll(std::string &s, const std::string &sub, const std::string &other) { boost::replace_all(s, sub, other); }