Moving coordinate auxiliary functions into the appropriate place
This commit is contained in:
parent
aecbcdd390
commit
cfa8b1f0dd
@ -21,6 +21,8 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
#ifndef COORDINATE_H_
|
#ifndef COORDINATE_H_
|
||||||
#define COORDINATE_H_
|
#define COORDINATE_H_
|
||||||
|
|
||||||
|
#include "../Util/StringUtil.h"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <climits>
|
#include <climits>
|
||||||
@ -87,7 +89,7 @@ inline double ApproximateDistance(const _Coordinate &c1, const _Coordinate &c2)
|
|||||||
return ApproximateDistance( c1.lat, c1.lon, c2.lat, c2.lon );
|
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.lat != INT_MIN);
|
||||||
assert(c1.lon != INT_MIN);
|
assert(c1.lon != INT_MIN);
|
||||||
assert(c2.lat != INT_MIN);
|
assert(c2.lat != INT_MIN);
|
||||||
@ -105,4 +107,30 @@ inline double ApproximateDistanceByEuclid(const _Coordinate &c1, const _Coordina
|
|||||||
return d;
|
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_ */
|
#endif /* COORDINATE_H_ */
|
||||||
|
@ -91,7 +91,7 @@ void DescriptionFactory::Run(const SearchEngine &sEngine, const unsigned zoomLev
|
|||||||
/** starts at index 1 */
|
/** starts at index 1 */
|
||||||
pathDescription[0].length = 0;
|
pathDescription[0].length = 0;
|
||||||
for(unsigned i = 1; i < pathDescription.size(); ++i) {
|
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;
|
double lengthOfSegment = 0;
|
||||||
|
@ -21,8 +21,6 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
#ifndef STRINGUTIL_H_
|
#ifndef STRINGUTIL_H_
|
||||||
#define STRINGUTIL_H_
|
#define STRINGUTIL_H_
|
||||||
|
|
||||||
|
|
||||||
#include "../DataStructures/Coordinate.h"
|
|
||||||
#include "../typedefs.h"
|
#include "../typedefs.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -95,32 +93,6 @@ static inline void doubleToStringWithTwoDigitsBehindComma(const double value, st
|
|||||||
output = buffer ;
|
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) {
|
inline void replaceAll(std::string &s, const std::string &sub, const std::string &other) {
|
||||||
boost::replace_all(s, sub, other);
|
boost::replace_all(s, sub, other);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user