osrm-backend/include/extractor/restriction_parser.hpp

60 lines
1.7 KiB
C++
Raw Normal View History

#ifndef RESTRICTION_PARSER_HPP
#define RESTRICTION_PARSER_HPP
2014-08-26 10:35:46 -04:00
2016-01-02 11:13:44 -05:00
#include "extractor/restriction.hpp"
2014-08-26 10:35:46 -04:00
#include <boost/optional/optional.hpp>
#include <osmium/tags/filter.hpp>
#include <set>
2014-08-26 10:35:46 -04:00
#include <string>
#include <vector>
namespace osmium
{
class Relation;
} // namespace osmium
2014-08-26 10:35:46 -04:00
namespace osrm::extractor
2016-01-05 10:51:13 -05:00
{
class ScriptingEnvironment;
/**
* Parses the relations that represents turn restrictions.
*
* Currently only restrictions where the via objects is a node are supported.
* from via to
* ------->(x)-------->
*
* While this class does not directly invoke any lua code _per relation_ it does
* load configuration values from the profile, that are saved in variables.
* Namely ```use_turn_restrictions``` and ```get_restrictions```.
*
* The restriction is represented by the osm id of the from way, the osm id of the
* to way and the osm id of the via node. This representation must be post-processed
* in the extractor to work with the edge-based data-model of OSRM:
2015-04-20 04:30:21 -04:00
* Since the from and to way share the via-node a turn will have the following form:
* ...----(a)-----(via)------(b)----...
* So it can be represented by the tripe (a, via, b).
*/
2014-08-26 10:35:46 -04:00
class RestrictionParser
{
public:
RestrictionParser(bool use_turn_restrictions,
bool parse_conditionals,
const std::vector<std::string> &restrictions);
std::vector<InputTurnRestriction> TryParse(const osmium::Relation &relation) const;
2014-08-26 10:35:46 -04:00
private:
2014-11-18 12:53:19 -05:00
bool ShouldIgnoreRestriction(const std::string &except_tag_string) const;
2014-08-26 10:35:46 -04:00
bool use_turn_restrictions;
bool parse_conditionals;
std::set<std::string> restrictions;
osmium::tags::KeyFilter filter;
2014-08-26 10:35:46 -04:00
};
2022-12-20 12:00:11 -05:00
} // namespace osrm::extractor
2016-01-05 10:51:13 -05:00
#endif /* RESTRICTION_PARSER_HPP */