Adapts Hint encoding and decoding to new fixed data facade
This commit is contained in:
		
							parent
							
								
									3d75d15361
								
							
						
					
					
						commit
						a145520b5b
					
				| @ -40,18 +40,20 @@ namespace osrm | |||||||
| namespace engine | namespace engine | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
|  | // Fwd. decls.
 | ||||||
|  | namespace datafacade | ||||||
|  | { | ||||||
|  | struct BaseDataFacade; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| // Is returned as a temporary identifier for snapped coodinates
 | // Is returned as a temporary identifier for snapped coodinates
 | ||||||
| struct Hint | struct Hint | ||||||
| { | { | ||||||
|     PhantomNode phantom; |     PhantomNode phantom; | ||||||
|     std::uint32_t data_checksum; |     std::uint32_t data_checksum; | ||||||
| 
 | 
 | ||||||
|     template <typename DataFacadeT> |     bool IsValid(const util::Coordinate new_input_coordinates, | ||||||
|     bool IsValid(const util::Coordinate new_input_coordinates, DataFacadeT &facade) const |                  const datafacade::BaseDataFacade &facade) const; | ||||||
|     { |  | ||||||
|         return phantom.IsValid(facade.GetNumberOfNodes(), new_input_coordinates) && |  | ||||||
|                facade.GetCheckSum() == data_checksum; |  | ||||||
|     } |  | ||||||
| 
 | 
 | ||||||
|     std::string ToBase64() const; |     std::string ToBase64() const; | ||||||
|     static Hint FromBase64(const std::string &base64Hint); |     static Hint FromBase64(const std::string &base64Hint); | ||||||
|  | |||||||
| @ -1,5 +1,6 @@ | |||||||
| #include "engine/hint.hpp" | #include "engine/hint.hpp" | ||||||
| #include "engine/object_encoder.hpp" | #include "engine/object_encoder.hpp" | ||||||
|  | #include "engine/datafacade/datafacade_base.hpp" | ||||||
| 
 | 
 | ||||||
| #include <boost/assert.hpp> | #include <boost/assert.hpp> | ||||||
| 
 | 
 | ||||||
| @ -7,14 +8,23 @@ namespace osrm | |||||||
| { | { | ||||||
| namespace engine | namespace engine | ||||||
| { | { | ||||||
|  | 
 | ||||||
|  | bool Hint::IsValid(const util::Coordinate new_input_coordinates, | ||||||
|  |                    const datafacade::BaseDataFacade &facade) const | ||||||
|  | { | ||||||
|  |     auto is_same_input_coordinate = new_input_coordinates.lon == phantom.input_location.lon && | ||||||
|  |                                     new_input_coordinates.lat == phantom.input_location.lat; | ||||||
|  |     return is_same_input_coordinate && phantom.IsValid(facade.GetNumberOfNodes()) && | ||||||
|  |            facade.GetCheckSum() == data_checksum; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| std::string Hint::ToBase64() const { return encodeBase64(*this); } | std::string Hint::ToBase64() const { return encodeBase64(*this); } | ||||||
| 
 | 
 | ||||||
| Hint Hint::FromBase64(const std::string &base64Hint) | Hint Hint::FromBase64(const std::string &base64Hint) | ||||||
| { | { | ||||||
|     BOOST_ASSERT_MSG(base64Hint.size() == ENCODED_HINT_SIZE, "Hint has invalid size"); |     BOOST_ASSERT_MSG(base64Hint.size() == ENCODED_HINT_SIZE, "Hint has invalid size"); | ||||||
| 
 | 
 | ||||||
|     auto decoded = decodeBase64<Hint>(base64Hint); |     return decodeBase64<Hint>(base64Hint); | ||||||
|     return decoded; |  | ||||||
| } | } | ||||||
| } | } | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user