Refactoring _Coordinate class
This commit is contained in:
parent
916387748c
commit
4748bca8a4
@ -56,11 +56,14 @@ private:
|
||||
}
|
||||
|
||||
public:
|
||||
inline void printEncodedString(const std::vector<SegmentInformation>& polyline, std::string &output) const {
|
||||
inline void printEncodedString(
|
||||
const std::vector<SegmentInformation> & polyline,
|
||||
std::string & output
|
||||
) const {
|
||||
std::vector<int> deltaNumbers;
|
||||
output += "\"";
|
||||
if(!polyline.empty()) {
|
||||
_Coordinate lastCoordinate = polyline[0].location;
|
||||
FixedPointCoordinate lastCoordinate = polyline[0].location;
|
||||
deltaNumbers.push_back( lastCoordinate.lat );
|
||||
deltaNumbers.push_back( lastCoordinate.lon );
|
||||
for(unsigned i = 1; i < polyline.size(); ++i) {
|
||||
@ -76,7 +79,7 @@ public:
|
||||
|
||||
}
|
||||
|
||||
inline void printEncodedString(const std::vector<_Coordinate>& polyline, std::string &output) const {
|
||||
inline void printEncodedString(const std::vector<FixedPointCoordinate>& polyline, std::string &output) const {
|
||||
std::vector<int> deltaNumbers(2*polyline.size());
|
||||
output += "\"";
|
||||
if(!polyline.empty()) {
|
||||
@ -91,7 +94,7 @@ public:
|
||||
output += "\"";
|
||||
}
|
||||
|
||||
inline void printUnencodedString(std::vector<_Coordinate> & polyline, std::string & output) const {
|
||||
inline void printUnencodedString(std::vector<FixedPointCoordinate> & polyline, std::string & output) const {
|
||||
output += "[";
|
||||
std::string tmp;
|
||||
for(unsigned i = 0; i < polyline.size(); i++) {
|
||||
|
@ -22,8 +22,8 @@
|
||||
|
||||
EdgeBasedGraphFactory::EdgeBasedGraphFactory(
|
||||
int nodes, std::vector<ImportEdge> & inputEdges,
|
||||
std::vector<NodeID> & bn,
|
||||
std::vector<NodeID> & tl,
|
||||
std::vector<NodeID> & barrier_node_list,
|
||||
std::vector<NodeID> & traffic_light_node_list,
|
||||
std::vector<TurnRestriction> & input_restrictions_list,
|
||||
std::vector<NodeInfo> & inputNodeInfoList,
|
||||
SpeedProfileProperties speedProfile
|
||||
@ -54,8 +54,15 @@ EdgeBasedGraphFactory::EdgeBasedGraphFactory(
|
||||
_restrictionBucketVector.at(index).push_back(std::make_pair(restriction.toNode, restriction.flags.isOnly));
|
||||
}
|
||||
|
||||
_barrierNodes.insert(bn.begin(), bn.end());
|
||||
_trafficLights.insert(tl.begin(), tl.end());
|
||||
_barrierNodes.insert(
|
||||
barrier_node_list.begin(),
|
||||
barrier_node_list.end()
|
||||
);
|
||||
|
||||
_trafficLights.insert(
|
||||
traffic_light_node_list.begin(),
|
||||
traffic_light_node_list.end()
|
||||
);
|
||||
|
||||
DeallocatingVector< _NodeBasedEdge > edges;
|
||||
_NodeBasedEdge edge;
|
||||
|
@ -75,8 +75,8 @@ public:
|
||||
return id == other.id;
|
||||
}
|
||||
|
||||
inline _Coordinate Centroid() const {
|
||||
_Coordinate centroid;
|
||||
inline FixedPointCoordinate Centroid() const {
|
||||
FixedPointCoordinate centroid;
|
||||
//The coordinates of the midpoint are given by:
|
||||
//x = (x1 + x2) /2 and y = (y1 + y2) /2.
|
||||
centroid.lon = (std::min(lon1, lon2) + std::max(lon1, lon2))/2;
|
||||
@ -87,6 +87,7 @@ public:
|
||||
inline bool isIgnored() const {
|
||||
return ignoreInGrid;
|
||||
}
|
||||
|
||||
NodeID id;
|
||||
int lat1;
|
||||
int lat2;
|
||||
|
@ -18,8 +18,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
or see http://www.gnu.org/licenses/agpl.txt.
|
||||
*/
|
||||
|
||||
#ifndef COORDINATE_H_
|
||||
#define COORDINATE_H_
|
||||
#ifndef FIXED_POINT_COORDINATE_H_
|
||||
#define FIXED_POINT_COORDINATE_H_
|
||||
|
||||
#include "../Util/StringUtil.h"
|
||||
|
||||
@ -31,11 +31,11 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
||||
|
||||
static const double COORDINATE_PRECISION = 1000000.;
|
||||
|
||||
struct _Coordinate {
|
||||
struct FixedPointCoordinate {
|
||||
int lat;
|
||||
int lon;
|
||||
_Coordinate () : lat(INT_MIN), lon(INT_MIN) {}
|
||||
explicit _Coordinate (int t, int n) : lat(t) , lon(n) {}
|
||||
FixedPointCoordinate () : lat(INT_MIN), lon(INT_MIN) {}
|
||||
explicit FixedPointCoordinate (int t, int n) : lat(t) , lon(n) {}
|
||||
|
||||
void Reset() {
|
||||
lat = INT_MIN;
|
||||
@ -55,12 +55,12 @@ struct _Coordinate {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool operator==(const _Coordinate & other) const {
|
||||
bool operator==(const FixedPointCoordinate & other) const {
|
||||
return lat == other.lat && lon == other.lon;
|
||||
}
|
||||
};
|
||||
|
||||
inline std::ostream & operator<<(std::ostream & out, const _Coordinate & c){
|
||||
inline std::ostream & operator<<(std::ostream & out, const FixedPointCoordinate & c){
|
||||
out << "(" << c.lat << "," << c.lon << ")";
|
||||
return out;
|
||||
}
|
||||
@ -93,11 +93,11 @@ inline double ApproximateDistance( const int lat1, const int lon1, const int lat
|
||||
return distance;
|
||||
}
|
||||
|
||||
inline double ApproximateDistance(const _Coordinate &c1, const _Coordinate &c2) {
|
||||
inline double ApproximateDistance(const FixedPointCoordinate &c1, const FixedPointCoordinate &c2) {
|
||||
return ApproximateDistance( c1.lat, c1.lon, c2.lat, c2.lon );
|
||||
}
|
||||
|
||||
inline double ApproximateEuclideanDistance(const _Coordinate &c1, const _Coordinate &c2) {
|
||||
inline double ApproximateEuclideanDistance(const FixedPointCoordinate &c1, const FixedPointCoordinate &c2) {
|
||||
assert(c1.lat != INT_MIN);
|
||||
assert(c1.lon != INT_MIN);
|
||||
assert(c2.lat != INT_MIN);
|
||||
@ -122,7 +122,7 @@ static inline void convertInternalLatLonToString(const int value, std::string &
|
||||
output = string;
|
||||
}
|
||||
|
||||
static inline void convertInternalCoordinateToString(const _Coordinate & coord, std::string & output) {
|
||||
static inline void convertInternalCoordinateToString(const FixedPointCoordinate & coord, std::string & output) {
|
||||
std::string tmp;
|
||||
convertInternalLatLonToString(coord.lon, tmp);
|
||||
output = tmp;
|
||||
@ -131,7 +131,7 @@ static inline void convertInternalCoordinateToString(const _Coordinate & coord,
|
||||
output += tmp;
|
||||
output += " ";
|
||||
}
|
||||
static inline void convertInternalReversedCoordinateToString(const _Coordinate & coord, std::string & output) {
|
||||
static inline void convertInternalReversedCoordinateToString(const FixedPointCoordinate & coord, std::string & output) {
|
||||
std::string tmp;
|
||||
convertInternalLatLonToString(coord.lat, tmp);
|
||||
output = tmp;
|
||||
@ -141,4 +141,4 @@ static inline void convertInternalReversedCoordinateToString(const _Coordinate &
|
||||
output += " ";
|
||||
}
|
||||
|
||||
#endif /* COORDINATE_H_ */
|
||||
#endif /* FIXED_POINT_COORDINATE_H_ */
|
||||
|
@ -31,7 +31,8 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
||||
class HilbertCode : boost::noncopyable {
|
||||
public:
|
||||
static uint64_t GetHilbertNumberForCoordinate(
|
||||
const _Coordinate & current_coordinate) {
|
||||
const FixedPointCoordinate & current_coordinate
|
||||
) {
|
||||
unsigned location[2];
|
||||
location[0] = current_coordinate.lat+( 90*COORDINATE_PRECISION);
|
||||
location[1] = current_coordinate.lon+(180*COORDINATE_PRECISION);
|
||||
|
@ -107,8 +107,8 @@ public:
|
||||
}
|
||||
|
||||
inline bool FindNearestNodeCoordForLatLon(
|
||||
const _Coordinate& input_coordinate,
|
||||
_Coordinate& result,
|
||||
const FixedPointCoordinate& input_coordinate,
|
||||
FixedPointCoordinate& result,
|
||||
const unsigned zoom_level = 18
|
||||
) const {
|
||||
PhantomNode resulting_phantom_node;
|
||||
@ -121,7 +121,7 @@ public:
|
||||
}
|
||||
|
||||
inline bool FindPhantomNodeForCoordinate(
|
||||
const _Coordinate & input_coordinate,
|
||||
const FixedPointCoordinate & input_coordinate,
|
||||
PhantomNode & resulting_phantom_node,
|
||||
const unsigned zoom_level
|
||||
) const {
|
||||
@ -164,9 +164,9 @@ private:
|
||||
NodeInfo b;
|
||||
while(!nodes_input_stream.eof()) {
|
||||
nodes_input_stream.read((char *)&b, sizeof(NodeInfo));
|
||||
coordinateVector.push_back(_Coordinate(b.lat, b.lon));
|
||||
coordinateVector.push_back(FixedPointCoordinate(b.lat, b.lon));
|
||||
}
|
||||
std::vector<_Coordinate>(coordinateVector).swap(coordinateVector);
|
||||
std::vector<FixedPointCoordinate>(coordinateVector).swap(coordinateVector);
|
||||
nodes_input_stream.close();
|
||||
|
||||
SimpleLogger().Write(logDEBUG) << "Loading edge data";
|
||||
@ -191,7 +191,7 @@ private:
|
||||
SimpleLogger().Write(logDEBUG) << "Opening NN indices";
|
||||
}
|
||||
|
||||
std::vector<_Coordinate> coordinateVector;
|
||||
std::vector<FixedPointCoordinate> coordinateVector;
|
||||
std::vector<NodeID> origEdgeData_viaNode;
|
||||
std::vector<unsigned> origEdgeData_nameID;
|
||||
std::vector<TurnInstruction> origEdgeData_turnInstruction;
|
||||
|
@ -24,13 +24,20 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
||||
#include "Coordinate.h"
|
||||
|
||||
struct PhantomNode {
|
||||
PhantomNode() : edgeBasedNode(UINT_MAX), nodeBasedEdgeNameID(UINT_MAX), weight1(INT_MAX), weight2(INT_MAX), ratio(0.) {}
|
||||
PhantomNode() :
|
||||
edgeBasedNode(UINT_MAX),
|
||||
nodeBasedEdgeNameID(UINT_MAX),
|
||||
weight1(INT_MAX),
|
||||
weight2(INT_MAX),
|
||||
ratio(0.)
|
||||
{ }
|
||||
|
||||
NodeID edgeBasedNode;
|
||||
unsigned nodeBasedEdgeNameID;
|
||||
int weight1;
|
||||
int weight2;
|
||||
double ratio;
|
||||
_Coordinate location;
|
||||
FixedPointCoordinate location;
|
||||
void Reset() {
|
||||
edgeBasedNode = UINT_MAX;
|
||||
nodeBasedEdgeNameID = UINT_MAX;
|
||||
@ -88,7 +95,7 @@ inline std::ostream& operator<<(std::ostream &out, const PhantomNode & pn){
|
||||
struct NodesOfEdge {
|
||||
NodeID edgeBasedNode;
|
||||
double ratio;
|
||||
_Coordinate projectedPoint;
|
||||
FixedPointCoordinate projectedPoint;
|
||||
};
|
||||
|
||||
#endif /* PHANTOMNODES_H_ */
|
||||
|
@ -33,14 +33,14 @@ SearchEngine::SearchEngine(
|
||||
|
||||
void SearchEngine::GetCoordinatesForNodeID(
|
||||
NodeID id,
|
||||
_Coordinate& result
|
||||
FixedPointCoordinate& result
|
||||
) const {
|
||||
result.lat = _queryData.nodeHelpDesk->getLatitudeOfNode(id);
|
||||
result.lon = _queryData.nodeHelpDesk->getLongitudeOfNode(id);
|
||||
}
|
||||
|
||||
void SearchEngine::FindPhantomNodeForCoordinate(
|
||||
const _Coordinate & location,
|
||||
const FixedPointCoordinate & location,
|
||||
PhantomNode & result,
|
||||
const unsigned zoomLevel
|
||||
) const {
|
||||
|
@ -45,17 +45,17 @@ public:
|
||||
AlternativeRouting<SearchEngineData> alternativePaths;
|
||||
|
||||
SearchEngine(
|
||||
QueryGraph * g,
|
||||
NodeInformationHelpDesk * nh,
|
||||
QueryGraph * g,
|
||||
NodeInformationHelpDesk * nh,
|
||||
std::vector<std::string> & n
|
||||
);
|
||||
~SearchEngine();
|
||||
|
||||
void GetCoordinatesForNodeID(NodeID id, _Coordinate& result) const;
|
||||
void GetCoordinatesForNodeID(NodeID id, FixedPointCoordinate& result) const;
|
||||
|
||||
void FindPhantomNodeForCoordinate(
|
||||
const _Coordinate & location,
|
||||
PhantomNode & result,
|
||||
const FixedPointCoordinate & location,
|
||||
PhantomNode & result,
|
||||
unsigned zoomLevel
|
||||
) const;
|
||||
|
||||
|
@ -27,16 +27,16 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
||||
#include <climits>
|
||||
|
||||
struct SegmentInformation {
|
||||
_Coordinate location;
|
||||
FixedPointCoordinate location;
|
||||
NodeID nameID;
|
||||
double length;
|
||||
unsigned duration;
|
||||
double bearing;
|
||||
TurnInstruction turnInstruction;
|
||||
bool necessary;
|
||||
SegmentInformation(const _Coordinate & loc, const NodeID nam, const double len, const unsigned dur, const TurnInstruction tInstr, const bool nec) :
|
||||
SegmentInformation(const FixedPointCoordinate & loc, const NodeID nam, const double len, const unsigned dur, const TurnInstruction tInstr, const bool nec) :
|
||||
location(loc), nameID(nam), length(len), duration(dur), bearing(0.), turnInstruction(tInstr), necessary(nec) {}
|
||||
SegmentInformation(const _Coordinate & loc, const NodeID nam, const double len, const unsigned dur, const TurnInstruction tInstr) :
|
||||
SegmentInformation(const FixedPointCoordinate & loc, const NodeID nam, const double len, const unsigned dur, const TurnInstruction tInstr) :
|
||||
location(loc), nameID(nam), length(len), duration(dur), bearing(0.), turnInstruction(tInstr), necessary(tInstr != 0) {}
|
||||
};
|
||||
|
||||
|
@ -100,8 +100,8 @@ private:
|
||||
max_lat = std::max(max_lat, other.max_lat);
|
||||
}
|
||||
|
||||
inline _Coordinate Centroid() const {
|
||||
_Coordinate centroid;
|
||||
inline FixedPointCoordinate Centroid() const {
|
||||
FixedPointCoordinate centroid;
|
||||
//The coordinates of the midpoints are given by:
|
||||
//x = (x1 + x2) /2 and y = (y1 + y2) /2.
|
||||
centroid.lon = (min_lon + max_lon)/2;
|
||||
@ -110,10 +110,10 @@ private:
|
||||
}
|
||||
|
||||
inline bool Intersects(const RectangleInt2D & other) const {
|
||||
_Coordinate upper_left (other.max_lat, other.min_lon);
|
||||
_Coordinate upper_right(other.max_lat, other.max_lon);
|
||||
_Coordinate lower_right(other.min_lat, other.max_lon);
|
||||
_Coordinate lower_left (other.min_lat, other.min_lon);
|
||||
FixedPointCoordinate upper_left (other.max_lat, other.min_lon);
|
||||
FixedPointCoordinate upper_right(other.max_lat, other.max_lon);
|
||||
FixedPointCoordinate lower_right(other.min_lat, other.max_lon);
|
||||
FixedPointCoordinate lower_left (other.min_lat, other.min_lon);
|
||||
|
||||
return (
|
||||
Contains(upper_left)
|
||||
@ -123,7 +123,7 @@ private:
|
||||
);
|
||||
}
|
||||
|
||||
inline double GetMinDist(const _Coordinate & location) const {
|
||||
inline double GetMinDist(const FixedPointCoordinate & location) const {
|
||||
bool is_contained = Contains(location);
|
||||
if (is_contained) {
|
||||
return 0.0;
|
||||
@ -169,13 +169,13 @@ private:
|
||||
return min_dist;
|
||||
}
|
||||
|
||||
inline double GetMinMaxDist(const _Coordinate & location) const {
|
||||
inline double GetMinMaxDist(const FixedPointCoordinate & location) const {
|
||||
double min_max_dist = DBL_MAX;
|
||||
//Get minmax distance to each of the four sides
|
||||
_Coordinate upper_left (max_lat, min_lon);
|
||||
_Coordinate upper_right(max_lat, max_lon);
|
||||
_Coordinate lower_right(min_lat, max_lon);
|
||||
_Coordinate lower_left (min_lat, min_lon);
|
||||
FixedPointCoordinate upper_left (max_lat, min_lon);
|
||||
FixedPointCoordinate upper_right(max_lat, max_lon);
|
||||
FixedPointCoordinate lower_right(min_lat, max_lon);
|
||||
FixedPointCoordinate lower_left (min_lat, min_lon);
|
||||
|
||||
min_max_dist = std::min(
|
||||
min_max_dist,
|
||||
@ -211,7 +211,7 @@ private:
|
||||
return min_max_dist;
|
||||
}
|
||||
|
||||
inline bool Contains(const _Coordinate & location) const {
|
||||
inline bool Contains(const FixedPointCoordinate & location) const {
|
||||
bool lats_contained =
|
||||
(location.lat > min_lat) && (location.lat < max_lat);
|
||||
bool lons_contained =
|
||||
@ -303,7 +303,7 @@ public:
|
||||
input_wrapper_vector[element_counter].m_array_index = element_counter;
|
||||
//Get Hilbert-Value for centroid in mercartor projection
|
||||
DataT & current_element = input_data_vector[element_counter];
|
||||
_Coordinate current_centroid = current_element.Centroid();
|
||||
FixedPointCoordinate current_centroid = current_element.Centroid();
|
||||
current_centroid.lat = COORDINATE_PRECISION*lat2y(current_centroid.lat/COORDINATE_PRECISION);
|
||||
|
||||
uint64_t current_hilbert_value = HilbertCode::GetHilbertNumberForCoordinate(current_centroid);
|
||||
@ -449,7 +449,7 @@ public:
|
||||
}
|
||||
/*
|
||||
inline void FindKNearestPhantomNodesForCoordinate(
|
||||
const _Coordinate & location,
|
||||
const FixedPointCoordinate & location,
|
||||
const unsigned zoom_level,
|
||||
const unsigned candidate_count,
|
||||
std::vector<std::pair<PhantomNode, double> > & result_vector
|
||||
@ -465,7 +465,7 @@ public:
|
||||
double min_max_dist = DBL_MAX;
|
||||
bool found_a_nearest_edge = false;
|
||||
|
||||
_Coordinate nearest, current_start_coordinate, current_end_coordinate;
|
||||
FixedPointCoordinate nearest, current_start_coordinate, current_end_coordinate;
|
||||
|
||||
//initialize queue with root element
|
||||
std::priority_queue<QueryCandidate> traversal_queue;
|
||||
@ -493,8 +493,8 @@ public:
|
||||
double current_ratio = 0.;
|
||||
double current_perpendicular_distance = ComputePerpendicularDistance(
|
||||
input_coordinate,
|
||||
_Coordinate(current_edge.lat1, current_edge.lon1),
|
||||
_Coordinate(current_edge.lat2, current_edge.lon2),
|
||||
FixedPointCoordinate(current_edge.lat1, current_edge.lon1),
|
||||
FixedPointCoordinate(current_edge.lat2, current_edge.lon2),
|
||||
nearest,
|
||||
¤t_ratio
|
||||
);
|
||||
@ -523,11 +523,11 @@ public:
|
||||
1 == abs(current_edge.id - result_phantom_node.edgeBasedNode )
|
||||
&& CoordinatesAreEquivalent(
|
||||
current_start_coordinate,
|
||||
_Coordinate(
|
||||
FixedPointCoordinate(
|
||||
current_edge.lat1,
|
||||
current_edge.lon1
|
||||
),
|
||||
_Coordinate(
|
||||
FixedPointCoordinate(
|
||||
current_edge.lat2,
|
||||
current_edge.lon2
|
||||
),
|
||||
@ -563,14 +563,14 @@ public:
|
||||
|
||||
const double distance_to_edge =
|
||||
ApproximateDistance (
|
||||
_Coordinate(nearest_edge.lat1, nearest_edge.lon1),
|
||||
FixedPointCoordinate(nearest_edge.lat1, nearest_edge.lon1),
|
||||
result_phantom_node.location
|
||||
);
|
||||
|
||||
const double length_of_edge =
|
||||
ApproximateDistance(
|
||||
_Coordinate(nearest_edge.lat1, nearest_edge.lon1),
|
||||
_Coordinate(nearest_edge.lat2, nearest_edge.lon2)
|
||||
FixedPointCoordinate(nearest_edge.lat1, nearest_edge.lon1),
|
||||
FixedPointCoordinate(nearest_edge.lat2, nearest_edge.lon2)
|
||||
);
|
||||
|
||||
const double ratio = (found_a_nearest_edge ?
|
||||
@ -596,7 +596,7 @@ public:
|
||||
|
||||
*/
|
||||
bool FindPhantomNodeForCoordinate(
|
||||
const _Coordinate & input_coordinate,
|
||||
const FixedPointCoordinate & input_coordinate,
|
||||
PhantomNode & result_phantom_node,
|
||||
const unsigned zoom_level
|
||||
) {
|
||||
@ -611,7 +611,7 @@ public:
|
||||
double min_max_dist = DBL_MAX;
|
||||
bool found_a_nearest_edge = false;
|
||||
|
||||
_Coordinate nearest, current_start_coordinate, current_end_coordinate;
|
||||
FixedPointCoordinate nearest, current_start_coordinate, current_end_coordinate;
|
||||
|
||||
//initialize queue with root element
|
||||
std::priority_queue<QueryCandidate> traversal_queue;
|
||||
@ -650,8 +650,8 @@ public:
|
||||
double current_ratio = 0.;
|
||||
double current_perpendicular_distance = ComputePerpendicularDistance(
|
||||
input_coordinate,
|
||||
_Coordinate(current_edge.lat1, current_edge.lon1),
|
||||
_Coordinate(current_edge.lat2, current_edge.lon2),
|
||||
FixedPointCoordinate(current_edge.lat1, current_edge.lon1),
|
||||
FixedPointCoordinate(current_edge.lat2, current_edge.lon2),
|
||||
nearest,
|
||||
¤t_ratio
|
||||
);
|
||||
@ -680,11 +680,11 @@ public:
|
||||
1 == abs(current_edge.id - result_phantom_node.edgeBasedNode )
|
||||
&& CoordinatesAreEquivalent(
|
||||
current_start_coordinate,
|
||||
_Coordinate(
|
||||
FixedPointCoordinate(
|
||||
current_edge.lat1,
|
||||
current_edge.lon1
|
||||
),
|
||||
_Coordinate(
|
||||
FixedPointCoordinate(
|
||||
current_edge.lat2,
|
||||
current_edge.lon2
|
||||
),
|
||||
@ -768,10 +768,10 @@ private:
|
||||
}
|
||||
|
||||
inline double ComputePerpendicularDistance(
|
||||
const _Coordinate& inputPoint,
|
||||
const _Coordinate& source,
|
||||
const _Coordinate& target,
|
||||
_Coordinate& nearest, double *r) const {
|
||||
const FixedPointCoordinate& inputPoint,
|
||||
const FixedPointCoordinate& source,
|
||||
const FixedPointCoordinate& target,
|
||||
FixedPointCoordinate& nearest, double *r) const {
|
||||
const double x = static_cast<double>(inputPoint.lat);
|
||||
const double y = static_cast<double>(inputPoint.lon);
|
||||
const double a = static_cast<double>(source.lat);
|
||||
@ -815,7 +815,7 @@ private:
|
||||
return (p-x)*(p-x) + (q-y)*(q-y);
|
||||
}
|
||||
|
||||
inline bool CoordinatesAreEquivalent(const _Coordinate & a, const _Coordinate & b, const _Coordinate & c, const _Coordinate & d) const {
|
||||
inline bool CoordinatesAreEquivalent(const FixedPointCoordinate & a, const FixedPointCoordinate & b, const FixedPointCoordinate & c, const FixedPointCoordinate & d) const {
|
||||
return (a == b && c == d) || (a == c && b == d) || (a == d && b == c);
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,10 @@ inline double DescriptionFactory::RadianToDegree(const double radian) const {
|
||||
return radian * (180/M_PI);
|
||||
}
|
||||
|
||||
double DescriptionFactory::GetBearing(const _Coordinate& A, const _Coordinate& B) const {
|
||||
double DescriptionFactory::GetBearing(
|
||||
const FixedPointCoordinate & A,
|
||||
const FixedPointCoordinate & B
|
||||
) const {
|
||||
double deltaLong = DegreeToRadian(B.lon/COORDINATE_PRECISION - A.lon/COORDINATE_PRECISION);
|
||||
|
||||
double lat1 = DegreeToRadian(A.lat/COORDINATE_PRECISION);
|
||||
@ -59,7 +62,7 @@ void DescriptionFactory::SetEndSegment(const PhantomNode & _targetPhantom) {
|
||||
pathDescription.push_back(SegmentInformation(_targetPhantom.location, _targetPhantom.nodeBasedEdgeNameID, 0, _targetPhantom.weight1, 0, true) );
|
||||
}
|
||||
|
||||
void DescriptionFactory::AppendSegment(const _Coordinate & coordinate, const _PathData & data ) {
|
||||
void DescriptionFactory::AppendSegment(const FixedPointCoordinate & coordinate, const _PathData & data ) {
|
||||
if(1 == pathDescription.size() && pathDescription.back().location == coordinate) {
|
||||
pathDescription.back().nameID = data.nameID;
|
||||
} else {
|
||||
|
@ -63,10 +63,10 @@ public:
|
||||
std::vector <SegmentInformation> pathDescription;
|
||||
DescriptionFactory();
|
||||
virtual ~DescriptionFactory();
|
||||
double GetBearing(const _Coordinate& C, const _Coordinate& B) const;
|
||||
double GetBearing(const FixedPointCoordinate& C, const FixedPointCoordinate& B) const;
|
||||
void AppendEncodedPolylineString(std::string &output);
|
||||
void AppendUnencodedPolylineString(std::string &output);
|
||||
void AppendSegment(const _Coordinate & coordinate, const _PathData & data);
|
||||
void AppendSegment(const FixedPointCoordinate & coordinate, const _PathData & data);
|
||||
void BuildRouteSummary(const double distance, const unsigned time);
|
||||
void SetStartSegment(const PhantomNode & startPhantom);
|
||||
void SetEndSegment(const PhantomNode & startPhantom);
|
||||
|
@ -28,7 +28,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
||||
class GPXDescriptor : public BaseDescriptor{
|
||||
private:
|
||||
_DescriptorConfig config;
|
||||
_Coordinate current;
|
||||
FixedPointCoordinate current;
|
||||
|
||||
std::string tmp;
|
||||
public:
|
||||
|
@ -39,7 +39,7 @@ private:
|
||||
_DescriptorConfig config;
|
||||
DescriptionFactory descriptionFactory;
|
||||
DescriptionFactory alternateDescriptionFactory;
|
||||
_Coordinate current;
|
||||
FixedPointCoordinate current;
|
||||
unsigned numberOfEnteredRestrictedAreas;
|
||||
struct RoundAbout{
|
||||
RoundAbout() :
|
||||
|
@ -21,7 +21,6 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
||||
#ifndef EXTRACTORSTRUCTS_H_
|
||||
#define EXTRACTORSTRUCTS_H_
|
||||
|
||||
|
||||
#include "../DataStructures/Coordinate.h"
|
||||
#include "../DataStructures/HashTable.h"
|
||||
#include "../DataStructures/ImportNode.h"
|
||||
@ -110,8 +109,8 @@ struct InternalExtractorEdge {
|
||||
bool isAccessRestricted;
|
||||
bool isContraFlow;
|
||||
|
||||
_Coordinate startCoord;
|
||||
_Coordinate targetCoord;
|
||||
FixedPointCoordinate startCoord;
|
||||
FixedPointCoordinate targetCoord;
|
||||
|
||||
static InternalExtractorEdge min_value() {
|
||||
return InternalExtractorEdge(0,0);
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
virtual const std::string & GetDescriptor() const = 0;
|
||||
virtual void HandleRequest(const RouteParameters & routeParameters, http::Reply& reply) = 0;
|
||||
|
||||
inline bool checkCoord(const _Coordinate & c) {
|
||||
inline bool checkCoord(const FixedPointCoordinate & c) {
|
||||
if(
|
||||
c.lat > 90*COORDINATE_PRECISION ||
|
||||
c.lat < -90*COORDINATE_PRECISION ||
|
||||
|
@ -48,7 +48,7 @@ public:
|
||||
}
|
||||
|
||||
//query to helpdesk
|
||||
_Coordinate result;
|
||||
FixedPointCoordinate result;
|
||||
std::string tmp;
|
||||
//json
|
||||
|
||||
|
@ -35,7 +35,7 @@ struct RawRouteData {
|
||||
std::vector< _PathData > computedShortestPath;
|
||||
std::vector< _PathData > computedAlternativePath;
|
||||
std::vector< PhantomNodes > segmentEndCoordinates;
|
||||
std::vector< _Coordinate > rawViaNodeCoordinates;
|
||||
std::vector< FixedPointCoordinate > rawViaNodeCoordinates;
|
||||
unsigned checkSum;
|
||||
int lengthOfShortestPath;
|
||||
int lengthOfAlternativePath;
|
||||
|
@ -52,7 +52,7 @@ struct RouteParameters {
|
||||
std::string jsonpParameter;
|
||||
std::string language;
|
||||
std::vector<std::string> hints;
|
||||
std::vector<_Coordinate> coordinates;
|
||||
std::vector<FixedPointCoordinate> coordinates;
|
||||
typedef HashTable<std::string, std::string>::const_iterator OptionsIterator;
|
||||
|
||||
void setZoomLevel(const short i) {
|
||||
@ -109,7 +109,7 @@ struct RouteParameters {
|
||||
void addCoordinate(const boost::fusion::vector < double, double > & arg_) {
|
||||
int lat = COORDINATE_PRECISION*boost::fusion::at_c < 0 > (arg_);
|
||||
int lon = COORDINATE_PRECISION*boost::fusion::at_c < 1 > (arg_);
|
||||
coordinates.push_back(_Coordinate(lat, lon));
|
||||
coordinates.push_back(FixedPointCoordinate(lat, lon));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -65,8 +65,8 @@ int main (int argc, char * argv[]) {
|
||||
route_parameters.language = ""; //unused atm
|
||||
//route_parameters.hints.push_back(); // see wiki, saves I/O if done properly
|
||||
|
||||
_Coordinate start_coordinate(52.519930*COORDINATE_PRECISION,13.438640*COORDINATE_PRECISION);
|
||||
_Coordinate target_coordinate(52.513191*COORDINATE_PRECISION,13.415852*COORDINATE_PRECISION);
|
||||
FixedPointCoordinate start_coordinate(52.519930*COORDINATE_PRECISION,13.438640*COORDINATE_PRECISION);
|
||||
FixedPointCoordinate target_coordinate(52.513191*COORDINATE_PRECISION,13.415852*COORDINATE_PRECISION);
|
||||
route_parameters.coordinates.push_back(start_coordinate);
|
||||
route_parameters.coordinates.push_back(target_coordinate);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user