From 3e0b4ee1e534f53d08f5bdfe1e18b284e598d9be Mon Sep 17 00:00:00 2001 From: DennisOSRM Date: Thu, 13 Sep 2012 13:59:46 +0200 Subject: [PATCH] Complete removal of speedprofile.ini and further adaption of profile.lua --- Contractor/EdgeBasedGraphFactory.cpp | 41 ++----------------- Contractor/EdgeBasedGraphFactory.h | 22 ++++++---- profile.lua | 29 ++++++++----- speedprofile.ini | 61 ---------------------------- 4 files changed, 35 insertions(+), 118 deletions(-) delete mode 100644 speedprofile.ini diff --git a/Contractor/EdgeBasedGraphFactory.cpp b/Contractor/EdgeBasedGraphFactory.cpp index da26d5fba..cbbc5b7ae 100644 --- a/Contractor/EdgeBasedGraphFactory.cpp +++ b/Contractor/EdgeBasedGraphFactory.cpp @@ -18,19 +18,10 @@ or see http://www.gnu.org/licenses/agpl.txt. */ -#include -#include -#include -#include -#include -#include - -#include "../Util/OpenMPWrapper.h" -#include "../DataStructures/Percent.h" #include "EdgeBasedGraphFactory.h" template<> -EdgeBasedGraphFactory::EdgeBasedGraphFactory(int nodes, std::vector & inputEdges, std::vector & bn, std::vector & tl, std::vector<_Restriction> & irs, std::vector & nI, boost::property_tree::ptree speedProfile, std::string & srtm) : inputNodeInfoList(nI), numberOfTurnRestrictions(irs.size()), trafficSignalPenalty(0), uturnPenalty(0), takeMinimumOfSpeeds(false) { +EdgeBasedGraphFactory::EdgeBasedGraphFactory(int nodes, std::vector & inputEdges, std::vector & bn, std::vector & tl, std::vector<_Restriction> & irs, std::vector & nI, SpeedProfileProperties sp, std::string & srtm) : inputNodeInfoList(nI), numberOfTurnRestrictions(irs.size()), speedProfile(sp) { BOOST_FOREACH(_Restriction & restriction, irs) { std::pair restrictionSource = std::make_pair(restriction.fromNode, restriction.viaNode); unsigned index; @@ -53,32 +44,6 @@ EdgeBasedGraphFactory::EdgeBasedGraphFactory(int nodes, std::vectorfirst ); - BOOST_FOREACH(boost::property_tree::ptree::value_type &v, speedProfile.get_child(usedSpeedProfile)) { - if("trafficSignalPenalty" == v.first) { - std::string value = v.second.get(""); - try { - trafficSignalPenalty = 10*boost::lexical_cast(v.second.get("")); - } catch(boost::bad_lexical_cast &) { - trafficSignalPenalty = 0; - } - } - if("uturnPenalty" == v.first) { - std::string value = v.second.get(""); - try { - uturnPenalty = 10*boost::lexical_cast(v.second.get("")); - } catch(boost::bad_lexical_cast &) { - uturnPenalty = 0; - } - } - if("takeMinimumOfSpeeds" == v.first) { - std::string value = v.second.get(""); - takeMinimumOfSpeeds = (v.second.get("") == "yes"); - } - } - - // INFO("traffic signal penalty: " << trafficSignalPenalty << ", U-Turn penalty: " << uturnPenalty << ", takeMinimumOfSpeeds=" << (takeMinimumOfSpeeds ? "yes" : "no")); - BOOST_FOREACH(NodeID id, bn) { _barrierNodes[id] = true; } @@ -308,11 +273,11 @@ void EdgeBasedGraphFactory::Run(const char * originalEdgeDataFilename) { unsigned distance = edgeData1.distance; if(_trafficLights.find(v) != _trafficLights.end()) { - distance += trafficSignalPenalty; + distance += speedProfile.trafficSignalPenalty; } short turnInstruction = AnalyzeTurn(u, v, w); if(turnInstruction == TurnInstructions.UTurn) - distance += uturnPenalty; + distance += speedProfile.uTurnPenalty; // if(!edgeData1.isAccessRestricted && edgeData2.isAccessRestricted) { // distance += TurnInstructions.AccessRestrictionPenalty; // turnInstruction |= TurnInstructions.AccessRestrictionFlag; diff --git a/Contractor/EdgeBasedGraphFactory.h b/Contractor/EdgeBasedGraphFactory.h index d4acb25ba..767259304 100644 --- a/Contractor/EdgeBasedGraphFactory.h +++ b/Contractor/EdgeBasedGraphFactory.h @@ -25,14 +25,17 @@ #ifndef EDGEBASEDGRAPHFACTORY_H_ #define EDGEBASEDGRAPHFACTORY_H_ -#include -#include -#include - +#include +#include #include #include #include +#include +#include +#include + + #include "../typedefs.h" #include "../DataStructures/DeallocatingVector.h" #include "../DataStructures/DynamicGraph.h" @@ -92,6 +95,12 @@ public: bool ignoreInGrid:1; }; + + struct SpeedProfileProperties{ + SpeedProfileProperties() : trafficSignalPenalty(0), uTurnPenalty(0) {} + int trafficSignalPenalty; + int uTurnPenalty; + } speedProfile; private: boost::shared_ptr<_NodeBasedDynamicGraph> _nodeBasedGraph; boost::unordered_map _barrierNodes; @@ -121,13 +130,10 @@ private: double GetAngleBetweenTwoEdges(const CoordinateT& A, const CoordinateT& C, const CoordinateT& B) const; // SRTMLookup srtmLookup; unsigned numberOfTurnRestrictions; - unsigned trafficSignalPenalty; - unsigned uturnPenalty; - bool takeMinimumOfSpeeds; public: template< class InputEdgeT > - explicit EdgeBasedGraphFactory(int nodes, std::vector & inputEdges, std::vector & _bollardNodes, std::vector & trafficLights, std::vector<_Restriction> & inputRestrictions, std::vector & nI, boost::property_tree::ptree speedProfile, std::string & srtm); + explicit EdgeBasedGraphFactory(int nodes, std::vector & inputEdges, std::vector & _bollardNodes, std::vector & trafficLights, std::vector<_Restriction> & inputRestrictions, std::vector & nI, SpeedProfileProperties speedProfile, std::string & srtm); void Run(const char * originalEdgeDataFilename); void GetEdgeBasedEdges( DeallocatingVector< EdgeBasedEdge >& edges ); diff --git a/profile.lua b/profile.lua index dbc786967..358430d8a 100644 --- a/profile.lua +++ b/profile.lua @@ -29,8 +29,13 @@ speed_profile = { ["default"] = 50 } -take_minimum_of_speeds = true -obey_oneway = true +take_minimum_of_speeds = true +obey_oneway = true +obey_bollards = true +use_restrictions = true +ignore_areas = true -- future feature +traffic_signal_penalty = 2 +u_turn_penalty = 20 -- End of globals @@ -45,14 +50,16 @@ function node_function (node) node.traffic_light = true; end - --flag node as unpassable if it black listed as unpassable - if access_tag_blacklist[barrier] then - node.bollard = true; - end - - --reverse the previous flag if there is an access tag specifying entrance - if node.bollard and not bollards_whitelist[barrier] and not access_tag_whitelist[barrier] then - node.bollard = false; + if obey_bollards then + --flag node as unpassable if it black listed as unpassable + if access_tag_blacklist[barrier] then + node.bollard = true; + end + + --reverse the previous flag if there is an access tag specifying entrance + if node.bollard and not bollards_whitelist[barrier] and not access_tag_whitelist[barrier] then + node.bollard = false; + end end return 1 end @@ -82,7 +89,7 @@ function way_function (way, numberOfNodesInWay) -- Second parse the way according to these properties - if("yes" == area) then + if ignore_areas and ("yes" == area) then return 0 end diff --git a/speedprofile.ini b/speedprofile.ini deleted file mode 100644 index bdf79ffd2..000000000 --- a/speedprofile.ini +++ /dev/null @@ -1,61 +0,0 @@ -[car] - motorway = 90 - motorway_link = 75 - trunk = 85 - trunk_link = 70 - primary = 65 - primary_link = 60 - secondary = 55 - secondary_link = 50 - tertiary = 40 - tertiary_link = 30 - unclassified = 25 - residential = 25 - living_street = 10 - service = 15 - track = 5 - ferry = 5 - pier = 5 - obeyBollards = yes - obeyOneways = yes - useRestrictions = yes - ignoreAreas = yes - accessTags = motorcar,motor_vehicle,vehicle,access - excludeFromGrid = ferry - defaultSpeed = 50 - trafficSignalPenalty = 2 - takeMinimumOfSpeeds = no - uturnPenalty = 20 - accessRestrictedService = parking_aisle - accessRestrictionKeys = destination,private,delivery,permissive - accessForbiddenKeys = no,private,agricultural,forestery - accessForbiddenDefault = track -[bike] - trunk = 16 - trunk_link = 16 - primary = 16 - primary_link = 16 - secondary = 16 - secondary_link = 16 - tertiary = 16 - tertiary_link = 16 - unclassified = 16 - residential = 16 - living_street = 16 - service = 16 - track = 16 - cycleway = 16 - path = 16 - ferry = 5 - pier = 5 - obeyOneways = yes - useRestrictions = no - accessTags = bicycle,vehicle,access - excludeFromGrid = ferry - defaultSpeed = 5 - trafficSignalPenalty = 5 - obeyBollards = no - takeMinimumOfSpeeds = yes - uturnPenalty = 20 - accessRestrictionKeys = destination,private,delivery - accessForbiddenKeys = no,private,agricultural,forestery