2014-11-28 09:00:48 -05:00
|
|
|
#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
|
|
|
|
2015-09-28 10:50:36 -04:00
|
|
|
#include <boost/optional/optional.hpp>
|
2014-08-26 10:35:46 -04:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2015-09-18 08:26:32 -04:00
|
|
|
namespace osmium
|
|
|
|
{
|
|
|
|
class Relation;
|
|
|
|
}
|
2014-08-26 10:35:46 -04:00
|
|
|
|
2016-01-05 10:51:13 -05:00
|
|
|
namespace osrm
|
|
|
|
{
|
|
|
|
namespace extractor
|
|
|
|
{
|
|
|
|
|
2016-07-11 11:44:58 -04:00
|
|
|
class ScriptingEnvironment;
|
2016-03-21 17:42:47 -04:00
|
|
|
|
2015-04-10 09:33:41 -04:00
|
|
|
/**
|
|
|
|
* 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.
|
2016-09-09 06:34:04 -04:00
|
|
|
* Namely ```use_turn_restrictions``` and ```get_restrictions```.
|
2015-04-10 09:33:41 -04:00
|
|
|
*
|
|
|
|
* 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:
|
2015-04-10 09:33:41 -04:00
|
|
|
* ...----(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:
|
2016-07-11 11:44:58 -04:00
|
|
|
RestrictionParser(ScriptingEnvironment &scripting_environment);
|
2015-09-18 08:26:32 -04:00
|
|
|
boost::optional<InputRestrictionContainer> 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
|
|
|
|
2016-09-09 06:34:04 -04:00
|
|
|
std::vector<std::string> restrictions;
|
2014-08-26 10:35:46 -04:00
|
|
|
bool use_turn_restrictions;
|
|
|
|
};
|
2016-01-05 10:51:13 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-28 09:00:48 -05:00
|
|
|
#endif /* RESTRICTION_PARSER_HPP */
|