2016-04-26 07:27:40 -04:00
|
|
|
#ifndef OSRM_UTIL_GUIDANCE_BEARING_CLASS_HPP_
|
|
|
|
#define OSRM_UTIL_GUIDANCE_BEARING_CLASS_HPP_
|
|
|
|
|
|
|
|
#include <cstddef>
|
|
|
|
#include <cstdint>
|
|
|
|
#include <functional>
|
|
|
|
#include <vector>
|
|
|
|
|
2016-05-10 02:37:45 -04:00
|
|
|
#include <boost/functional/hash.hpp>
|
|
|
|
|
|
|
|
#include "util/typedefs.hpp"
|
|
|
|
|
2016-04-26 07:27:40 -04:00
|
|
|
namespace osrm
|
|
|
|
{
|
|
|
|
namespace util
|
|
|
|
{
|
|
|
|
namespace guidance
|
|
|
|
{
|
|
|
|
class BearingClass;
|
|
|
|
} // namespace guidance
|
|
|
|
} // namespace util
|
|
|
|
} // namespace osrm
|
|
|
|
|
|
|
|
namespace std
|
|
|
|
{
|
|
|
|
template <> struct hash<::osrm::util::guidance::BearingClass>
|
|
|
|
{
|
|
|
|
inline std::size_t operator()(const ::osrm::util::guidance::BearingClass &bearing_class) const;
|
|
|
|
};
|
|
|
|
} // namespace std
|
|
|
|
|
|
|
|
namespace osrm
|
|
|
|
{
|
|
|
|
namespace util
|
|
|
|
{
|
|
|
|
namespace guidance
|
|
|
|
{
|
|
|
|
|
|
|
|
class BearingClass
|
|
|
|
{
|
|
|
|
public:
|
2016-11-11 08:09:04 -05:00
|
|
|
BearingClass();
|
|
|
|
|
2016-05-10 02:37:45 -04:00
|
|
|
// Add a bearing to the set
|
|
|
|
void add(const DiscreteBearing bearing);
|
2016-05-09 09:39:11 -04:00
|
|
|
|
2016-04-26 07:27:40 -04:00
|
|
|
// hashing
|
|
|
|
bool operator==(const BearingClass &other) const;
|
|
|
|
|
|
|
|
// sorting
|
|
|
|
bool operator<(const BearingClass &other) const;
|
|
|
|
|
2016-05-10 02:37:45 -04:00
|
|
|
const std::vector<DiscreteBearing> &getAvailableBearings() const;
|
|
|
|
|
|
|
|
std::size_t findMatchingBearing(const double bearing) const;
|
2016-04-26 07:27:40 -04:00
|
|
|
|
2016-05-10 02:37:45 -04:00
|
|
|
const constexpr static double discrete_step_size = 360. / 24.;
|
|
|
|
static DiscreteBearing getDiscreteBearing(const double bearing);
|
2016-04-26 07:27:40 -04:00
|
|
|
|
|
|
|
private:
|
2016-05-10 02:37:45 -04:00
|
|
|
std::vector<DiscreteBearing> available_bearings;
|
2016-04-26 07:27:40 -04:00
|
|
|
|
|
|
|
// allow hash access to internal representation
|
|
|
|
friend std::size_t std::hash<BearingClass>::operator()(const BearingClass &) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace guidance
|
|
|
|
} // namespace util
|
|
|
|
} // namespace osrm
|
|
|
|
|
|
|
|
// make Bearing Class hasbable
|
|
|
|
namespace std
|
|
|
|
{
|
|
|
|
inline size_t hash<::osrm::util::guidance::BearingClass>::
|
|
|
|
operator()(const ::osrm::util::guidance::BearingClass &bearing_class) const
|
|
|
|
{
|
2016-05-10 02:37:45 -04:00
|
|
|
return boost::hash_value(bearing_class.available_bearings);
|
2016-04-26 07:27:40 -04:00
|
|
|
}
|
|
|
|
} // namespace std
|
|
|
|
|
|
|
|
#endif /* OSRM_UTIL_GUIDANCE_BEARING_CLASS_HPP_ */
|