Compare commits

...

6 Commits

Author SHA1 Message Date
Patrick Niklaus cc0c28f366 Fix formating for cherry-picked commit 2017-03-09 12:05:01 +00:00
Michael Krasnyk 66cc99703c Compute correct speed values in tile plugin 2017-03-09 11:49:10 +00:00
Patrick Niklaus f7fbca3e5e Update changelog 2017-03-03 17:27:28 +00:00
Patrick Niklaus 9695eaa28a Fix tile datasize check 2017-03-03 16:03:47 +00:00
Patrick Niklaus 0d7546a510 Only allow restricted access for road of certain highway type 2017-03-03 16:03:36 +00:00
Michael Krasnyk 9dc8136240 Fix incorrect forward datasources getter in facade 2017-03-03 10:52:53 +00:00
10 changed files with 224 additions and 79 deletions
+12
View File
@@ -1,3 +1,15 @@
# 5.6.3
- Changes from 5.6.0
- Bugfixes
- #3790 Fix incorrect speed values in tile plugin
# 5.6.2
- Changes from 5.6.0
- Bugfixes
- Fix incorrect forward datasources getter in facade
- Fix include `access=private` non-car roads in the car profile
# 5.6.1
- Changes from 5.6.0
- Bugfixes
+27 -4
View File
@@ -165,7 +165,7 @@ Feature: Car - Restricted access
| motorway | yes | permissive | | private | x | | implied oneway |
| trunk | agricultural | designated | permissive | no | | | |
| pedestrian | | | | | | | |
| pedestrian | | | | destination | x | x | |
| pedestrian | | | | destination | | | temporary disabled #3773 |
Scenario: Car - Ignore access tags for other modes
Then routability should be
@@ -262,9 +262,11 @@ Feature: Car - Restricted access
Scenario: Car - a way with a list of tags
Then routability should be
| highway | motor_vehicle | motor_vehicle:forward | motor_vehicle:backward | forw | backw |
| footway | | | destination | | x |
| track | destination;agricultural | destination | | x | x |
| highway | motor_vehicle | motor_vehicle:forward | motor_vehicle:backward | forw | backw | # |
| primary | | no | destination | | x | |
| primary | destination;agricultural | destination | | x | x | |
| footway | | | destination | | | temporary #3373 |
| track | destination;agricultural | destination | | | x | temporary #3373 |
Scenario: Car - Don't route over steps even if marked as accessible
Then routability should be
@@ -280,3 +282,24 @@ Feature: Car - Restricted access
| steps | permissive | |
| footway | permissive | x |
| garbagetag | permissive | x |
Scenario: Car - Access private blacklist
Then routability should be
| highway | access | bothw |
| footway | yes | x |
| pedestrian | private | |
| footway | private | |
| service | private | |
| cycleway | private | |
| track | private | |
Scenario: Car - Access blacklist
Then routability should be
| highway | access | bothw |
| primary | | x |
| primary | customer | |
| primary | emergency | |
| primary | forestry | |
| primary | agricultural | |
| primary | psv | |
| primary | no | |
+49 -37
View File
@@ -36,15 +36,18 @@ Feature: Traffic - speeds
1,4,27
4,1,27
"""
And I route I should get
| from | to | route | speed | weights |
| a | b | ad,de,eb,eb | 30 km/h | 1275.7,400.4,378.2,0 |
| a | c | ad,dc,dc | 31 km/h | 1275.7,956.8,0 |
| b | c | bc,bc | 27 km/h | 741.5,0 |
| a | d | ad,ad | 27 km/h | 1275.7,0 |
| d | c | dc,dc | 36 km/h | 956.8,0 |
| g | b | fb,fb | 36 km/h | 164.7,0 |
| a | g | ad,df,fb,fb | 30 km/h | 1275.7,487.5,304.7,0 |
And the query options
| annotations | datasources |
When I route I should get
| from | to | route | speed | weights | a:datasources |
| a | b | ad,de,eb,eb | 30 km/h | 1275.7,400.4,378.2,0 | 1:0:0:0 |
| a | c | ad,dc,dc | 31 km/h | 1275.7,956.8,0 | 1:0 |
| b | c | bc,bc | 27 km/h | 741.5,0 | 1:0 |
| a | d | ad,ad | 27 km/h | 1275.7,0 | 1:0 |
| d | c | dc,dc | 36 km/h | 956.8,0 | 0 |
| g | b | fb,fb | 36 km/h | 164.7,0 | 0 |
| a | g | ad,df,fb,fb | 30 km/h | 1275.7,487.5,304.7,0 | 1:0:0 |
Scenario: Weighting based on speed file weights, ETA based on file durations
@@ -58,15 +61,18 @@ Feature: Traffic - speeds
1,4,27,1275.7
4,1,27,1275.7
"""
And I route I should get
| from | to | route | speed | weights |
| a | b | ad,de,eb,eb | 30 km/h | 1275.7,400.4,378.2,0 |
| a | c | ad,dc,dc | 31 km/h | 1275.7,956.8,0 |
| b | c | bc,bc | 27 km/h | 741.5,0 |
| a | d | ad,ad | 27 km/h | 1275.7,0 |
| d | c | dc,dc | 36 km/h | 956.8,0 |
| g | b | ab,ab | 1 km/h | 10010.4,0 |
| a | g | ab,ab | 1 km/h | 10010.3,0 |
And the query options
| annotations | datasources |
When I route I should get
| from | to | route | speed | weights | a:datasources |
| a | b | ad,de,eb,eb | 30 km/h | 1275.7,400.4,378.2,0 | 1:0:0:0 |
| a | c | ad,dc,dc | 31 km/h | 1275.7,956.8,0 | 1:0 |
| b | c | bc,bc | 27 km/h | 741.5,0 | 1:0 |
| a | d | ad,ad | 27 km/h | 1275.7,0 | 1:0 |
| d | c | dc,dc | 36 km/h | 956.8,0 | 0 |
| g | b | ab,ab | 1 km/h | 10010.4,0 | 1:0 |
| a | g | ab,ab | 1 km/h | 10010.3,0 | 1 |
Scenario: Weighting based on speed file weights, ETA based on file durations
@@ -87,16 +93,19 @@ Feature: Traffic - speeds
1,4,1,34445.12
4,1,1,34445.3
"""
And I route I should get
| from | to | route | speed | weights |
| a | b | ab,ab | 1 km/h | 20020.789,0 |
| a | c | ab,bc,bc | 2 km/h | 20020.789,741.568,0 |
| b | c | bc,bc | 27 km/h | 741.568,0 |
| a | d | ab,eb,de,de | 2 km/h | 20020.789,378.169,400.415,0 |
| d | c | dc,dc | 36 km/h | 956.805,0 |
| g | b | ab,ab | 1 km/h | 10010.392,0 |
| a | g | ab,ab | 1 km/h | 10010.397,0 |
| g | a | ab,ab | 1 km/h | 10010.064,0 |
And the query options
| annotations | datasources |
When I route I should get
| from | to | route | speed | weights | a:datasources |
| a | b | ab,ab | 1 km/h | 20020.789,0 | 1:0 |
| a | c | ab,bc,bc | 2 km/h | 20020.789,741.568,0 | 1:1:0 |
| b | c | bc,bc | 27 km/h | 741.568,0 | 1:0 |
| a | d | ab,eb,de,de | 2 km/h | 20020.789,378.169,400.415,0 | 1:0:0 |
| d | c | dc,dc | 36 km/h | 956.805,0 | 0 |
| g | b | ab,ab | 1 km/h | 10010.392,0 | 1:0 |
| a | g | ab,ab | 1 km/h | 10010.397,0 | 1 |
| g | a | ab,ab | 1 km/h | 10010.064,0 | 1:1 |
Scenario: Speeds that isolate a single node (a)
@@ -113,15 +122,18 @@ Feature: Traffic - speeds
1,4,0
4,1,0
"""
And I route I should get
| from | to | route | speed | weights |
| a | b | fb,fb | 36 km/h | 329.4,0 |
| a | c | fb,bc,bc | 30 km/h | 329.4,741.5,0 |
| b | c | bc,bc | 27 km/h | 741.5,0 |
| a | d | fb,df,df | 36 km/h | 140,487.5,0 |
| d | c | dc,dc | 36 km/h | 956.8,0 |
| g | b | fb,fb | 36 km/h | 164.7,0 |
| a | g | fb,fb | 36 km/h | 164.7,0 |
And the query options
| annotations | true |
When I route I should get
| from | to | route | speed | weights | a:datasources |
| a | b | fb,fb | 36 km/h | 329.4,0 | 0 |
| a | c | fb,bc,bc | 30 km/h | 329.4,741.5,0 | 0:1:0 |
| b | c | bc,bc | 27 km/h | 741.5,0 | 1:0 |
| a | d | fb,df,df | 36 km/h | 140,487.5,0 | 0:0:0 |
| d | c | dc,dc | 36 km/h | 956.8,0 | 0 |
| g | b | fb,fb | 36 km/h | 164.7,0 | 0 |
| a | g | fb,fb | 36 km/h | 164.7,0 | 0 |
Scenario: Verify that negative values cause an error, they're not valid at all
@@ -865,7 +865,6 @@ class ContiguousInternalMemoryDataFacade : public BaseDataFacade
}
else
{
result_datasources.resize(end - begin);
std::copy(m_datasource_list.begin() + begin,
m_datasource_list.begin() + end,
std::back_inserter(result_datasources));
+2
View File
@@ -67,6 +67,8 @@ local profile = {
restricted_access_tag_list = Set { },
restricted_highway_whitelist = Set { },
access_tags_hierarchy = Sequence {
'bicycle',
'vehicle',
+21 -2
View File
@@ -74,7 +74,11 @@ local profile = {
'agricultural',
'forestry',
'emergency',
'psv'
'psv',
'customer',
'private',
'delivery',
'destination'
},
restricted_access_tag_list = Set {
@@ -137,6 +141,21 @@ local profile = {
["drive-thru"] = 0.5
},
restricted_highway_whitelist = Set {
'motorway',
'motorway_link',
'trunk',
'trunk_link',
'primary',
'primary_link',
'secondary',
'secondary_link',
'tertiary',
'tertiary_link',
'residential',
'living_street',
},
route_speeds = {
ferry = 5,
shuttle_train = 10
@@ -259,7 +278,7 @@ function node_function (node, result)
-- parse access and barrier tags
local access = find_access_tag(node, profile.access_tags_hierarchy)
if access then
if profile.access_tag_blacklist[access] then
if profile.access_tag_blacklist[access] and not profile.restricted_access_tag_list[access] then
result.barrier = true
end
else
+2
View File
@@ -53,6 +53,8 @@ local profile = {
restricted_access_tag_list = Set { },
restricted_highway_whitelist = Set { },
access_tags_hierarchy = Sequence {
'foot',
'access'
+13 -10
View File
@@ -212,25 +212,28 @@ function Handlers.handle_access(way,result,data,profile)
data.forward_access, data.backward_access =
Tags.get_forward_backward_by_set(way,data,profile.access_tags_hierarchy)
if profile.access_tag_blacklist[data.forward_access] then
-- only allow a subset of roads that are marked as restricted
if profile.restricted_highway_whitelist[data.highway] then
if profile.restricted_access_tag_list[data.forward_access] then
result.forward_restricted = true
end
if profile.restricted_access_tag_list[data.backward_access] then
result.backward_restricted = true
end
end
if profile.access_tag_blacklist[data.forward_access] and not result.forward_restricted then
result.forward_mode = mode.inaccessible
end
if profile.access_tag_blacklist[data.backward_access] then
if profile.access_tag_blacklist[data.backward_access] and not result.backward_restricted then
result.backward_mode = mode.inaccessible
end
if result.forward_mode == mode.inaccessible and result.backward_mode == mode.inaccessible then
return false
end
if profile.restricted_access_tag_list[data.forward_access] then
result.forward_restricted = true
end
if profile.restricted_access_tag_list[data.backward_access] then
result.backward_restricted = true
end
end
-- handle speed (excluding maxspeed)
+66 -14
View File
@@ -79,9 +79,10 @@ struct TurnData final
TurnData(const util::Coordinate coordinate_,
const std::size_t _in,
const std::size_t _out,
const std::size_t _weight)
const std::size_t _weight,
const std::size_t _duration)
: coordinate(std::move(coordinate_)), in_angle_offset(_in), turn_angle_offset(_out),
weight_offset(_weight)
weight_offset(_weight), duration_offset(_duration)
{
}
@@ -89,6 +90,7 @@ struct TurnData final
const std::size_t in_angle_offset;
const std::size_t turn_angle_offset;
const std::size_t weight_offset;
const std::size_t duration_offset;
};
using FixedPoint = Point<std::int32_t>;
@@ -457,6 +459,7 @@ Status TilePlugin::HandleRequest(const std::shared_ptr<const datafacade::BaseDat
// vw is the "exit"
std::vector<contractor::QueryEdge::EdgeData> unpacked_shortcut;
std::vector<EdgeWeight> approach_weight_vector;
std::vector<EdgeWeight> approach_duration_vector;
// Make sure we traverse the startnodes in a consistent order
// to ensure identical PBF encoding on all platforms.
@@ -539,16 +542,26 @@ Status TilePlugin::HandleRequest(const std::shared_ptr<const datafacade::BaseDat
approach_weight_vector = facade->GetUncompressedForwardWeights(
edge_based_node_info[approachedge.edge_based_node_id]
.packed_geometry_id);
approach_duration_vector = facade->GetUncompressedForwardDurations(
edge_based_node_info[approachedge.edge_based_node_id]
.packed_geometry_id);
}
else
{
approach_weight_vector = facade->GetUncompressedReverseWeights(
edge_based_node_info[approachedge.edge_based_node_id]
.packed_geometry_id);
approach_duration_vector = facade->GetUncompressedReverseDurations(
edge_based_node_info[approachedge.edge_based_node_id]
.packed_geometry_id);
}
const auto sum_node_weight = std::accumulate(approach_weight_vector.begin(),
approach_weight_vector.end(),
EdgeWeight{0});
const auto sum_node_duration =
std::accumulate(approach_duration_vector.begin(),
approach_duration_vector.end(),
EdgeWeight{0});
// The edge.weight is the whole edge weight, which includes the turn
// cost.
@@ -557,7 +570,8 @@ Status TilePlugin::HandleRequest(const std::shared_ptr<const datafacade::BaseDat
// intersections include stop signs, traffic signals and other
// penalties, but at this stage, we can't divide those out, so we just
// treat the whole lot as the "turn cost" that we'll stick on the map.
const auto turn_cost = data.weight - sum_node_weight;
const auto turn_weight = data.weight - sum_node_weight;
const auto turn_duration = data.duration - sum_node_duration;
// Find the three nodes that make up the turn movement)
const auto node_from = startnode;
@@ -598,14 +612,19 @@ Status TilePlugin::HandleRequest(const std::shared_ptr<const datafacade::BaseDat
// And, same for the actual turn cost value - it goes in the lookup
// table,
// not directly on the feature itself.
const auto turn_cost_index = use_point_float_value(
turn_cost / 10.0); // Note conversion to float here
const auto turn_weight_index = use_point_float_value(
turn_weight / 10.0); // Note conversion to float here
const auto turn_duration_index = use_point_float_value(
turn_duration / 10.0); // Note conversion to float here
// Save everything we need to later add all the points to the tile.
// We need the coordinate of the intersection, the angle in, the turn
// angle and the turn cost.
all_turn_data.emplace_back(
coord_via, angle_in_index, turn_angle_index, turn_cost_index);
all_turn_data.emplace_back(coord_via,
angle_in_index,
turn_angle_index,
turn_weight_index,
turn_duration_index);
}
}
}
@@ -672,6 +691,8 @@ Status TilePlugin::HandleRequest(const std::shared_ptr<const datafacade::BaseDat
for (const auto &edge_index : sorted_edge_indexes)
{
const auto &edge = edges[edge_index];
// Weight values
const auto forward_weight_vector =
facade->GetUncompressedForwardWeights(edge.packed_geometry_id);
const auto reverse_weight_vector =
@@ -679,8 +700,20 @@ Status TilePlugin::HandleRequest(const std::shared_ptr<const datafacade::BaseDat
const auto forward_weight = forward_weight_vector[edge.fwd_segment_position];
const auto reverse_weight = reverse_weight_vector[reverse_weight_vector.size() -
edge.fwd_segment_position - 1];
use_line_value(reverse_weight);
use_line_value(forward_weight);
use_line_value(reverse_weight);
// Duration values
const auto forward_duration_vector =
facade->GetUncompressedForwardDurations(edge.packed_geometry_id);
const auto reverse_duration_vector =
facade->GetUncompressedReverseDurations(edge.packed_geometry_id);
const auto forward_duration = forward_duration_vector[edge.fwd_segment_position];
const auto reverse_duration =
reverse_duration_vector[reverse_duration_vector.size() -
edge.fwd_segment_position - 1];
use_line_value(forward_duration);
use_line_value(reverse_duration);
}
// Begin the layer features block
@@ -701,6 +734,10 @@ Status TilePlugin::HandleRequest(const std::shared_ptr<const datafacade::BaseDat
facade->GetUncompressedForwardWeights(edge.packed_geometry_id);
const auto reverse_weight_vector =
facade->GetUncompressedReverseWeights(edge.packed_geometry_id);
const auto forward_duration_vector =
facade->GetUncompressedForwardDurations(edge.packed_geometry_id);
const auto reverse_duration_vector =
facade->GetUncompressedReverseDurations(edge.packed_geometry_id);
const auto forward_datasource_vector =
facade->GetUncompressedForwardDatasources(edge.packed_geometry_id);
const auto reverse_datasource_vector =
@@ -709,6 +746,11 @@ Status TilePlugin::HandleRequest(const std::shared_ptr<const datafacade::BaseDat
const auto reverse_weight =
reverse_weight_vector[reverse_weight_vector.size() -
edge.fwd_segment_position - 1];
const auto forward_duration =
forward_duration_vector[edge.fwd_segment_position];
const auto reverse_duration =
reverse_duration_vector[reverse_duration_vector.size() -
edge.fwd_segment_position - 1];
const auto forward_datasource =
forward_datasource_vector[edge.fwd_segment_position];
const auto reverse_datasource =
@@ -735,6 +777,7 @@ Status TilePlugin::HandleRequest(const std::shared_ptr<const datafacade::BaseDat
&max_datasource_id,
&used_line_ints](const FixedLine &tile_line,
const std::uint32_t speed_kmh,
const std::size_t weight,
const std::size_t duration,
const DatasourceID datasource,
const std::size_t name_idx,
@@ -770,10 +813,13 @@ Status TilePlugin::HandleRequest(const std::shared_ptr<const datafacade::BaseDat
(edge.component.is_tiny ? 0 : 1)); // is_small feature
field.add_element(2); // "datasource" tag key offset
field.add_element(130 + datasource); // datasource value offset
field.add_element(3); // "duration" tag key offset
field.add_element(3); // "weight" tag key offset
field.add_element(130 + max_datasource_id + 1 +
weight); // weight value offset
field.add_element(4); // "duration" tag key offset
field.add_element(130 + max_datasource_id + 1 +
duration); // duration value offset
field.add_element(4); // "name" tag key offset
field.add_element(5); // "name" tag key offset
field.add_element(130 + max_datasource_id + 1 + used_line_ints.size() +
name_idx); // name value offset
@@ -788,14 +834,14 @@ Status TilePlugin::HandleRequest(const std::shared_ptr<const datafacade::BaseDat
};
// If this is a valid forward edge, go ahead and add it to the tile
if (forward_weight != 0 && edge.forward_segment_id.enabled)
if (forward_duration != 0 && edge.forward_segment_id.enabled)
{
std::int32_t start_x = 0;
std::int32_t start_y = 0;
// Calculate the speed for this line
std::uint32_t speed_kmh =
static_cast<std::uint32_t>(round(length / forward_weight * 10 * 3.6));
static_cast<std::uint32_t>(round(length / forward_duration * 10 * 3.6));
auto tile_line = coordinatesToTileLine(a, b, tile_bbox);
if (!tile_line.empty())
@@ -803,6 +849,7 @@ Status TilePlugin::HandleRequest(const std::shared_ptr<const datafacade::BaseDat
encode_tile_line(tile_line,
speed_kmh,
line_int_offsets[forward_weight],
line_int_offsets[forward_duration],
forward_datasource,
name_offset,
start_x,
@@ -812,14 +859,14 @@ Status TilePlugin::HandleRequest(const std::shared_ptr<const datafacade::BaseDat
// Repeat the above for the coordinates reversed and using the `reverse`
// properties
if (reverse_weight != 0 && edge.reverse_segment_id.enabled)
if (reverse_duration != 0 && edge.reverse_segment_id.enabled)
{
std::int32_t start_x = 0;
std::int32_t start_y = 0;
// Calculate the speed for this line
std::uint32_t speed_kmh =
static_cast<std::uint32_t>(round(length / reverse_weight * 10 * 3.6));
static_cast<std::uint32_t>(round(length / reverse_duration * 10 * 3.6));
auto tile_line = coordinatesToTileLine(b, a, tile_bbox);
if (!tile_line.empty())
@@ -827,6 +874,7 @@ Status TilePlugin::HandleRequest(const std::shared_ptr<const datafacade::BaseDat
encode_tile_line(tile_line,
speed_kmh,
line_int_offsets[reverse_weight],
line_int_offsets[reverse_duration],
reverse_datasource,
name_offset,
start_x,
@@ -842,6 +890,7 @@ Status TilePlugin::HandleRequest(const std::shared_ptr<const datafacade::BaseDat
line_layer_writer.add_string(util::vector_tile::KEY_TAG, "speed");
line_layer_writer.add_string(util::vector_tile::KEY_TAG, "is_small");
line_layer_writer.add_string(util::vector_tile::KEY_TAG, "datasource");
line_layer_writer.add_string(util::vector_tile::KEY_TAG, "weight");
line_layer_writer.add_string(util::vector_tile::KEY_TAG, "duration");
line_layer_writer.add_string(util::vector_tile::KEY_TAG, "name");
@@ -938,6 +987,8 @@ Status TilePlugin::HandleRequest(const std::shared_ptr<const datafacade::BaseDat
field.add_element(1); // "turn_angle" tag key offset
field.add_element(point_turn_data.turn_angle_offset);
field.add_element(2); // "cost" tag key offset
field.add_element(used_point_ints.size() + point_turn_data.duration_offset);
field.add_element(3); // "cost" tag key offset
field.add_element(used_point_ints.size() + point_turn_data.weight_offset);
}
{
@@ -965,6 +1016,7 @@ Status TilePlugin::HandleRequest(const std::shared_ptr<const datafacade::BaseDat
point_layer_writer.add_string(util::vector_tile::KEY_TAG, "bearing_in");
point_layer_writer.add_string(util::vector_tile::KEY_TAG, "turn_angle");
point_layer_writer.add_string(util::vector_tile::KEY_TAG, "cost");
point_layer_writer.add_string(util::vector_tile::KEY_TAG, "weight");
// Now, save the lists of integers and floats that our features refer to.
for (const auto &value : used_point_ints)
+32 -11
View File
@@ -32,7 +32,7 @@ BOOST_AUTO_TEST_CASE(test_tile)
const auto rc = osrm.Tile(params, result);
BOOST_CHECK(rc == Status::Ok);
BOOST_CHECK(result.size() > 115000);
BOOST_CHECK(result.size() > 114000);
protozero::pbf_reader tile_message(result);
tile_message.next();
@@ -54,7 +54,7 @@ BOOST_AUTO_TEST_CASE(test_tile)
auto property_iter_pair = feature_message.get_packed_uint32();
auto value_begin = property_iter_pair.begin();
auto value_end = property_iter_pair.end();
BOOST_CHECK_EQUAL(std::distance(value_begin, value_end), 10);
BOOST_CHECK_EQUAL(std::distance(value_begin, value_end), 12);
auto iter = value_begin;
BOOST_CHECK_EQUAL(*iter++, 0); // speed key
BOOST_CHECK_LT(*iter++, 128); // speed value
@@ -65,10 +65,12 @@ BOOST_AUTO_TEST_CASE(test_tile)
iter++;
BOOST_CHECK_EQUAL(*iter++, 2); // data source key
*iter++; // skip value check, can be valud uint32
BOOST_CHECK_EQUAL(*iter++, 3); // duration key
BOOST_CHECK_EQUAL(*iter++, 3); // weight key
BOOST_CHECK_GT(*iter++, 130); // weight value
BOOST_CHECK_EQUAL(*iter++, 4); // duration key
BOOST_CHECK_GT(*iter++, 130); // duration value
// name
BOOST_CHECK_EQUAL(*iter++, 4);
BOOST_CHECK_EQUAL(*iter++, 5);
BOOST_CHECK_GT(*iter++, 130);
BOOST_CHECK(iter == value_end);
// geometry
@@ -137,7 +139,7 @@ BOOST_AUTO_TEST_CASE(test_tile)
}
}
BOOST_CHECK_EQUAL(number_of_speed_keys, 5);
BOOST_CHECK_EQUAL(number_of_speed_keys, 6);
BOOST_CHECK_GT(number_of_speed_values, 128); // speed value resolution
tile_message.next();
@@ -156,7 +158,7 @@ BOOST_AUTO_TEST_CASE(test_tile)
BOOST_CHECK_EQUAL(feature_message.tag(), util::vector_tile::FEATURE_ATTRIBUTES_TAG);
// properties
auto feature_iter_pair = feature_message.get_packed_uint32();
BOOST_CHECK_EQUAL(std::distance(feature_iter_pair.begin(), feature_iter_pair.end()), 6);
BOOST_CHECK_EQUAL(std::distance(feature_iter_pair.begin(), feature_iter_pair.end()), 8);
auto iter = feature_iter_pair.begin();
BOOST_CHECK_EQUAL(*iter++, 0); // bearing_in key
*iter++;
@@ -164,6 +166,8 @@ BOOST_AUTO_TEST_CASE(test_tile)
*iter++;
BOOST_CHECK_EQUAL(*iter++, 2); // cost key
*iter++; // skip value check, can be valud uint32
BOOST_CHECK_EQUAL(*iter++, 3); // weight key
*iter++; // skip value check, can be valud uint32
BOOST_CHECK(iter == feature_iter_pair.end());
// geometry
feature_message.next();
@@ -204,7 +208,7 @@ BOOST_AUTO_TEST_CASE(test_tile)
}
}
BOOST_CHECK_EQUAL(number_of_turn_keys, 3);
BOOST_CHECK_EQUAL(number_of_turn_keys, 4);
BOOST_CHECK(number_of_turns_found > 700);
}
@@ -236,6 +240,7 @@ BOOST_AUTO_TEST_CASE(test_tile_turns)
std::vector<int> found_bearing_in_indexes;
std::vector<int> found_turn_angles_indexes;
std::vector<int> found_penalties_indexes;
std::vector<int> found_weight_indexes;
const auto check_turn_feature = [&](protozero::pbf_reader feature_message) {
feature_message.next(); // advance parser to first entry
@@ -250,7 +255,7 @@ BOOST_AUTO_TEST_CASE(test_tile_turns)
BOOST_CHECK_EQUAL(feature_message.tag(), util::vector_tile::FEATURE_ATTRIBUTES_TAG);
// properties
auto feature_iter_pair = feature_message.get_packed_uint32();
BOOST_CHECK_EQUAL(std::distance(feature_iter_pair.begin(), feature_iter_pair.end()), 6);
BOOST_CHECK_EQUAL(std::distance(feature_iter_pair.begin(), feature_iter_pair.end()), 8);
auto iter = feature_iter_pair.begin();
BOOST_CHECK_EQUAL(*iter++, 0); // bearing_in key
found_bearing_in_indexes.push_back(*iter++);
@@ -258,6 +263,8 @@ BOOST_AUTO_TEST_CASE(test_tile_turns)
found_turn_angles_indexes.push_back(*iter++);
BOOST_CHECK_EQUAL(*iter++, 2); // cost key
found_penalties_indexes.push_back(*iter++); // skip value check, can be valud uint32
BOOST_CHECK_EQUAL(*iter++, 3); // weight key
found_weight_indexes.push_back(*iter++); // skip value check, can be valud uint32
BOOST_CHECK(iter == feature_iter_pair.end());
// geometry
feature_message.next();
@@ -333,6 +340,18 @@ BOOST_AUTO_TEST_CASE(test_tile_turns)
0, 0, 0, 0, 0, 0, .1f, .1f, .3f, .4f, 1.2f, 1.9f, 5.3f, 5.5f, 5.8f, 7.1f, 7.2f, 7.2f};
BOOST_CHECK(actual_turn_penalties == expected_turn_penalties);
// Verify that we got the expected turn penalties
std::vector<float> actual_turn_weights;
for (const auto &i : found_weight_indexes)
{
BOOST_CHECK(float_vals.count(i) == 1);
actual_turn_weights.push_back(float_vals[i]);
}
std::sort(actual_turn_weights.begin(), actual_turn_weights.end());
const std::vector<float> expected_turn_weights = {
0, 0, 0, 0, 0, 0, .1f, .1f, .3f, .4f, 1.2f, 1.9f, 5.3f, 5.5f, 5.8f, 7.1f, 7.2f, 7.2f};
BOOST_CHECK(actual_turn_weights == expected_turn_weights);
// Verify the expected turn angles
std::vector<std::int64_t> actual_turn_angles;
for (const auto &i : found_turn_angles_indexes)
@@ -401,7 +420,7 @@ BOOST_AUTO_TEST_CASE(test_tile_speeds)
auto property_iter_pair = feature_message.get_packed_uint32();
auto value_begin = property_iter_pair.begin();
auto value_end = property_iter_pair.end();
BOOST_CHECK_EQUAL(std::distance(value_begin, value_end), 10);
BOOST_CHECK_EQUAL(std::distance(value_begin, value_end), 12);
auto iter = value_begin;
BOOST_CHECK_EQUAL(*iter++, 0); // speed key
found_speed_indexes.push_back(*iter++);
@@ -410,10 +429,12 @@ BOOST_AUTO_TEST_CASE(test_tile_speeds)
found_component_indexes.push_back(*iter++);
BOOST_CHECK_EQUAL(*iter++, 2); // data source key
found_datasource_indexes.push_back(*iter++);
BOOST_CHECK_EQUAL(*iter++, 3); // duration key
BOOST_CHECK_EQUAL(*iter++, 3); // weight key
found_duration_indexes.push_back(*iter++);
BOOST_CHECK_EQUAL(*iter++, 4); // duration key
found_duration_indexes.push_back(*iter++);
// name
BOOST_CHECK_EQUAL(*iter++, 4);
BOOST_CHECK_EQUAL(*iter++, 5);
found_name_indexes.push_back(*iter++);
BOOST_CHECK(iter == value_end);
// geometry