Merge branch 'develop' of https://github.com/DennisOSRM/Project-OSRM into develop
This commit is contained in:
		
						commit
						555bfaf37a
					
				| @ -28,12 +28,15 @@ or see http://www.gnu.org/licenses/agpl.txt. | |||||||
| #include <boost/regex.hpp> | #include <boost/regex.hpp> | ||||||
| #include <climits> | #include <climits> | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| #include "../Util/StringUtil.h" | #include "../Util/StringUtil.h" | ||||||
| 
 | 
 | ||||||
|  | namespace qi = boost::spirit::qi; | ||||||
|  | 
 | ||||||
| //TODO: Move into LUA
 | //TODO: Move into LUA
 | ||||||
| 
 | 
 | ||||||
| inline bool durationIsValid(const std::string &s) { | inline bool durationIsValid(const std::string &s) { | ||||||
|     boost::regex e ("((\\d|\\d\\d):)*(\\d|\\d\\d)",boost::regex_constants::icase|boost::regex_constants::perl); |     boost::regex e ("((\\d|\\d\\d):(\\d|\\d\\d):(\\d|\\d\\d))|((\\d|\\d\\d):(\\d|\\d\\d))|(\\d|\\d\\d)",boost::regex_constants::icase|boost::regex_constants::perl); | ||||||
| 
 | 
 | ||||||
|     std::vector< std::string > result; |     std::vector< std::string > result; | ||||||
|     boost::algorithm::split_regex( result, s, boost::regex( ":" ) ) ; |     boost::algorithm::split_regex( result, s, boost::regex( ":" ) ) ; | ||||||
| @ -42,17 +45,28 @@ inline bool durationIsValid(const std::string &s) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| inline unsigned parseDuration(const std::string &s) { | inline unsigned parseDuration(const std::string &s) { | ||||||
|     int hours = 0; | 	unsigned hours = 0; | ||||||
|     int minutes = 0; |     unsigned minutes = 0; | ||||||
|     boost::regex e ("((\\d|\\d\\d):)*(\\d|\\d\\d)",boost::regex_constants::icase|boost::regex_constants::perl); |     unsigned seconds = 0; | ||||||
|  |     boost::regex e ("((\\d|\\d\\d):(\\d|\\d\\d):(\\d|\\d\\d))|((\\d|\\d\\d):(\\d|\\d\\d))|(\\d|\\d\\d)",boost::regex_constants::icase|boost::regex_constants::perl); | ||||||
| 
 | 
 | ||||||
|     std::vector< std::string > result; |     std::vector< std::string > result; | ||||||
|     boost::algorithm::split_regex( result, s, boost::regex( ":" ) ) ; |     boost::algorithm::split_regex( result, s, boost::regex( ":" ) ) ; | ||||||
|     bool matched = regex_match(s, e); |     bool matched = regex_match(s, e); | ||||||
|     if(matched) { |     if(matched) { | ||||||
|         hours = (result.size()== 2) ?  stringToInt(result[0]) : 0; |     	if(1 == result.size()) { | ||||||
|         minutes = (result.size()== 2) ?  stringToInt(result[1]) : stringToInt(result[0]); |     		minutes = stringToInt(result[0]); | ||||||
|         return 600*(hours*60+minutes); |     	} | ||||||
|  |     	if(2 == result.size()) { | ||||||
|  |     		minutes =  stringToInt(result[1]); | ||||||
|  |     		hours = stringToInt(result[0]); | ||||||
|  |     	} | ||||||
|  |     	if(3 == result.size()) { | ||||||
|  |             seconds = stringToInt(result[2]); | ||||||
|  |             minutes = stringToInt(result[1]); | ||||||
|  |             hours   = stringToInt(result[0]); | ||||||
|  |     	} | ||||||
|  |         return 10*(3600*hours+60*minutes+seconds); | ||||||
|     } |     } | ||||||
|     return UINT_MAX; |     return UINT_MAX; | ||||||
| } | } | ||||||
| @ -66,5 +80,4 @@ inline int parseMaxspeed(std::string input) { //call-by-value on purpose. | |||||||
|     return n; |     return n; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| #endif /* EXTRACTIONHELPERFUNCTIONS_H_ */ | #endif /* EXTRACTIONHELPERFUNCTIONS_H_ */ | ||||||
|  | |||||||
| @ -6,9 +6,9 @@ Feature: Durations | |||||||
| 		 | 		 | ||||||
|     Scenario: Duration of ways |     Scenario: Duration of ways | ||||||
|     	Given the node map |     	Given the node map | ||||||
|     	 | a | b |  |   |   | |     	 | a | b |  |   |   | f | | ||||||
|     	 |   |   |  | e |   | |     	 |   |   |  | e |   |   | | ||||||
|     	 |   | c |  |   | d | |     	 |   | c |  |   | d |   | | ||||||
| 	  | 	  | ||||||
|     	And the ways |     	And the ways | ||||||
|     	 | nodes | highway | duration | |     	 | nodes | highway | duration | | ||||||
| @ -16,6 +16,7 @@ Feature: Durations | |||||||
|     	 | bc    | primary | 0:10     | |     	 | bc    | primary | 0:10     | | ||||||
|     	 | cd    | primary | 1:00     | |     	 | cd    | primary | 1:00     | | ||||||
|     	 | de    | primary | 10:00    | |     	 | de    | primary | 10:00    | | ||||||
|  |     	 | ef    | primary | 01:02:03 | | ||||||
| 
 | 
 | ||||||
|  		When I route I should get |  		When I route I should get | ||||||
|  		 | from | to | route | distance | time       | |  		 | from | to | route | distance | time       | | ||||||
| @ -23,6 +24,7 @@ Feature: Durations | |||||||
|  		 | b    | c  | bc    | 200m +-1 | 600s +-1   | |  		 | b    | c  | bc    | 200m +-1 | 600s +-1   | | ||||||
|  		 | c    | d  | cd    | 300m +-1 | 3600s +-1  | |  		 | c    | d  | cd    | 300m +-1 | 3600s +-1  | | ||||||
|  		 | d    | e  | de    | 144m +-2 | 36000s +-1 | |  		 | d    | e  | de    | 144m +-2 | 36000s +-1 | | ||||||
|  |  		 | e    | f  | ef    | 224m +-2 | 3723s +-1  | | ||||||
|      |      | ||||||
|     @todo |     @todo | ||||||
|     Scenario: Partial duration of ways |     Scenario: Partial duration of ways | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user