2014-08-26 10:35:46 -04:00
|
|
|
/*
|
|
|
|
|
2015-02-19 03:19:51 -05:00
|
|
|
Copyright (c) 2014, Project OSRM contributors
|
2014-08-26 10:35:46 -04:00
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without modification,
|
|
|
|
are permitted provided that the following conditions are met:
|
|
|
|
|
|
|
|
Redistributions of source code must retain the above copyright notice, this list
|
|
|
|
of conditions and the following disclaimer.
|
|
|
|
Redistributions in binary form must reproduce the above copyright notice, this
|
|
|
|
list of conditions and the following disclaimer in the documentation and/or
|
|
|
|
other materials provided with the distribution.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
|
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
|
|
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
|
|
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2014-11-28 09:00:48 -05:00
|
|
|
#ifndef RESTRICTION_PARSER_HPP
|
|
|
|
#define RESTRICTION_PARSER_HPP
|
2014-08-26 10:35:46 -04:00
|
|
|
|
2014-11-28 06:13:18 -05:00
|
|
|
#include "../data_structures/restriction.hpp"
|
2014-08-26 10:35:46 -04:00
|
|
|
|
|
|
|
#include <osmium/osm.hpp>
|
|
|
|
#include <osmium/tags/regex_filter.hpp>
|
|
|
|
|
2014-08-29 05:27:51 -04:00
|
|
|
#include <variant/optional.hpp>
|
2014-08-26 10:35:46 -04:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
struct lua_State;
|
|
|
|
class ScriptingEnvironment;
|
|
|
|
|
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.
|
|
|
|
* Namely ```use_turn_restrictions``` and ```get_exceptions```.
|
|
|
|
*
|
|
|
|
* 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:
|
2014-11-18 10:54:48 -05:00
|
|
|
RestrictionParser(lua_State *lua_state);
|
2015-01-22 06:19:11 -05:00
|
|
|
mapbox::util::optional<InputRestrictionContainer>
|
|
|
|
TryParse(const osmium::Relation &relation) const;
|
2014-08-26 10:35:46 -04:00
|
|
|
|
|
|
|
private:
|
2014-11-18 10:54:48 -05:00
|
|
|
void ReadUseRestrictionsSetting(lua_State *lua_state);
|
|
|
|
void ReadRestrictionExceptions(lua_State *lua_state);
|
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
|
|
|
|
|
|
|
std::vector<std::string> restriction_exceptions;
|
|
|
|
bool use_turn_restrictions;
|
|
|
|
};
|
|
|
|
|
2014-11-28 09:00:48 -05:00
|
|
|
#endif /* RESTRICTION_PARSER_HPP */
|