Support for backward speed in extractor
This commit is contained in:
		
							parent
							
								
									a64420d700
								
							
						
					
					
						commit
						7f69857376
					
				| @ -44,8 +44,8 @@ or see http://www.gnu.org/licenses/agpl.txt. | |||||||
| 
 | 
 | ||||||
| ExtractorCallbacks::ExtractorCallbacks() {externalMemory = NULL; stringMap = NULL; } | ExtractorCallbacks::ExtractorCallbacks() {externalMemory = NULL; stringMap = NULL; } | ||||||
| ExtractorCallbacks::ExtractorCallbacks(ExtractionContainers * ext, StringMap * strMap) { | ExtractorCallbacks::ExtractorCallbacks(ExtractionContainers * ext, StringMap * strMap) { | ||||||
|     externalMemory = ext; | 	externalMemory = ext; | ||||||
|     stringMap = strMap; | 	stringMap = strMap; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| ExtractorCallbacks::~ExtractorCallbacks() { | ExtractorCallbacks::~ExtractorCallbacks() { | ||||||
| @ -64,42 +64,71 @@ bool ExtractorCallbacks::restrictionFunction(_RawRestrictionContainer &r) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /** warning: caller needs to take care of synchronization! */ | /** warning: caller needs to take care of synchronization! */ | ||||||
| bool ExtractorCallbacks::wayFunction(_Way &w) { | bool ExtractorCallbacks::wayFunction(_Way &parsed_way) { | ||||||
|     /*** Store name of way and split it into edge segments ***/ | 	if ( parsed_way.speed > 0 ) { //Only true if the way is specified by the speed profile
 | ||||||
|  | 		if(parsed_way.id == UINT_MAX){ | ||||||
|  | 			WARN("found bogus way with id: " << parsed_way.id << " of size " << parsed_way.path.size()); | ||||||
|  | 			return true; | ||||||
|  | 		} | ||||||
|  | 		//Get the unique identifier for the street name
 | ||||||
|  | 		const StringMap::const_iterator string_map_iterator = stringMap->find(parsed_way.name); | ||||||
|  | 		if(string_map_iterator == stringMap->end()) { | ||||||
|  | 			parsed_way.nameID = externalMemory->nameVector.size(); | ||||||
|  | 			externalMemory->nameVector.push_back(parsed_way.name); | ||||||
|  | 			stringMap->insert(StringMap::value_type(parsed_way.name, parsed_way.nameID)); | ||||||
|  | 		} else { | ||||||
|  | 			parsed_way.nameID = string_map_iterator->second; | ||||||
|  | 		} | ||||||
| 
 | 
 | ||||||
|     if ( w.speed > 0 ) { //Only true if the way is specified by the speed profile
 | 		if ( parsed_way.direction == _Way::opposite ){ | ||||||
|  | 			std::reverse( parsed_way.path.begin(), parsed_way.path.end() ); | ||||||
|  | 		} | ||||||
| 
 | 
 | ||||||
|         //Get the unique identifier for the street name
 | 		if( parsed_way.backward_speed > 0 && parsed_way.direction == _Way::bidirectional) { | ||||||
|         const StringMap::const_iterator strit = stringMap->find(w.name); | 			parsed_way.direction == _Way::oneway; | ||||||
|         if(strit == stringMap->end()) { | 		} | ||||||
|             w.nameID = externalMemory->nameVector.size(); |  | ||||||
|             externalMemory->nameVector.push_back(w.name); |  | ||||||
|             stringMap->insert(StringMap::value_type(w.name, w.nameID)); |  | ||||||
|         } else { |  | ||||||
|             w.nameID = strit->second; |  | ||||||
|         } |  | ||||||
| 
 | 
 | ||||||
|         if(fabs(-1. - w.speed) < FLT_EPSILON){ | 		for(std::vector< NodeID >::size_type n = 0; n < parsed_way.path.size()-1; ++n) { | ||||||
|             WARN("found way with bogus speed, id: " << w.id); | 			externalMemory->allEdges.push_back( | ||||||
|             return true; | 					_Edge(parsed_way.path[n], | ||||||
|         } | 							parsed_way.path[n+1], | ||||||
|         if(w.id == UINT_MAX) { | 							parsed_way.type, | ||||||
|             WARN("found way with unknown type: " << w.id); | 							(_Way::bidirectional == parsed_way.direction && parsed_way.backward_speed > 0 ? _Way::oneway : parsed_way.direction), | ||||||
|             return true; | 							parsed_way.speed, | ||||||
|         } | 							parsed_way.nameID, | ||||||
|  | 							parsed_way.roundabout, | ||||||
|  | 							parsed_way.ignoreInGrid, | ||||||
|  | 							parsed_way.isDurationSet, | ||||||
|  | 							parsed_way.isAccessRestricted | ||||||
|  | 						) | ||||||
|  | 					); | ||||||
|  | 			externalMemory->usedNodeIDs.push_back(parsed_way.path[n]); | ||||||
|  | 		} | ||||||
|  | 		externalMemory->usedNodeIDs.push_back(parsed_way.path.back()); | ||||||
| 
 | 
 | ||||||
|         if ( w.direction == _Way::opposite ){ | 		//The following information is needed to identify start and end segments of restrictions
 | ||||||
|             std::reverse( w.path.begin(), w.path.end() ); | 		externalMemory->wayStartEndVector.push_back(_WayIDStartAndEndEdge(parsed_way.id, parsed_way.path[0], parsed_way.path[1], parsed_way.path[parsed_way.path.size()-2], parsed_way.path.back())); | ||||||
|         } |  | ||||||
| 
 | 
 | ||||||
|         for(std::vector< NodeID >::size_type n = 0; n < w.path.size()-1; ++n) { | 		if ( parsed_way.backward_speed > 0 ) { //Only true if the way should be split
 | ||||||
|             externalMemory->allEdges.push_back(_Edge(w.path[n], w.path[n+1], w.type, w.direction, w.speed, w.nameID, w.roundabout, w.ignoreInGrid, w.isDurationSet, w.isAccessRestricted)); | 			std::reverse( parsed_way.path.begin(), parsed_way.path.end() ); | ||||||
|             externalMemory->usedNodeIDs.push_back(w.path[n]); | 			for(std::vector< NodeID >::size_type n = 0; n < parsed_way.path.size()-1; ++n) { | ||||||
|         } | 				externalMemory->allEdges.push_back( | ||||||
|         externalMemory->usedNodeIDs.push_back(w.path.back()); | 						_Edge(parsed_way.path[n], | ||||||
| 
 | 								parsed_way.path[n+1], | ||||||
|         //The following information is needed to identify start and end segments of restrictions
 | 								parsed_way.type, | ||||||
|         externalMemory->wayStartEndVector.push_back(_WayIDStartAndEndEdge(w.id, w.path[0], w.path[1], w.path[w.path.size()-2], w.path[w.path.size()-1])); | 								_Way::oneway, | ||||||
|     } | 								parsed_way.backward_speed, | ||||||
|     return true; | 								parsed_way.nameID, | ||||||
|  | 								parsed_way.roundabout, | ||||||
|  | 								parsed_way.ignoreInGrid, | ||||||
|  | 								parsed_way.isDurationSet, | ||||||
|  | 								parsed_way.isAccessRestricted, | ||||||
|  | 								(_Way::oneway == parsed_way.direction) | ||||||
|  | 							) | ||||||
|  | 						); | ||||||
|  | 			} | ||||||
|  | 			externalMemory->wayStartEndVector.push_back(_WayIDStartAndEndEdge(parsed_way.id, parsed_way.path[0], parsed_way.path[1], parsed_way.path[parsed_way.path.size()-2], parsed_way.path.back())); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	return true; | ||||||
| } | } | ||||||
|  | |||||||
| @ -52,6 +52,7 @@ struct _Way { | |||||||
| 		keyVals.EraseAll(); | 		keyVals.EraseAll(); | ||||||
|         direction = _Way::notSure; |         direction = _Way::notSure; | ||||||
|         speed = -1; |         speed = -1; | ||||||
|  |         backward_speed = -1; | ||||||
|         type = -1; |         type = -1; | ||||||
|         access = true; |         access = true; | ||||||
|         roundabout = false; |         roundabout = false; | ||||||
| @ -67,6 +68,7 @@ struct _Way { | |||||||
|     unsigned nameID; |     unsigned nameID; | ||||||
|     std::string name; |     std::string name; | ||||||
|     double speed; |     double speed; | ||||||
|  |     double backward_speed; | ||||||
|     short type; |     short type; | ||||||
|     bool access; |     bool access; | ||||||
|     bool roundabout; |     bool roundabout; | ||||||
| @ -86,10 +88,13 @@ struct _Relation { | |||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| struct _Edge { | struct _Edge { | ||||||
|     _Edge() : start(0), target(0), type(0), direction(0), speed(0), nameID(0), isRoundabout(false), ignoreInGrid(false), isDurationSet(false), isAccessRestricted(false) {}; |     _Edge() : start(0), target(0), type(0), direction(0), speed(0), nameID(0), isRoundabout(false), ignoreInGrid(false), isDurationSet(false), isAccessRestricted(false), isContraFlow(false) {}; | ||||||
|     _Edge(NodeID s, NodeID t) : start(s), target(t), type(0), direction(0), speed(0), nameID(0), isRoundabout(false), ignoreInGrid(false), isDurationSet(false), isAccessRestricted(false) { } |     _Edge(NodeID s, NodeID t) : start(s), target(t), type(0), direction(0), speed(0), nameID(0), isRoundabout(false), ignoreInGrid(false), isDurationSet(false), isAccessRestricted(false), isContraFlow(false) { } | ||||||
|     _Edge(NodeID s, NodeID t, short tp, short d, double sp): start(s), target(t), type(tp), direction(d), speed(sp), nameID(0), isRoundabout(false), ignoreInGrid(false), isDurationSet(false), isAccessRestricted(false) { } |     _Edge(NodeID s, NodeID t, short tp, short d, double sp): start(s), target(t), type(tp), direction(d), speed(sp), nameID(0), isRoundabout(false), ignoreInGrid(false), isDurationSet(false), isAccessRestricted(false), isContraFlow(false) { } | ||||||
|     _Edge(NodeID s, NodeID t, short tp, short d, double sp, unsigned nid, bool isra, bool iing, bool ids, bool iar): start(s), target(t), type(tp), direction(d), speed(sp), nameID(nid), isRoundabout(isra), ignoreInGrid(iing), isDurationSet(ids), isAccessRestricted(iar) { |     _Edge(NodeID s, NodeID t, short tp, short d, double sp, unsigned nid, bool isra, bool iing, bool ids, bool iar): start(s), target(t), type(tp), direction(d), speed(sp), nameID(nid), isRoundabout(isra), ignoreInGrid(iing), isDurationSet(ids), isAccessRestricted(iar), isContraFlow(false) { | ||||||
|  |         assert(0 <= type); | ||||||
|  |     } | ||||||
|  |     _Edge(NodeID s, NodeID t, short tp, short d, double sp, unsigned nid, bool isra, bool iing, bool ids, bool iar, bool icf): start(s), target(t), type(tp), direction(d), speed(sp), nameID(nid), isRoundabout(isra), ignoreInGrid(iing), isDurationSet(ids), isAccessRestricted(iar), isContraFlow(icf) { | ||||||
|         assert(0 <= type); |         assert(0 <= type); | ||||||
|     } |     } | ||||||
|     NodeID start; |     NodeID start; | ||||||
| @ -102,6 +107,7 @@ struct _Edge { | |||||||
|     bool ignoreInGrid; |     bool ignoreInGrid; | ||||||
|     bool isDurationSet; |     bool isDurationSet; | ||||||
|     bool isAccessRestricted; |     bool isAccessRestricted; | ||||||
|  |     bool isContraFlow; | ||||||
| 
 | 
 | ||||||
|     _Coordinate startCoord; |     _Coordinate startCoord; | ||||||
|     _Coordinate targetCoord; |     _Coordinate targetCoord; | ||||||
|  | |||||||
| @ -68,6 +68,7 @@ ScriptingEnvironment::ScriptingEnvironment(const char * fileName) { | |||||||
|                                      luabind::class_<_Way>("Way") |                                      luabind::class_<_Way>("Way") | ||||||
|                                      .def(luabind::constructor<>()) |                                      .def(luabind::constructor<>()) | ||||||
|                                      .def_readwrite("name", &_Way::name) |                                      .def_readwrite("name", &_Way::name) | ||||||
|  |                                      .def_readwrite("backward_speed", &_Way::backward_speed) | ||||||
|                                      .def_readwrite("speed", &_Way::speed) |                                      .def_readwrite("speed", &_Way::speed) | ||||||
|                                      .def_readwrite("type", &_Way::type) |                                      .def_readwrite("type", &_Way::type) | ||||||
|                                      .def_readwrite("access", &_Way::access) |                                      .def_readwrite("access", &_Way::access) | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user