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 4f15498
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 25 deletions.
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{
turn_coordinate,
pre_turn_bearing,
post_turn_bearing,
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{
turn_coordinate,
pre_turn_bearing,
post_turn_bearing,
instruction,
WaypointType::None,
INVALID_EXIT_NR,
{} // no intermediate intersections
};
}
} // ns detail
} // ns engine
Expand Down
25 changes: 17 additions & 8 deletions src/engine/guidance/post_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ RouteStep forwardInto(RouteStep destination, const RouteStep &source)
// Overwrites turn instruction and increases exit NR
destination.duration += source.duration;
destination.distance += source.distance;
destination.geometry_begin = std::min( destination.geometry_begin, source.geometry_begin );
destination.geometry_end = std::max( destination.geometry_end, source.geometry_end );
destination.geometry_begin = std::min(destination.geometry_begin, source.geometry_begin);
destination.geometry_end = std::max(destination.geometry_end, source.geometry_end);
return destination;
}

Expand All @@ -51,8 +51,13 @@ void print(const std::vector<RouteStep> &steps)
std::cout << "\t[" << ++segment << "]: " << type << " " << modifier
<< " Duration: " << step.duration << " Distance: " << step.distance
<< " Geometry: " << step.geometry_begin << " " << step.geometry_end
<< " exit: " << step.maneuver.exit << " Intersection: " << step.maneuver.intersection << " name[" << step.name_id
<< "]: " << step.name << std::endl;
<< " exit: " << step.maneuver.exit
<< " Intersections: " << step.maneuver.intersections.size() << " [";

for (auto intersection : step.maneuver.intersections)
std::cout << "(" << intersection.duration << " " << intersection.distance << ")";

std::cout << "] name[" << step.name_id << "]: " << step.name << std::endl;
}
}

Expand Down Expand Up @@ -149,7 +154,7 @@ std::vector<RouteStep> postProcess(std::vector<RouteStep> steps)
? TurnType::EnterRotary
: TurnType::EnterRoundabout;

//remember the now enter-instruction as valid
// remember the now enter-instruction as valid
last_valid_instruction = 1;
}

Expand Down Expand Up @@ -191,14 +196,18 @@ std::vector<RouteStep> postProcess(std::vector<RouteStep> steps)
}
else if (instruction.type == TurnType::Suppressed)
{
// count intersections. We cannot use exit, since intersections can follow directly after a roundabout
steps[last_valid_instruction].maneuver.intersection += 1;
// count intersections. We cannot use exit, since intersections can follow directly
// after a roundabout
steps[last_valid_instruction].maneuver.intersections.push_back(
{steps[last_valid_instruction].duration,
steps[last_valid_instruction].distance,
step.maneuver.location});

steps[last_valid_instruction] =
detail::forwardInto(steps[last_valid_instruction], step);
step.maneuver.instruction = TurnInstruction::NO_TURN();
}
else if( !isSilent(instruction) )
else if (!isSilent(instruction))
{
// Remember the last non silent instruction
last_valid_instruction = step_index;
Expand Down

0 comments on commit 4f15498

Please sign in to comment.