osrm-backend/include/extractor/restriction_parser.hpp
Michael Bell 5266ac1635
Add support for multiple via-way restrictions (#5907)
Currently OSRM only supports turn restrictions with a single via-node or one
via-way. OSM allows for multiple via-ways to represent longer and more
complex restrictions.

This PR extends the use of duplicate nodes for representng via-way turn
restrictions to also support multi via-way restrictions. Effectively, this
increases the edge-based graph size by the number of edges in multi via-way
restrictions. However, given the low number of these restrictions it
has little effect on total graph size.

In addition, we add a new step in the extraction phase that constructs
a restriction graph to support more complex relationships between restrictions,
such as nested restrictions and overlapping restrictions.
2020-12-20 13:59:57 -08:00

60 lines
1.6 KiB
C++

#ifndef RESTRICTION_PARSER_HPP
#define RESTRICTION_PARSER_HPP
#include "extractor/restriction.hpp"
#include <boost/optional/optional.hpp>
#include <string>
#include <vector>
namespace osmium
{
class Relation;
}
namespace osrm
{
namespace extractor
{
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:
* 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).
*/
class RestrictionParser
{
public:
RestrictionParser(bool use_turn_restrictions,
bool parse_conditionals,
std::vector<std::string> &restrictions);
boost::optional<InputTurnRestriction> TryParse(const osmium::Relation &relation) const;
private:
bool ShouldIgnoreRestriction(const std::string &except_tag_string) const;
bool use_turn_restrictions;
bool parse_conditionals;
std::vector<std::string> restrictions;
};
} // namespace extractor
} // namespace osrm
#endif /* RESTRICTION_PARSER_HPP */