Complete removal of speedprofile.ini and further adaption of
profile.lua
This commit is contained in:
		
							parent
							
								
									eac900c6b8
								
							
						
					
					
						commit
						3e0b4ee1e5
					
				| @ -18,19 +18,10 @@ | ||||
|  or see http://www.gnu.org/licenses/agpl.txt.
 | ||||
|  */ | ||||
| 
 | ||||
| #include <algorithm> | ||||
| #include <queue> | ||||
| #include <boost/foreach.hpp> | ||||
| #include <boost/lexical_cast.hpp> | ||||
| #include <boost/property_tree/ptree.hpp> | ||||
| #include <boost/property_tree/ini_parser.hpp> | ||||
| 
 | ||||
| #include "../Util/OpenMPWrapper.h" | ||||
| #include "../DataStructures/Percent.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, 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<NodeBasedEdge> & inputEdges, std::vector<NodeID> & bn, std::vector<NodeID> & tl, std::vector<_Restriction> & irs, std::vector<NodeInfo> & nI, SpeedProfileProperties sp, std::string & srtm) : inputNodeInfoList(nI), numberOfTurnRestrictions(irs.size()), speedProfile(sp) { | ||||
|     BOOST_FOREACH(_Restriction & restriction, irs) { | ||||
|         std::pair<NodeID, NodeID> restrictionSource = std::make_pair(restriction.fromNode, restriction.viaNode); | ||||
|         unsigned index; | ||||
| @ -53,32 +44,6 @@ EdgeBasedGraphFactory::EdgeBasedGraphFactory(int nodes, std::vector<NodeBasedEdg | ||||
|         _restrictionBucketVector.at(index).push_back(std::make_pair(restriction.toNode, restriction.flags.isOnly)); | ||||
|     } | ||||
| 
 | ||||
|     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; | ||||
|             } | ||||
|         } | ||||
|         if("uturnPenalty" ==  v.first) { | ||||
|             std::string value = v.second.get<std::string>(""); | ||||
|             try { | ||||
|                 uturnPenalty = 10*boost::lexical_cast<int>(v.second.get<std::string>("")); | ||||
|             } catch(boost::bad_lexical_cast &) { | ||||
|                 uturnPenalty = 0; | ||||
|             } | ||||
|         } | ||||
|         if("takeMinimumOfSpeeds" ==  v.first) { | ||||
|             std::string value = v.second.get<std::string>(""); | ||||
|             takeMinimumOfSpeeds = (v.second.get<std::string>("") == "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;
 | ||||
|  | ||||
| @ -25,14 +25,17 @@ | ||||
| #ifndef EDGEBASEDGRAPHFACTORY_H_ | ||||
| #define EDGEBASEDGRAPHFACTORY_H_ | ||||
| 
 | ||||
| #include <boost/shared_ptr.hpp> | ||||
| #include <boost/property_tree/ptree.hpp> | ||||
| #include <boost/property_tree/ini_parser.hpp> | ||||
| 
 | ||||
| #include <algorithm> | ||||
| #include <queue> | ||||
| #include <vector> | ||||
| #include <stxxl.h> | ||||
| #include <cstdlib> | ||||
| 
 | ||||
| #include <boost/foreach.hpp> | ||||
| #include <boost/lexical_cast.hpp> | ||||
| #include <boost/shared_ptr.hpp> | ||||
| 
 | ||||
| 
 | ||||
| #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<NodeID, bool>          _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<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); | ||||
|     explicit EdgeBasedGraphFactory(int nodes, std::vector<InputEdgeT> & inputEdges, std::vector<NodeID> & _bollardNodes, std::vector<NodeID> & trafficLights, std::vector<_Restriction> & inputRestrictions, std::vector<NodeInfo> & nI, SpeedProfileProperties speedProfile, std::string & srtm); | ||||
| 
 | ||||
|     void Run(const char * originalEdgeDataFilename); | ||||
|     void GetEdgeBasedEdges( DeallocatingVector< EdgeBasedEdge >& edges ); | ||||
|  | ||||
							
								
								
									
										29
									
								
								profile.lua
									
									
									
									
									
								
							
							
						
						
									
										29
									
								
								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 | ||||
| 		 | ||||
|  | ||||
| @ -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 | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user