merged
This commit is contained in:
commit
f1e5afd9ee
@ -101,7 +101,7 @@ public:
|
|||||||
std::string oneway( w.keyVals.Find("oneway"));
|
std::string oneway( w.keyVals.Find("oneway"));
|
||||||
std::string junction( w.keyVals.Find("junction") );
|
std::string junction( w.keyVals.Find("junction") );
|
||||||
std::string route( w.keyVals.Find("route") );
|
std::string route( w.keyVals.Find("route") );
|
||||||
double maxspeed( atoi(w.keyVals.Find("maxspeed").c_str()) );
|
int maxspeed( atoi(w.keyVals.Find("maxspeed").c_str()) );
|
||||||
std::string access( w.keyVals.Find("access") );
|
std::string access( w.keyVals.Find("access") );
|
||||||
std::string accessTag( w.keyVals.Find(settings.accessTag) );
|
std::string accessTag( w.keyVals.Find(settings.accessTag) );
|
||||||
std::string man_made( w.keyVals.Find("man_made") );
|
std::string man_made( w.keyVals.Find("man_made") );
|
||||||
@ -119,12 +119,17 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Is the highway tag listed as usable way?
|
//Is the highway tag listed as usable way?
|
||||||
if(0 < settings[highway]) {
|
if(0 < settings[highway] || "yes" == accessTag || "designated" == accessTag) {
|
||||||
|
|
||||||
|
if(0 < settings[highway]) {
|
||||||
if(0 < maxspeed)
|
if(0 < maxspeed)
|
||||||
w.speed = maxspeed;
|
w.speed = std::min(maxspeed, settings[highway]);
|
||||||
else
|
else
|
||||||
w.speed = settings[highway];
|
w.speed = settings[highway];
|
||||||
|
} else {
|
||||||
|
w.speed = settings.defaultSpeed;
|
||||||
|
highway = "default";
|
||||||
|
}
|
||||||
w.useful = true;
|
w.useful = true;
|
||||||
|
|
||||||
//Okay, do we have access to that way?
|
//Okay, do we have access to that way?
|
||||||
@ -157,11 +162,16 @@ public:
|
|||||||
w.useful = true;
|
w.useful = true;
|
||||||
w.speed = settings[route];
|
w.speed = settings[route];
|
||||||
w.direction = _Way::bidirectional;
|
w.direction = _Way::bidirectional;
|
||||||
|
if(0 < settings[route])
|
||||||
|
highway = route;
|
||||||
|
else if (0 < settings[man_made]) {
|
||||||
|
highway = man_made;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( w.useful && w.access && (1 < w.path.size()) ) { //Only true if the way is specified by the speed profile
|
if ( w.useful && w.access && (1 < w.path.size()) ) { //Only true if the way is specified by the speed profile
|
||||||
//TODO: type is not set, perhaps use a bimap'ed speed profile to do set the type correctly?
|
//TODO: type is not set, perhaps use a bimap'ed speed profile to do set the type correctly?
|
||||||
w.type = 1;
|
w.type = settings.GetHighwayTypeID(highway);
|
||||||
|
|
||||||
//Get the unique identifier for the street name
|
//Get the unique identifier for the street name
|
||||||
const StringMap::const_iterator strit = stringMap->find(w.name);
|
const StringMap::const_iterator strit = stringMap->find(w.name);
|
||||||
|
@ -36,6 +36,7 @@ struct _PathData {
|
|||||||
};
|
};
|
||||||
|
|
||||||
typedef boost::unordered_map<std::string, NodeID > StringMap;
|
typedef boost::unordered_map<std::string, NodeID > StringMap;
|
||||||
|
typedef boost::unordered_map<std::string, std::pair<int, int> > StringToIntPairMap;
|
||||||
|
|
||||||
struct _Node : NodeInfo{
|
struct _Node : NodeInfo{
|
||||||
_Node(int _lat, int _lon, unsigned int _id) : NodeInfo(_lat, _lon, _id) {}
|
_Node(int _lat, int _lon, unsigned int _id) : NodeInfo(_lat, _lon, _id) {}
|
||||||
@ -254,19 +255,28 @@ struct CmpWayByID : public std::binary_function<_WayIDStartAndEndEdge, _WayIDSta
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct Settings {
|
struct Settings {
|
||||||
Settings() : obeyPollards(true), obeyOneways(true), useRestrictions(true), accessTag("motorcar") {}
|
Settings() : obeyPollards(true), obeyOneways(true), useRestrictions(true), accessTag("motorcar"), defaultSpeed(30), excludeFromGrid("ferry") {}
|
||||||
StringMap speedProfile;
|
StringToIntPairMap speedProfile;
|
||||||
int operator[](const string & param) const {
|
int operator[](const std::string & param) const {
|
||||||
if(speedProfile.find(param) == speedProfile.end())
|
if(speedProfile.find(param) == speedProfile.end())
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
return speedProfile.at(param);
|
return speedProfile.at(param).first;
|
||||||
|
}
|
||||||
|
int GetHighwayTypeID(const std::string & param) const {
|
||||||
|
if(speedProfile.find(param) == speedProfile.end()) {
|
||||||
|
DEBUG("There is a bug with highway \"" << param << "\"");
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
return speedProfile.at(param).second;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
bool obeyPollards;
|
bool obeyPollards;
|
||||||
bool obeyOneways;
|
bool obeyOneways;
|
||||||
bool useRestrictions;
|
bool useRestrictions;
|
||||||
string accessTag;
|
std::string accessTag;
|
||||||
|
int defaultSpeed;
|
||||||
|
std::string excludeFromGrid;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Cmp : public std::binary_function<NodeID, NodeID, bool> {
|
struct Cmp : public std::binary_function<NodeID, NodeID, bool> {
|
||||||
|
@ -304,18 +304,22 @@ public:
|
|||||||
|
|
||||||
_GridEdge smallestEdge;
|
_GridEdge smallestEdge;
|
||||||
_Coordinate tmp, newEndpoint;
|
_Coordinate tmp, newEndpoint;
|
||||||
double dist = (numeric_limits<double>::max)();
|
double dist = numeric_limits<double>::max();
|
||||||
BOOST_FOREACH(_GridEdge candidate, candidates) {
|
BOOST_FOREACH(_GridEdge candidate, candidates) {
|
||||||
double r = 0.;
|
double r = 0.;
|
||||||
double tmpDist = ComputeDistance(startCoord, candidate.startCoord, candidate.targetCoord, tmp, &r);
|
double tmpDist = ComputeDistance(startCoord, candidate.startCoord, candidate.targetCoord, tmp, &r);
|
||||||
if(DoubleEpsilonCompare(dist, tmpDist) && 1 == std::abs((int)candidate.edgeBasedNode-(int)resultNode.edgeBasedNode)) {
|
if(DoubleEpsilonCompare(dist, tmpDist) && 1 == std::abs((int)candidate.edgeBasedNode-(int)resultNode.edgeBasedNode)) {
|
||||||
resultNode.weight2 = candidate.weight;
|
resultNode.weight2 = candidate.weight;
|
||||||
|
// INFO("b) " << candidate.edgeBasedNode << ", dist: " << tmpDist);
|
||||||
if(candidate.edgeBasedNode < resultNode.edgeBasedNode) {
|
if(candidate.edgeBasedNode < resultNode.edgeBasedNode) {
|
||||||
resultNode.edgeBasedNode = candidate.edgeBasedNode;
|
resultNode.edgeBasedNode = candidate.edgeBasedNode;
|
||||||
std::swap(resultNode.weight1, resultNode.weight2);
|
std::swap(resultNode.weight1, resultNode.weight2);
|
||||||
}
|
}
|
||||||
|
// } else if(std::fabs(dist - tmpDist) < 1) {
|
||||||
|
// INFO("b) ignored " << candidate.edgeBasedNode << " at distance " << tmpDist);
|
||||||
}
|
}
|
||||||
if(tmpDist < dist && !DoubleEpsilonCompare(dist, tmpDist)) {
|
if(tmpDist < dist && !DoubleEpsilonCompare(dist, tmpDist)) {
|
||||||
|
// INFO("a) " << candidate.edgeBasedNode << ", dist: " << tmpDist);
|
||||||
resultNode.Reset();
|
resultNode.Reset();
|
||||||
resultNode.edgeBasedNode = candidate.edgeBasedNode;
|
resultNode.edgeBasedNode = candidate.edgeBasedNode;
|
||||||
resultNode.nodeBasedEdgeNameID = candidate.nameID;
|
resultNode.nodeBasedEdgeNameID = candidate.nameID;
|
||||||
@ -326,6 +330,8 @@ public:
|
|||||||
foundNode = true;
|
foundNode = true;
|
||||||
smallestEdge = candidate;
|
smallestEdge = candidate;
|
||||||
newEndpoint = tmp;
|
newEndpoint = tmp;
|
||||||
|
// } else if(tmpDist < dist) {
|
||||||
|
// INFO("a) ignored " << candidate.edgeBasedNode << " at distance " << std::fabs(dist - tmpDist));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,6 +353,7 @@ public:
|
|||||||
// INFO("New weight1: " << resultNode.weight1 << ", new weight2: " << resultNode.weight2);
|
// INFO("New weight1: " << resultNode.weight1 << ", new weight2: " << resultNode.weight2);
|
||||||
}
|
}
|
||||||
// INFO("bidirected: " << (resultNode.isBidirected() ? "yes" : "no") << "\n--")
|
// INFO("bidirected: " << (resultNode.isBidirected() ? "yes" : "no") << "\n--")
|
||||||
|
// INFO("selected node: " << resultNode.edgeBasedNode << ", bidirected: " << (resultNode.isBidirected() ? "yes" : "no") << "\n--")
|
||||||
return foundNode;
|
return foundNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,13 +91,17 @@ public:
|
|||||||
|
|
||||||
//insert start and/or target node of start edge
|
//insert start and/or target node of start edge
|
||||||
_forwardHeap->Insert(phantomNodes.startPhantom.edgeBasedNode, -phantomNodes.startPhantom.weight1, phantomNodes.startPhantom.edgeBasedNode);
|
_forwardHeap->Insert(phantomNodes.startPhantom.edgeBasedNode, -phantomNodes.startPhantom.weight1, phantomNodes.startPhantom.edgeBasedNode);
|
||||||
|
// INFO("a) forw insert " << phantomNodes.startPhantom.edgeBasedNode << ", weight: " << -phantomNodes.startPhantom.weight1);
|
||||||
if(phantomNodes.startPhantom.isBidirected() ) {
|
if(phantomNodes.startPhantom.isBidirected() ) {
|
||||||
|
// INFO("b) forw insert " << phantomNodes.startPhantom.edgeBasedNode+1 << ", weight: " << -phantomNodes.startPhantom.weight2);
|
||||||
_forwardHeap->Insert(phantomNodes.startPhantom.edgeBasedNode+1, -phantomNodes.startPhantom.weight2, phantomNodes.startPhantom.edgeBasedNode+1);
|
_forwardHeap->Insert(phantomNodes.startPhantom.edgeBasedNode+1, -phantomNodes.startPhantom.weight2, phantomNodes.startPhantom.edgeBasedNode+1);
|
||||||
}
|
}
|
||||||
//insert start and/or target node of target edge id
|
//insert start and/or target node of target edge id
|
||||||
_backwardHeap->Insert(phantomNodes.targetPhantom.edgeBasedNode, -phantomNodes.targetPhantom.weight1, phantomNodes.targetPhantom.edgeBasedNode);
|
_backwardHeap->Insert(phantomNodes.targetPhantom.edgeBasedNode, -phantomNodes.targetPhantom.weight2, phantomNodes.targetPhantom.edgeBasedNode);
|
||||||
|
// INFO("c) back insert " << phantomNodes.targetPhantom.edgeBasedNode << ", weight: " << -phantomNodes.targetPhantom.weight2);
|
||||||
if(phantomNodes.targetPhantom.isBidirected() ) {
|
if(phantomNodes.targetPhantom.isBidirected() ) {
|
||||||
_backwardHeap->Insert(phantomNodes.targetPhantom.edgeBasedNode+1, -phantomNodes.targetPhantom.weight2, phantomNodes.targetPhantom.edgeBasedNode+1);
|
_backwardHeap->Insert(phantomNodes.targetPhantom.edgeBasedNode+1, -phantomNodes.targetPhantom.weight1, phantomNodes.targetPhantom.edgeBasedNode+1);
|
||||||
|
// INFO("d) back insert " << phantomNodes.targetPhantom.edgeBasedNode+1 << ", weight: " << -phantomNodes.targetPhantom.weight1);
|
||||||
}
|
}
|
||||||
|
|
||||||
while(_forwardHeap->Size() + _backwardHeap->Size() > 0){
|
while(_forwardHeap->Size() + _backwardHeap->Size() > 0){
|
||||||
|
@ -134,11 +134,20 @@ int main (int argc, char *argv[]) {
|
|||||||
if(name == "accessTag") {
|
if(name == "accessTag") {
|
||||||
settings.accessTag = value;
|
settings.accessTag = value;
|
||||||
continue;
|
continue;
|
||||||
|
} else {
|
||||||
|
if(name == "excludeFromGrid") {
|
||||||
|
settings.excludeFromGrid = value;
|
||||||
|
} else {
|
||||||
|
if(name == "defaultSpeed") {
|
||||||
|
settings.defaultSpeed = atoi(value.c_str());
|
||||||
|
settings.speedProfile["default"] = std::make_pair(settings.defaultSpeed, settings.speedProfile.size() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
settings.speedProfile[name] = atoi(value.c_str());
|
}
|
||||||
|
settings.speedProfile[name] = std::make_pair(std::atoi(value.c_str()), settings.speedProfile.size() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch(std::exception& e) {
|
} catch(std::exception& e) {
|
||||||
ERR("caught: " << e.what() );
|
ERR("caught: " << e.what() );
|
||||||
@ -277,8 +286,6 @@ int main (int argc, char *argv[]) {
|
|||||||
|
|
||||||
if(UINT_MAX != restrictionsIT->restriction.fromNode && UINT_MAX != restrictionsIT->restriction.toNode) {
|
if(UINT_MAX != restrictionsIT->restriction.fromNode && UINT_MAX != restrictionsIT->restriction.toNode) {
|
||||||
++usableRestrictionsCounter;
|
++usableRestrictionsCounter;
|
||||||
} else {
|
|
||||||
INFO("Restriction from: " << restrictionsIT->restriction.fromNode << ", to: " << restrictionsIT->restriction.toNode);
|
|
||||||
}
|
}
|
||||||
++restrictionsIT;
|
++restrictionsIT;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user