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