1 #ifndef RESTRICTION_PARSER_HPP
2 #define RESTRICTION_PARSER_HPP
3 
4 #include "extractor/restriction.hpp"
5 
6 #include <boost/optional/optional.hpp>
7 
8 #include <string>
9 #include <vector>
10 
11 namespace osmium
12 {
13 class Relation;
14 }
15 
16 namespace osrm
17 {
18 namespace extractor
19 {
20 
21 class ScriptingEnvironment;
22 
23 /**
24  * Parses the relations that represents turn restrictions.
25  *
26  * Currently only restrictions where the via objects is a node are supported.
27  *  from   via   to
28  * ------->(x)-------->
29  *
30  * While this class does not directly invoke any lua code _per relation_ it does
31  * load configuration values from the profile, that are saved in variables.
32  * Namely ```use_turn_restrictions``` and ```get_restrictions```.
33  *
34  * The restriction is represented by the osm id of the from way, the osm id of the
35  * to way and the osm id of the via node. This representation must be post-processed
36  * in the extractor to work with the edge-based data-model of OSRM:
37  * Since the from and to way share the via-node a turn will have the following form:
38  * ...----(a)-----(via)------(b)----...
39  * So it can be represented by the tripe (a, via, b).
40  */
41 class RestrictionParser
42 {
43   public:
44     RestrictionParser(bool use_turn_restrictions,
45                       bool parse_conditionals,
46                       std::vector<std::string> &restrictions);
47     boost::optional<InputTurnRestriction> TryParse(const osmium::Relation &relation) const;
48 
49   private:
50     bool ShouldIgnoreRestriction(const std::string &except_tag_string) const;
51 
52     bool use_turn_restrictions;
53     bool parse_conditionals;
54     std::vector<std::string> restrictions;
55 };
56 } // namespace extractor
57 } // namespace osrm
58 
59 #endif /* RESTRICTION_PARSER_HPP */
60