2016-01-28 10:28:44 -05:00
|
|
|
#ifndef ENGINE_HINT_HPP
|
|
|
|
#define ENGINE_HINT_HPP
|
|
|
|
|
|
|
|
#include "engine/phantom_node.hpp"
|
|
|
|
|
2016-02-23 15:23:13 -05:00
|
|
|
#include "util/coordinate.hpp"
|
2016-01-28 10:28:44 -05:00
|
|
|
|
2016-02-18 18:54:30 -05:00
|
|
|
#include <string>
|
2016-03-08 17:46:14 -05:00
|
|
|
#include <cstdint>
|
2016-02-18 18:54:30 -05:00
|
|
|
|
2016-01-28 10:28:44 -05:00
|
|
|
namespace osrm
|
|
|
|
{
|
|
|
|
namespace engine
|
|
|
|
{
|
|
|
|
|
|
|
|
// Is returned as a temporary identifier for snapped coodinates
|
|
|
|
struct Hint
|
|
|
|
{
|
2016-02-23 15:23:13 -05:00
|
|
|
util::Coordinate input_coordinate;
|
2016-01-28 10:28:44 -05:00
|
|
|
PhantomNode phantom;
|
|
|
|
std::uint32_t data_checksum;
|
|
|
|
|
|
|
|
template <typename DataFacadeT>
|
2016-02-23 15:23:13 -05:00
|
|
|
bool IsValid(const util::Coordinate new_input_coordinates, DataFacadeT &facade) const
|
2016-01-28 10:28:44 -05:00
|
|
|
{
|
2016-02-23 15:23:13 -05:00
|
|
|
auto is_same_input_coordinate = new_input_coordinates.lon == input_coordinate.lon &&
|
|
|
|
new_input_coordinates.lat == input_coordinate.lat;
|
2016-01-28 10:28:44 -05:00
|
|
|
return is_same_input_coordinate && phantom.IsValid(facade.GetNumberOfNodes()) &&
|
|
|
|
facade.GetCheckSum() == data_checksum;
|
|
|
|
}
|
|
|
|
|
2016-03-08 17:46:14 -05:00
|
|
|
std::string ToBase64() const;
|
|
|
|
static Hint FromBase64(const std::string &base64Hint);
|
2016-01-28 10:28:44 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#ifndef _MSC_VER
|
|
|
|
constexpr std::size_t ENCODED_HINT_SIZE = 88;
|
|
|
|
static_assert(ENCODED_HINT_SIZE / 4 * 3 >= sizeof(Hint),
|
|
|
|
"ENCODED_HINT_SIZE does not match size of Hint");
|
|
|
|
#else
|
|
|
|
// PhantomNode is bigger under windows because MSVC does not support bit packing
|
|
|
|
constexpr std::size_t ENCODED_HINT_SIZE = 84;
|
|
|
|
static_assert(ENCODED_HINT_SIZE / 4 * 3 >= sizeof(Hint),
|
|
|
|
"ENCODED_HINT_SIZE does not match size of Hint");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|