osrm-backend/include/util/timezones.hpp
Karen Shea 799a677e7a Conditional turn restriction support (#3841)
* optionally include condition and via node coords in InputRestrictionContainer

* only write conditionals to disk, custom serialization for restrictions

* conditional turn lookup, reuse timezone validation from
extract-conditionals

* adapt updater to use coordinates/osm ids, remove internal to external map

* add utc time now parameter to contraction

* only compile timezone code where libshp is found, adapt test running

* slight refactor, more tests

* catch invalid via nodes in restriction parsing, set default cucumber
origin to guinée

* add another run to test mld routed paths

* cosmetic review changes

* Simplify Timezoner for windows build

* Split declaration and parsing parts for opening hours

* adjust conditional tests to run without shapefiles

* always include parse conditionals option

* Adjust travis timeout

* Added dummy TZ shapefile with test timezone polygons

* [skip ci] update changelog
2017-05-11 12:13:52 +02:00

49 lines
1.2 KiB
C++

#ifndef OSRM_TIMEZONES_HPP
#define OSRM_TIMEZONES_HPP
#include "util/log.hpp"
#include <boost/geometry.hpp>
#include <boost/geometry/index/rtree.hpp>
#include <chrono>
namespace osrm
{
namespace updater
{
// Time zone shape polygons loaded in R-tree
// local_time_t is a pair of a time zone shape polygon and the corresponding local time
// rtree_t is a lookup R-tree that maps a geographic point to an index in a local_time_t vector
using point_t = boost::geometry::model::
point<double, 2, boost::geometry::cs::spherical_equatorial<boost::geometry::degree>>;
using polygon_t = boost::geometry::model::polygon<point_t>;
using box_t = boost::geometry::model::box<point_t>;
using rtree_t =
boost::geometry::index::rtree<std::pair<box_t, size_t>, boost::geometry::index::rstar<8>>;
using local_time_t = std::pair<polygon_t, struct tm>;
bool SupportsShapefiles();
class Timezoner
{
public:
Timezoner() = default;
Timezoner(std::string tz_filename, std::time_t utc_time_now);
struct tm operator()(const point_t &point) const;
private:
void LoadLocalTimesRTree(const std::string &tz_shapes_filename, std::time_t utc_time);
struct tm default_time;
rtree_t rtree;
std::vector<local_time_t> local_times;
};
}
}
#endif