From 4a84ca319780383948f3d58aef469a4f20bcdf77 Mon Sep 17 00:00:00 2001 From: "Daniel J. Hofmann" Date: Mon, 14 Mar 2016 14:21:18 +0100 Subject: [PATCH] Adapts Hint encoding and decoding to new fixed data facade --- include/engine/hint.hpp | 14 ++++++++------ src/engine/hint.cpp | 14 ++++++++++++-- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/include/engine/hint.hpp b/include/engine/hint.hpp index 4d6eb93a1..f74477c91 100644 --- a/include/engine/hint.hpp +++ b/include/engine/hint.hpp @@ -40,18 +40,20 @@ namespace osrm namespace engine { +// Fwd. decls. +namespace datafacade +{ +struct BaseDataFacade; +} + // Is returned as a temporary identifier for snapped coodinates struct Hint { PhantomNode phantom; std::uint32_t data_checksum; - template - bool IsValid(const util::Coordinate new_input_coordinates, DataFacadeT &facade) const - { - return phantom.IsValid(facade.GetNumberOfNodes(), new_input_coordinates) && - facade.GetCheckSum() == data_checksum; - } + bool IsValid(const util::Coordinate new_input_coordinates, + const datafacade::BaseDataFacade &facade) const; std::string ToBase64() const; static Hint FromBase64(const std::string &base64Hint); diff --git a/src/engine/hint.cpp b/src/engine/hint.cpp index e47943c89..c3fd4ac0a 100644 --- a/src/engine/hint.cpp +++ b/src/engine/hint.cpp @@ -1,5 +1,6 @@ #include "engine/hint.hpp" #include "engine/object_encoder.hpp" +#include "engine/datafacade/datafacade_base.hpp" #include @@ -7,14 +8,23 @@ namespace osrm { 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); } Hint Hint::FromBase64(const std::string &base64Hint) { BOOST_ASSERT_MSG(base64Hint.size() == ENCODED_HINT_SIZE, "Hint has invalid size"); - auto decoded = decodeBase64(base64Hint); - return decoded; + return decodeBase64(base64Hint); } } }