Skip to content

Commit 341109a

Browse files
oxidasedaniel-j-h
authored andcommitted
Adjusted number of nodes in annotation, resolves #3515
Conflicts: CHANGELOG.md
1 parent a0b1a5d commit 341109a

File tree

3 files changed

+84
-2
lines changed

3 files changed

+84
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- PR #3504 - debug tiles were very slow to generate due to unnecessarily copying data in a hot loop.
55
- PR #3556 - fix an assertion in the walking profile triggered by tight spiral stairwells
66
- PR #3469 - don't assert when identical coordinates are supplied to some calculations - OSM data contains these, we shouldn't crash.
7+
- PR #3515 - adjusted number of `nodes` in `annotation`
78
- Enhancements:
89
- backported 6ea9f9fdf19 - when anticipating upcoming lanes, consider how many lanes need to be crossed to get there.
910
- when using osrm-datastore, it will attempt to clean up locks if it crashes.
@@ -396,5 +397,3 @@
396397
- `properties.use_turn_restrictions`
397398
- `properties.u_turn_penalty`
398399
- `properties.allow_u_turn_at_via`
399-
400-

src/engine/guidance/post_processing.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,6 +1441,7 @@ void trimShortSegments(std::vector<RouteStep> &steps, LegGeometry &geometry)
14411441
// This can happen if the last coordinate snaps to a node in the unpacked geometry
14421442
geometry.locations.pop_back();
14431443
geometry.annotations.pop_back();
1444+
geometry.osm_node_ids.pop_back();
14441445
geometry.segment_offsets.back()--;
14451446
// since the last geometry includes the location of arrival, the arrival instruction
14461447
// geometry overlaps with the previous segment

unit_tests/engine/guidance_assembly.cpp

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "engine/guidance/assemble_overview.hpp"
44
#include "engine/guidance/assemble_route.hpp"
55
#include "engine/guidance/assemble_steps.hpp"
6+
#include "engine/guidance/post_processing.hpp"
67

78
#include <boost/test/test_case_template.hpp>
89
#include <boost/test/unit_test.hpp>
@@ -17,4 +18,85 @@ BOOST_AUTO_TEST_CASE(rfc4648_test_vectors)
1718
// TODO(daniel-j-h):
1819
}
1920

21+
BOOST_AUTO_TEST_CASE(trim_short_segments)
22+
{
23+
//using namespace osrm::extractor::guidance;
24+
using namespace osrm::engine::guidance;
25+
using namespace osrm::engine;
26+
using namespace osrm::util;
27+
28+
Intersection intersection1{{FloatLongitude{-73.981154}, FloatLatitude{40.767762}},
29+
{302},
30+
{1},
31+
Intersection::NO_INDEX,
32+
0,
33+
{0, 255},
34+
{}};
35+
Intersection intersection2{{FloatLongitude{-73.981495}, FloatLatitude{40.768275}},
36+
{180},
37+
{1},
38+
0,
39+
Intersection::NO_INDEX,
40+
{0, 255},
41+
{}};
42+
43+
// Check that duplicated coordinate in the end is removed
44+
std::vector<RouteStep> steps = {{324,
45+
"Central Park West",
46+
"",
47+
"",
48+
"",
49+
"",
50+
"",
51+
0.2,
52+
1.9076601161280742,
53+
TRAVEL_MODE_DRIVING,
54+
{{FloatLongitude{-73.981492}, FloatLatitude{40.768258}},
55+
329,
56+
348,
57+
{TurnType::ExitRotary, DirectionModifier::Straight},
58+
WaypointType::Depart,
59+
0},
60+
0,
61+
3,
62+
{intersection1}},
63+
{324,
64+
"Central Park West",
65+
"",
66+
"",
67+
"",
68+
"",
69+
"",
70+
0,
71+
0,
72+
TRAVEL_MODE_DRIVING,
73+
{{FloatLongitude{-73.981495}, FloatLatitude{40.768275}},
74+
0,
75+
0,
76+
{TurnType::NoTurn, DirectionModifier::UTurn},
77+
WaypointType::Arrive,
78+
0},
79+
2,
80+
3,
81+
{intersection2}}};
82+
83+
LegGeometry geometry;
84+
geometry.locations = {{FloatLongitude{-73.981492}, FloatLatitude{40.768258}},
85+
{FloatLongitude{-73.981495}, FloatLatitude{40.768275}},
86+
{FloatLongitude{-73.981495}, FloatLatitude{40.768275}}};
87+
geometry.segment_offsets = {0, 2};
88+
geometry.segment_distances = {1.9076601161280742};
89+
geometry.osm_node_ids = {OSMNodeID{0}, OSMNodeID{1}, OSMNodeID{2}};
90+
geometry.annotations = {{1.9076601161280742, 0.2, 0}, {0, 0, 0}};
91+
92+
trimShortSegments(steps, geometry);
93+
94+
BOOST_CHECK_EQUAL(geometry.segment_distances.size(), 1);
95+
BOOST_CHECK_EQUAL(geometry.segment_offsets.size(), 2);
96+
BOOST_CHECK_EQUAL(geometry.segment_offsets.back(), 1);
97+
BOOST_CHECK_EQUAL(geometry.annotations.size(), 1);
98+
BOOST_CHECK_EQUAL(geometry.locations.size(), 2);
99+
BOOST_CHECK_EQUAL(geometry.osm_node_ids.size(), 2);
100+
}
101+
20102
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)