Add OSM node barrier=height_restrictor handling
This commit is contained in:
parent
0da2029d2d
commit
5f598da76d
@ -7,7 +7,8 @@
|
|||||||
- Profile:
|
- Profile:
|
||||||
- FIXED: `highway=service` will now be used for restricted access, `access=private` is still disabled for snapping.
|
- FIXED: `highway=service` will now be used for restricted access, `access=private` is still disabled for snapping.
|
||||||
- ADDED #4775: Exposes more information to the turn function, now being able to set turn weights with highway and access information of the turn as well as other roads at the intersection [#4775](https://github.com/Project-OSRM/osrm-backend/issues/4775)
|
- ADDED #4775: Exposes more information to the turn function, now being able to set turn weights with highway and access information of the turn as well as other roads at the intersection [#4775](https://github.com/Project-OSRM/osrm-backend/issues/4775)
|
||||||
- FIXED: #4763: Add support for non-numerical units in car profile for maxheight [#4763](https://github.com/Project-OSRM/osrm-backend/issues/4763)
|
- FIXED #4763: Add support for non-numerical units in car profile for maxheight [#4763](https://github.com/Project-OSRM/osrm-backend/issues/4763)
|
||||||
|
- ADDED #4872: Handling of `barrier=height_restrictor` nodes [#4872](https://github.com/Project-OSRM/osrm-backend/pull/4872)
|
||||||
|
|
||||||
# 5.15.1
|
# 5.15.1
|
||||||
- Changes from 5.15.0:
|
- Changes from 5.15.0:
|
||||||
|
@ -45,3 +45,11 @@ Feature: Car - Barriers
|
|||||||
| bollard | | |
|
| bollard | | |
|
||||||
| bollard | rising | x |
|
| bollard | rising | x |
|
||||||
| bollard | removable | |
|
| bollard | removable | |
|
||||||
|
|
||||||
|
Scenario: Car - Height restrictions
|
||||||
|
Then routability should be
|
||||||
|
| node/barrier | node/maxheight | bothw |
|
||||||
|
| height_restrictor | | x |
|
||||||
|
| height_restrictor | 1 | |
|
||||||
|
| height_restrictor | 3 | x |
|
||||||
|
| height_restrictor | default | x |
|
||||||
|
@ -129,8 +129,12 @@ Feature: osrm-extract lua ways:get_nodes()
|
|||||||
"""
|
"""
|
||||||
functions = require('testbot')
|
functions = require('testbot')
|
||||||
|
|
||||||
|
functions.process_node = function(profile, node, result, relations)
|
||||||
|
print ('node ' .. tostring(node:get_location_tag('answer')))
|
||||||
|
end
|
||||||
|
|
||||||
functions.process_way = function(profile, way, result, relations)
|
functions.process_way = function(profile, way, result, relations)
|
||||||
print ('answer ' .. tostring(way:get_location_tag('answer')))
|
print ('way ' .. tostring(way:get_location_tag('answer')))
|
||||||
result.forward_mode = mode.driving
|
result.forward_mode = mode.driving
|
||||||
result.forward_speed = 1
|
result.forward_speed = 1
|
||||||
end
|
end
|
||||||
@ -148,4 +152,5 @@ Feature: osrm-extract lua ways:get_nodes()
|
|||||||
|
|
||||||
When I run "osrm-extract --profile {profile_file} {osm_file} --location-dependent-data test/data/regions/null-island.geojson"
|
When I run "osrm-extract --profile {profile_file} {osm_file} --location-dependent-data test/data/regions/null-island.geojson"
|
||||||
Then it should exit successfully
|
Then it should exit successfully
|
||||||
And stdout should contain "answer 42"
|
And stdout should contain "node 42"
|
||||||
|
And stdout should contain "way 42"
|
||||||
|
@ -9,6 +9,7 @@ Relations = require("lib/relations")
|
|||||||
find_access_tag = require("lib/access").find_access_tag
|
find_access_tag = require("lib/access").find_access_tag
|
||||||
limit = require("lib/maxspeed").limit
|
limit = require("lib/maxspeed").limit
|
||||||
Utils = require("lib/utils")
|
Utils = require("lib/utils")
|
||||||
|
Measure = require("lib/measure")
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
return {
|
return {
|
||||||
@ -54,7 +55,8 @@ function setup()
|
|||||||
'gate',
|
'gate',
|
||||||
'lift_gate',
|
'lift_gate',
|
||||||
'no',
|
'no',
|
||||||
'entrance'
|
'entrance',
|
||||||
|
'height_restrictor'
|
||||||
},
|
},
|
||||||
|
|
||||||
access_tag_whitelist = Set {
|
access_tag_whitelist = Set {
|
||||||
@ -320,11 +322,18 @@ function process_node(profile, node, result, relations)
|
|||||||
else
|
else
|
||||||
local barrier = node:get_value_by_key("barrier")
|
local barrier = node:get_value_by_key("barrier")
|
||||||
if barrier then
|
if barrier then
|
||||||
|
-- check height restriction barriers
|
||||||
|
local restricted_by_height = false
|
||||||
|
if barrier == 'height_restrictor' then
|
||||||
|
local maxheight = Measure.get_max_height(node:get_value_by_key("maxheight"), node)
|
||||||
|
restricted_by_height = maxheight and maxheight < profile.vehicle_height
|
||||||
|
end
|
||||||
|
|
||||||
-- make an exception for rising bollard barriers
|
-- make an exception for rising bollard barriers
|
||||||
local bollard = node:get_value_by_key("bollard")
|
local bollard = node:get_value_by_key("bollard")
|
||||||
local rising_bollard = bollard and "rising" == bollard
|
local rising_bollard = bollard and "rising" == bollard
|
||||||
|
|
||||||
if not profile.barrier_whitelist[barrier] and not rising_bollard then
|
if not profile.barrier_whitelist[barrier] and not rising_bollard or restricted_by_height then
|
||||||
result.barrier = true
|
result.barrier = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -62,11 +62,11 @@ local height_non_numerical_values = Set { "default", "none", "no-sign", "unsigne
|
|||||||
|
|
||||||
--- Get maxheight of specified way in meters. If there are no
|
--- Get maxheight of specified way in meters. If there are no
|
||||||
--- max height, then return nil
|
--- max height, then return nil
|
||||||
function Measure.get_max_height(raw_value,way)
|
function Measure.get_max_height(raw_value, element)
|
||||||
if raw_value then
|
if raw_value then
|
||||||
if height_non_numerical_values[raw_value] then
|
if height_non_numerical_values[raw_value] then
|
||||||
if way then
|
if element then
|
||||||
return way:get_location_tag('maxheight') or default_maxheight
|
return element:get_location_tag('maxheight') or default_maxheight
|
||||||
else
|
else
|
||||||
return default_maxheight
|
return default_maxheight
|
||||||
end
|
end
|
||||||
|
@ -218,6 +218,22 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
|
|||||||
"valid",
|
"valid",
|
||||||
&osmium::Location::valid);
|
&osmium::Location::valid);
|
||||||
|
|
||||||
|
auto get_location_tag = [](auto &context, const auto &location, const char *key) {
|
||||||
|
if (context.location_dependent_data.empty())
|
||||||
|
return sol::object(sol::nil);
|
||||||
|
|
||||||
|
const LocationDependentData::point_t point{location.lon(), location.lat()};
|
||||||
|
if (!boost::geometry::equals(context.last_location_point, point))
|
||||||
|
{
|
||||||
|
context.last_location_point = point;
|
||||||
|
context.last_location_indexes =
|
||||||
|
context.location_dependent_data.GetPropertyIndexes(point);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto value = context.location_dependent_data.FindByKey(context.last_location_indexes, key);
|
||||||
|
return boost::apply_visitor(to_lua_object(context.state), value);
|
||||||
|
};
|
||||||
|
|
||||||
context.state.new_usertype<osmium::Way>(
|
context.state.new_usertype<osmium::Way>(
|
||||||
"Way",
|
"Way",
|
||||||
"get_value_by_key",
|
"get_value_by_key",
|
||||||
@ -229,37 +245,29 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
|
|||||||
"get_nodes",
|
"get_nodes",
|
||||||
[](const osmium::Way &way) { return sol::as_table(way.nodes()); },
|
[](const osmium::Way &way) { return sol::as_table(way.nodes()); },
|
||||||
"get_location_tag",
|
"get_location_tag",
|
||||||
[&context](const osmium::Way &way, const char *key) {
|
[&context, &get_location_tag](const osmium::Way &way, const char *key) {
|
||||||
if (context.location_dependent_data.empty())
|
|
||||||
return sol::object(sol::nil);
|
|
||||||
// HEURISTIC: use a single node (last) of the way to localize the way
|
// HEURISTIC: use a single node (last) of the way to localize the way
|
||||||
// For more complicated scenarios a proper merging of multiple tags
|
// For more complicated scenarios a proper merging of multiple tags
|
||||||
// at one or many locations must be provided
|
// at one or many locations must be provided
|
||||||
const auto &nodes = way.nodes();
|
const auto &nodes = way.nodes();
|
||||||
const auto &location = nodes.back().location();
|
const auto &location = nodes.back().location();
|
||||||
const LocationDependentData::point_t point{location.lon(), location.lat()};
|
return get_location_tag(context, location, key);
|
||||||
|
|
||||||
if (!boost::geometry::equals(context.last_location_point, point))
|
|
||||||
{
|
|
||||||
context.last_location_point = point;
|
|
||||||
context.last_location_indexes =
|
|
||||||
context.location_dependent_data.GetPropertyIndexes(point);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto value =
|
|
||||||
context.location_dependent_data.FindByKey(context.last_location_indexes, key);
|
|
||||||
return boost::apply_visitor(to_lua_object(context.state), value);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
context.state.new_usertype<osmium::Node>("Node",
|
context.state.new_usertype<osmium::Node>(
|
||||||
"location",
|
"Node",
|
||||||
&osmium::Node::location,
|
"location",
|
||||||
"get_value_by_key",
|
&osmium::Node::location,
|
||||||
&get_value_by_key<osmium::Node>,
|
"get_value_by_key",
|
||||||
"id",
|
&get_value_by_key<osmium::Node>,
|
||||||
&osmium::Node::id,
|
"id",
|
||||||
"version",
|
&osmium::Node::id,
|
||||||
&osmium::Node::version);
|
"version",
|
||||||
|
&osmium::Node::version,
|
||||||
|
"get_location_tag",
|
||||||
|
[&context, &get_location_tag](const osmium::Node &node, const char *key) {
|
||||||
|
return get_location_tag(context, node.location(), key);
|
||||||
|
});
|
||||||
|
|
||||||
context.state.new_usertype<ExtractionNode>("ResultNode",
|
context.state.new_usertype<ExtractionNode>("ResultNode",
|
||||||
"traffic_lights",
|
"traffic_lights",
|
||||||
|
@ -139,6 +139,7 @@
|
|||||||
{"key": "access", "value": "emergency"},
|
{"key": "access", "value": "emergency"},
|
||||||
{"key": "access", "value": "psv"},
|
{"key": "access", "value": "psv"},
|
||||||
{"key": "access", "value": "delivery"},
|
{"key": "access", "value": "delivery"},
|
||||||
|
{"key": "maxheight", "object_types": ["node", "way"]},
|
||||||
{"key": "maxspeed", "value": "none"},
|
{"key": "maxspeed", "value": "none"},
|
||||||
{"key": "maxspeed", "value": "urban"},
|
{"key": "maxspeed", "value": "urban"},
|
||||||
{"key": "maxspeed", "value": "rural"},
|
{"key": "maxspeed", "value": "rural"},
|
||||||
|
Loading…
Reference in New Issue
Block a user