Hide functional road classification based on tags in implementation file
This commit is contained in:
		
							parent
							
								
									b45efeb4bd
								
							
						
					
					
						commit
						458a1c8157
					
				| @ -1,12 +1,9 @@ | |||||||
| #ifndef OSRM_EXTRACTOR_CLASSIFICATION_DATA_HPP_ | #ifndef OSRM_EXTRACTOR_CLASSIFICATION_DATA_HPP_ | ||||||
| #define OSRM_EXTRACTOR_CLASSIFICATION_DATA_HPP_ | #define OSRM_EXTRACTOR_CLASSIFICATION_DATA_HPP_ | ||||||
| 
 | 
 | ||||||
| #include "util/simple_logger.hpp" |  | ||||||
| 
 |  | ||||||
| #include <cstdint> | #include <cstdint> | ||||||
| 
 | 
 | ||||||
| #include <string> | #include <string> | ||||||
| #include <unordered_map> |  | ||||||
| 
 | 
 | ||||||
| // Forward Declaration to allow usage of external osmium::Way
 | // Forward Declaration to allow usage of external osmium::Way
 | ||||||
| namespace osmium | namespace osmium | ||||||
| @ -41,43 +38,7 @@ enum class FunctionalRoadClass : std::uint8_t | |||||||
|     LOW_PRIORITY_ROAD // a road simply included for connectivity. Should be avoided at all cost
 |     LOW_PRIORITY_ROAD // a road simply included for connectivity. Should be avoided at all cost
 | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| inline FunctionalRoadClass functionalRoadClassFromTag(std::string const &value) | FunctionalRoadClass functionalRoadClassFromTag(std::string const &tag); | ||||||
| { |  | ||||||
|     // FIXME at some point this should be part of the profiles
 |  | ||||||
|     const static auto class_hash = [] |  | ||||||
|     { |  | ||||||
|         std::unordered_map<std::string, FunctionalRoadClass> hash; |  | ||||||
|         hash["motorway"] = FunctionalRoadClass::MOTORWAY; |  | ||||||
|         hash["motorway_link"] = FunctionalRoadClass::MOTORWAY_LINK; |  | ||||||
|         hash["trunk"] = FunctionalRoadClass::TRUNK; |  | ||||||
|         hash["trunk_link"] = FunctionalRoadClass::TRUNK_LINK; |  | ||||||
|         hash["primary"] = FunctionalRoadClass::PRIMARY; |  | ||||||
|         hash["primary_link"] = FunctionalRoadClass::PRIMARY_LINK; |  | ||||||
|         hash["secondary"] = FunctionalRoadClass::SECONDARY; |  | ||||||
|         hash["secondary_link"] = FunctionalRoadClass::SECONDARY_LINK; |  | ||||||
|         hash["tertiary"] = FunctionalRoadClass::TERTIARY; |  | ||||||
|         hash["tertiary_link"] = FunctionalRoadClass::TERTIARY_LINK; |  | ||||||
|         hash["unclassified"] = FunctionalRoadClass::UNCLASSIFIED; |  | ||||||
|         hash["residential"] = FunctionalRoadClass::RESIDENTIAL; |  | ||||||
|         hash["service"] = FunctionalRoadClass::SERVICE; |  | ||||||
|         hash["living_street"] = FunctionalRoadClass::LIVING_STREET; |  | ||||||
|         hash["track"] = FunctionalRoadClass::LOW_PRIORITY_ROAD; |  | ||||||
|         hash["road"] = FunctionalRoadClass::LOW_PRIORITY_ROAD; |  | ||||||
|         hash["path"] = FunctionalRoadClass::LOW_PRIORITY_ROAD; |  | ||||||
|         hash["driveway"] = FunctionalRoadClass::LOW_PRIORITY_ROAD; |  | ||||||
|         return hash; |  | ||||||
|     }(); |  | ||||||
| 
 |  | ||||||
|     if (class_hash.find(value) != class_hash.end()) |  | ||||||
|     { |  | ||||||
|         return class_hash.find(value)->second; |  | ||||||
|     } |  | ||||||
|     else |  | ||||||
|     { |  | ||||||
|         util::SimpleLogger().Write(logDEBUG) << "Unknown road class encountered: " << value; |  | ||||||
|         return FunctionalRoadClass::UNKNOWN; |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| 
 | 
 | ||||||
| inline bool isRampClass(const FunctionalRoadClass road_class) | inline bool isRampClass(const FunctionalRoadClass road_class) | ||||||
| { | { | ||||||
|  | |||||||
							
								
								
									
										53
									
								
								src/extractor/guidance/classification_data.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								src/extractor/guidance/classification_data.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,53 @@ | |||||||
|  | #include "extractor/guidance/classification_data.hpp" | ||||||
|  | #include "util/simple_logger.hpp" | ||||||
|  | 
 | ||||||
|  | #include <unordered_map> | ||||||
|  | 
 | ||||||
|  | namespace osrm | ||||||
|  | { | ||||||
|  | namespace extractor | ||||||
|  | { | ||||||
|  | namespace guidance | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  | FunctionalRoadClass functionalRoadClassFromTag(std::string const &value) | ||||||
|  | { | ||||||
|  |     // FIXME at some point this should be part of the profiles
 | ||||||
|  |     const static auto class_hash = [] | ||||||
|  |     { | ||||||
|  |         std::unordered_map<std::string, FunctionalRoadClass> hash; | ||||||
|  |         hash["motorway"] = FunctionalRoadClass::MOTORWAY; | ||||||
|  |         hash["motorway_link"] = FunctionalRoadClass::MOTORWAY_LINK; | ||||||
|  |         hash["trunk"] = FunctionalRoadClass::TRUNK; | ||||||
|  |         hash["trunk_link"] = FunctionalRoadClass::TRUNK_LINK; | ||||||
|  |         hash["primary"] = FunctionalRoadClass::PRIMARY; | ||||||
|  |         hash["primary_link"] = FunctionalRoadClass::PRIMARY_LINK; | ||||||
|  |         hash["secondary"] = FunctionalRoadClass::SECONDARY; | ||||||
|  |         hash["secondary_link"] = FunctionalRoadClass::SECONDARY_LINK; | ||||||
|  |         hash["tertiary"] = FunctionalRoadClass::TERTIARY; | ||||||
|  |         hash["tertiary_link"] = FunctionalRoadClass::TERTIARY_LINK; | ||||||
|  |         hash["unclassified"] = FunctionalRoadClass::UNCLASSIFIED; | ||||||
|  |         hash["residential"] = FunctionalRoadClass::RESIDENTIAL; | ||||||
|  |         hash["service"] = FunctionalRoadClass::SERVICE; | ||||||
|  |         hash["living_street"] = FunctionalRoadClass::LIVING_STREET; | ||||||
|  |         hash["track"] = FunctionalRoadClass::LOW_PRIORITY_ROAD; | ||||||
|  |         hash["road"] = FunctionalRoadClass::LOW_PRIORITY_ROAD; | ||||||
|  |         hash["path"] = FunctionalRoadClass::LOW_PRIORITY_ROAD; | ||||||
|  |         hash["driveway"] = FunctionalRoadClass::LOW_PRIORITY_ROAD; | ||||||
|  |         return hash; | ||||||
|  |     }(); | ||||||
|  | 
 | ||||||
|  |     if (class_hash.find(value) != class_hash.end()) | ||||||
|  |     { | ||||||
|  |         return class_hash.find(value)->second; | ||||||
|  |     } | ||||||
|  |     else | ||||||
|  |     { | ||||||
|  |         util::SimpleLogger().Write(logDEBUG) << "Unknown road class encountered: " << value; | ||||||
|  |         return FunctionalRoadClass::UNKNOWN; | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | } // ns guidance
 | ||||||
|  | } // ns extractor
 | ||||||
|  | } // ns osrm
 | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user