Skip to content

Commit

Permalink
added list of intersections to the step-maneuver, not in api so far
Browse files Browse the repository at this point in the history
  • Loading branch information
Moritz Kobitzsch committed Mar 22, 2016
1 parent 3692602 commit 5487542
Show file tree
Hide file tree
Showing 5 changed files with 200 additions and 142 deletions.
4 changes: 2 additions & 2 deletions include/engine/guidance/assemble_steps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
const bool source_traversed_in_reverse,
const bool target_traversed_in_reverse)
{
const double constexpr ZERO_DURACTION = 0., ZERO_DISTANCE = 0.;
const double constexpr ZERO_DURATION = 0., ZERO_DISTANCE = 0.;
const EdgeWeight source_duration =
source_traversed_in_reverse ? source_node.reverse_weight : source_node.forward_weight;
const auto source_mode = source_traversed_in_reverse ? source_node.backward_travel_mode
Expand Down Expand Up @@ -167,7 +167,7 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
WaypointType::Arrive, leg_geometry);
steps.push_back(RouteStep{target_node.name_id,
facade.GetNameForID(target_node.name_id),
ZERO_DURACTION,
ZERO_DURATION,
ZERO_DISTANCE,
target_mode,
final_maneuver,
Expand Down
11 changes: 10 additions & 1 deletion include/engine/guidance/step_maneuver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "extractor/guidance/turn_instruction.hpp"

#include <cstdint>
#include <vector>

namespace osrm
{
Expand All @@ -20,6 +21,14 @@ enum class WaypointType : std::uint8_t
Depart,
};

//A represenetation of intermediate intersections
struct IntermediateIntersection
{
double duration;
double distance;
util::Coordinate location;
};

struct StepManeuver
{
util::Coordinate location;
Expand All @@ -28,7 +37,7 @@ struct StepManeuver
extractor::guidance::TurnInstruction instruction;
WaypointType waypoint_type;
unsigned exit;
unsigned intersection;
std::vector<IntermediateIntersection> intersections;
};
} // namespace guidance
} // namespace engine
Expand Down
4 changes: 2 additions & 2 deletions src/engine/api/json_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ util::json::Object makeStepManeuver(const guidance::StepManeuver &maneuver)
//TODO currently we need this to comply with the api.
//We should move this to an additional entry, the moment we
//actually compute the correct locations of the intersections
if (maneuver.intersection != 0 && maneuver.exit == 0 )
step_maneuver.values["exit"] = maneuver.intersection;
if (!maneuver.intersections.empty() && maneuver.exit == 0 )
step_maneuver.values["exit"] = maneuver.intersections.size();
return step_maneuver;
}

Expand Down
32 changes: 18 additions & 14 deletions src/engine/guidance/assemble_steps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ StepManeuver stepManeuverFromGeometry(extractor::guidance::TurnInstruction instr
pre_turn_bearing =
util::coordinate_calculation::bearing(pre_turn_coordinate, turn_coordinate);
}
return StepManeuver{turn_coordinate,
pre_turn_bearing,
post_turn_bearing,
instruction,
waypoint_type,
INVALID_EXIT_NR,
INVALID_EXIT_NR};
return StepManeuver{
std::move(turn_coordinate),
pre_turn_bearing,
post_turn_bearing,
std::move(instruction),
waypoint_type,
INVALID_EXIT_NR,
{} // no intermediate intersections
};
}

StepManeuver stepManeuverFromGeometry(extractor::guidance::TurnInstruction instruction,
Expand All @@ -64,13 +66,15 @@ StepManeuver stepManeuverFromGeometry(extractor::guidance::TurnInstruction instr
const double post_turn_bearing =
util::coordinate_calculation::bearing(turn_coordinate, post_turn_coordinate);

return StepManeuver{turn_coordinate,
pre_turn_bearing,
post_turn_bearing,
instruction,
WaypointType::None,
INVALID_EXIT_NR,
INVALID_EXIT_NR};
return StepManeuver{
std::move(turn_coordinate),
pre_turn_bearing,
post_turn_bearing,
std::move(instruction),
WaypointType::None,
INVALID_EXIT_NR,
{} // no intermediate intersections
};
}
} // ns detail
} // ns engine
Expand Down
Loading

0 comments on commit 5487542

Please sign in to comment.