Merge pull request #1150 from Project-OSRM/feature/announce_via_locations

implements announcement of waypoints, closes #584
This commit is contained in:
Dennis Luxen 2014-08-12 11:49:51 +02:00
commit 1592fe377a
8 changed files with 38 additions and 25 deletions

View File

@ -69,6 +69,11 @@ struct RawRouteData
int shortest_path_length; int shortest_path_length;
int alternative_path_length; int alternative_path_length;
bool is_via_leg(const std::size_t leg) const
{
return (leg != unpacked_path_segments.size() - 1);
}
RawRouteData() RawRouteData()
: check_sum(SPECIAL_NODEID), : check_sum(SPECIAL_NODEID),
shortest_path_length(INVALID_EDGE_WEIGHT), shortest_path_length(INVALID_EDGE_WEIGHT),

View File

@ -31,7 +31,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
enum class TurnInstruction : unsigned char enum class TurnInstruction : unsigned char
{ {
NoTurn = 0, GoStraight, TurnSlightRight, TurnRight, TurnSharpRight, UTurn, NoTurn = 0, GoStraight, TurnSlightRight, TurnRight, TurnSharpRight, UTurn,
TurnSharpLeft, TurnLeft, TurnSlightLeft, ReachViaPoint, HeadOn, EnterRoundAbout, TurnSharpLeft, TurnLeft, TurnSlightLeft, ReachViaLocation, HeadOn, EnterRoundAbout,
LeaveRoundAbout, StayOnRoundAbout, StartAtEndOfStreet, ReachedYourDestination, LeaveRoundAbout, StayOnRoundAbout, StartAtEndOfStreet, ReachedYourDestination,
EnterAgainstAllowedDirection, LeaveAgainstAllowedDirection, EnterAgainstAllowedDirection, LeaveAgainstAllowedDirection,
InverseAccessRestrictionFlag = 127, InverseAccessRestrictionFlag = 127,

View File

@ -50,13 +50,19 @@ void DescriptionFactory::SetStartSegment(const PhantomNode &source, const bool t
BOOST_ASSERT(path_description.back().duration == segment_duration); BOOST_ASSERT(path_description.back().duration == segment_duration);
} }
void DescriptionFactory::SetEndSegment(const PhantomNode &target, const bool traversed_in_reverse) void DescriptionFactory::SetEndSegment(const PhantomNode &target, const bool traversed_in_reverse, const bool is_via_location)
{ {
target_phantom = target; target_phantom = target;
const EdgeWeight segment_duration = const EdgeWeight segment_duration =
(traversed_in_reverse ? target.reverse_weight : target.forward_weight); (traversed_in_reverse ? target.reverse_weight : target.forward_weight);
path_description.emplace_back( path_description.emplace_back(
target.location, target.name_id, segment_duration, 0.f, TurnInstruction::NoTurn, true, true); target.location,
target.name_id,
segment_duration,
0.f,
is_via_location ? TurnInstruction::ReachViaLocation : TurnInstruction::NoTurn,
true,
true);
BOOST_ASSERT(path_description.back().duration == segment_duration); BOOST_ASSERT(path_description.back().duration == segment_duration);
} }

View File

@ -80,7 +80,7 @@ class DescriptionFactory
void AppendSegment(const FixedPointCoordinate &coordinate, const PathData &data); void AppendSegment(const FixedPointCoordinate &coordinate, const PathData &data);
void BuildRouteSummary(const double distance, const unsigned time); void BuildRouteSummary(const double distance, const unsigned time);
void SetStartSegment(const PhantomNode &start_phantom, const bool traversed_in_reverse); void SetStartSegment(const PhantomNode &start_phantom, const bool traversed_in_reverse);
void SetEndSegment(const PhantomNode &start_phantom, const bool traversed_in_reverse); void SetEndSegment(const PhantomNode &start_phantom, const bool traversed_in_reverse, const bool is_via_location = false);
JSON::Value AppendEncodedPolylineString(const bool return_encoded); JSON::Value AppendEncodedPolylineString(const bool return_encoded);
std::vector<unsigned> const & GetViaIndices() const; std::vector<unsigned> const & GetViaIndices() const;

View File

@ -76,7 +76,8 @@ template <class DataFacadeT> class JSONDescriptor : public BaseDescriptor<DataFa
unsigned DescribeLeg(const std::vector<PathData> route_leg, unsigned DescribeLeg(const std::vector<PathData> route_leg,
const PhantomNodes &leg_phantoms, const PhantomNodes &leg_phantoms,
const bool target_traversed_in_reverse) const bool target_traversed_in_reverse,
const bool is_via_leg)
{ {
unsigned added_element_count = 0; unsigned added_element_count = 0;
// Get all the coordinates for the computed route // Get all the coordinates for the computed route
@ -87,7 +88,7 @@ template <class DataFacadeT> class JSONDescriptor : public BaseDescriptor<DataFa
description_factory.AppendSegment(current_coordinate, path_data); description_factory.AppendSegment(current_coordinate, path_data);
++added_element_count; ++added_element_count;
} }
description_factory.SetEndSegment(leg_phantoms.target_phantom, target_traversed_in_reverse); description_factory.SetEndSegment(leg_phantoms.target_phantom, target_traversed_in_reverse, is_via_leg);
++added_element_count; ++added_element_count;
BOOST_ASSERT((route_leg.size() + 1) == added_element_count); BOOST_ASSERT((route_leg.size() + 1) == added_element_count);
return added_element_count; return added_element_count;
@ -126,7 +127,8 @@ template <class DataFacadeT> class JSONDescriptor : public BaseDescriptor<DataFa
#endif #endif
DescribeLeg(raw_route.unpacked_path_segments[i], DescribeLeg(raw_route.unpacked_path_segments[i],
raw_route.segment_end_coordinates[i], raw_route.segment_end_coordinates[i],
raw_route.target_traversed_in_reverse[i]); raw_route.target_traversed_in_reverse[i],
raw_route.is_via_leg(i));
BOOST_ASSERT(0 < added_segments); BOOST_ASSERT(0 < added_segments);
} }
description_factory.Run(facade, config.zoom_level); description_factory.Run(facade, config.zoom_level);

View File

@ -73,6 +73,6 @@ Feature: Avoid weird loops caused by rounding errors
| cf | secondary | | cf | secondary |
When I route I should get When I route I should get
| waypoints | route | turns | | waypoints | route | turns |
| a,2,d | ab,be,ef,cf,cd | head,left,right,right,left,destination | | a,2,d | ab,be,ef,ef,cf,cd | head,left,right,via,right,left,destination |
| a,1,d | ab,be,ef,cf,cd | head,left,right,right,left,destination | | a,1,d | ab,be,ef,ef,cf,cd | head,left,right,via,right,left,destination |

View File

@ -21,7 +21,7 @@ Feature: U-turns at via points
When I route I should get When I route I should get
| waypoints | route | turns | | waypoints | route | turns |
| a,e,c | ab,be,ef,fg,dg,cd | head,right,left,straight,left,left,destination | | a,e,c | ab,be,be,ef,fg,dg,cd | head,right,via,left,straight,left,left,destination |
Scenario: Query param to allow U-turns at all via points Scenario: Query param to allow U-turns at all via points
Given the node map Given the node map
@ -42,8 +42,8 @@ Feature: U-turns at via points
| fg | | fg |
When I route I should get When I route I should get
| waypoints | route | | waypoints | route |
| a,e,c | ab,be,bc | | a,e,c | ab,be,be,bc |
@todo @todo
Scenario: Instructions at via points at u-turns Scenario: Instructions at via points at u-turns

View File

@ -13,9 +13,9 @@ Feature: Via points
| abc | | abc |
When I route I should get When I route I should get
| waypoints | route | | waypoints | route |
| a,b,c | abc | | a,b,c | abc,abc |
| c,b,a | abc | | c,b,a | abc,abc |
Scenario: Via point at a dead end Scenario: Via point at a dead end
Given the node map Given the node map
@ -28,9 +28,9 @@ Feature: Via points
| bd | | bd |
When I route I should get When I route I should get
| waypoints | route | | waypoints | route |
| a,d,c | abc,bd,bd,abc | | a,d,c | abc,bd,bd,bd,abc |
| c,d,a | abc,bd,bd,abc | | c,d,a | abc,bd,bd,bd,abc |
Scenario: Multiple via points Scenario: Multiple via points
Given the node map Given the node map
@ -48,9 +48,9 @@ Feature: Via points
| dh | | dh |
When I route I should get When I route I should get
| waypoints | route | | waypoints | route |
| a,c,f | ab,bcd,de,efg | | a,c,f | ab,bcd,bcd,de,efg |
| a,c,f,h | ab,bcd,de,efg,gh | | a,c,f,h | ab,bcd,bcd,de,efg,efg,gh |
Scenario: Via points on ring of oneways Scenario: Via points on ring of oneways
# xa it to avoid only having a single ring, which cna trigger edge cases # xa it to avoid only having a single ring, which cna trigger edge cases
@ -73,9 +73,9 @@ Feature: Via points
| waypoints | route | distance | turns | | waypoints | route | distance | turns |
| 1,3 | ab,bc,cd | 400m +-1 | head,straight,straight,destination | | 1,3 | ab,bc,cd | 400m +-1 | head,straight,straight,destination |
| 3,1 | cd,de,ef,fa,ab | 1000m +-1 | head,right,right,right,right,destination | | 3,1 | cd,de,ef,fa,ab | 1000m +-1 | head,right,right,right,right,destination |
| 1,2,3 | ab,bc,cd | 400m +-1 | head,straight,straight,destination | | 1,2,3 | ab,bc,bc,cd | 400m +-1 | head,straight,via,straight,destination |
| 1,3,2 | ab,bc,cd,de,ef,fa,ab,bc | 1600m +-1 | head,straight,straight,right,right,right,right,straight,destination | | 1,3,2 | ab,bc,cd,cd,de,ef,fa,ab,bc | 1600m +-1 | head,straight,straight,via,right,right,right,right,straight,destination |
| 3,2,1 | cd,de,ef,fa,ab,bc,cd,de,ef,fa,ab | 2400m +-1 | head,right,right,right,right,straight,straight,right,right,right,right,destination | | 3,2,1 | cd,de,ef,fa,ab,bc,bc,cd,de,ef,fa,ab | 2400m +-1 | head,right,right,right,right,straight,via,straight,right,right,right,right,destination |
@bug @bug
Scenario: Via points on ring on the same oneway Scenario: Via points on ring on the same oneway