traffic signal penalty gets incorporated now into routing data.

This commit is contained in:
DennisOSRM
2012-02-28 16:25:01 +01:00
parent 8d83ce47e9
commit 300f7370c8
3 changed files with 42 additions and 15 deletions
+21 -1
View File
@@ -24,14 +24,30 @@
#include <algorithm>
#endif
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/ini_parser.hpp>
#include "../Util/OpenMPReplacement.h"
#include "EdgeBasedGraphFactory.h"
template<>
EdgeBasedGraphFactory::EdgeBasedGraphFactory(int nodes, std::vector<NodeBasedEdge> & inputEdges, std::vector<NodeID> & bn, std::vector<NodeID> & tl, std::vector<_Restriction> & irs, std::vector<NodeInfo> & nI, std::string & srtm)
EdgeBasedGraphFactory::EdgeBasedGraphFactory(int nodes, std::vector<NodeBasedEdge> & inputEdges, std::vector<NodeID> & bn, std::vector<NodeID> & tl, std::vector<_Restriction> & irs, std::vector<NodeInfo> & nI, boost::property_tree::ptree speedProfile, std::string & srtm)
: inputRestrictions(irs), inputNodeInfoList(nI)/*, srtmLookup(srtm) */{
std::string usedSpeedProfile(speedProfile.get_child("").begin()->first);
BOOST_FOREACH(boost::property_tree::ptree::value_type &v, speedProfile.get_child(usedSpeedProfile)) {
if("trafficSignalPenalty" == v.first) {
std::string value = v.second.get<std::string>("");
try {
trafficSignalPenalty = 10*boost::lexical_cast<int>(v.second.get<std::string>(""));
} catch(boost::bad_lexical_cast &) {
trafficSignalPenalty = 0;
}
}
}
INFO("Using traffic signal penalty: " << trafficSignalPenalty );
#ifdef _GLIBCXX_PARALLEL
__gnu_parallel::sort(inputRestrictions.begin(), inputRestrictions.end(), CmpRestrictionByFrom);
#else
@@ -225,6 +241,10 @@ void EdgeBasedGraphFactory::Run() {
unsigned nameID = _nodeBasedGraph->GetEdgeData(e2).nameID;
short turnInstruction = AnalyzeTurn(u, v, w);
if(_trafficLights.find(v) != _trafficLights.end()) {
distance += trafficSignalPenalty;
}
//create edge-based graph edge
EdgeBasedEdge newEdge(edgeBasedSource, edgeBasedTarget, v, nameID, distance, true, false, turnInstruction);
edgeBasedEdges.push_back(newEdge);
+13 -5
View File
@@ -26,8 +26,13 @@
#define EDGEBASEDGRAPHFACTORY_H_
#include <boost/shared_ptr.hpp>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/ini_parser.hpp>
#include <vector>
#include <cstdlib>
#include "../typedefs.h"
#include "../DataStructures/DynamicGraph.h"
#include "../DataStructures/ExtractorStructs.h"
@@ -35,6 +40,8 @@
#include "../DataStructures/ImportEdge.h"
#include "../DataStructures/Percent.h"
#include "../DataStructures/TurnInstructions.h"
#include "../Util/BaseConfiguration.h"
//#include "../Util/SRTMLookup.h"
class EdgeBasedGraphFactory {
@@ -82,12 +89,13 @@ public:
};
private:
boost::shared_ptr<_NodeBasedDynamicGraph> _nodeBasedGraph;
boost::unordered_map<NodeID, bool> _barrierNodes;
boost::unordered_map<NodeID, bool> _trafficLights;
boost::shared_ptr<_NodeBasedDynamicGraph> _nodeBasedGraph;
boost::unordered_map<NodeID, bool> _barrierNodes;
boost::unordered_map<NodeID, bool> _trafficLights;
std::vector<_Restriction> & inputRestrictions;
std::vector<NodeInfo> & inputNodeInfoList;
std::vector<NodeInfo> & inputNodeInfoList;
int trafficSignalPenalty;
std::vector<EdgeBasedEdge> edgeBasedEdges;
std::vector<EdgeBasedNode> edgeBasedNodes;
@@ -98,7 +106,7 @@ private:
public:
template< class InputEdgeT >
explicit EdgeBasedGraphFactory(int nodes, std::vector<InputEdgeT> & inputEdges, std::vector<NodeID> & _bollardNodes, std::vector<NodeID> & trafficLights, std::vector<_Restriction> & inputRestrictions, std::vector<NodeInfo> & nI, std::string & srtm);
explicit EdgeBasedGraphFactory(int nodes, std::vector<InputEdgeT> & inputEdges, std::vector<NodeID> & _bollardNodes, std::vector<NodeID> & trafficLights, std::vector<_Restriction> & inputRestrictions, std::vector<NodeInfo> & nI, boost::property_tree::ptree speedProfile, std::string & srtm);
virtual ~EdgeBasedGraphFactory();
void Run();