Skip to content

Commit

Permalink
Format updates
Browse files Browse the repository at this point in the history
  • Loading branch information
oxidase authored and danpat committed Feb 8, 2018
1 parent f6ecc3c commit 5b4c4d1
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 61 deletions.
100 changes: 54 additions & 46 deletions include/engine/api/route_api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,21 +108,24 @@ class RouteAPI : public BaseAPI
for (const auto &a : unpacked_path_segments)
{
util::Log(logDEBUG) << "Route: ";
util::Log(logDEBUG) << (source_traversed_in_reverse[0]
? segment_end_coordinates[0].source_phantom.reverse_segment_id.id
: segment_end_coordinates[0].source_phantom.forward_segment_id.id)
<< " ";
util::Log(logDEBUG)
<< (source_traversed_in_reverse[0]
? segment_end_coordinates[0].source_phantom.reverse_segment_id.id
: segment_end_coordinates[0].source_phantom.forward_segment_id.id)
<< " ";
for (const auto &b : a)
{
util::Log(logDEBUG) << "(";
util::Log(logDEBUG) << b.from_edge_based_node << " ";
util::Log(logDEBUG) << static_cast<int>(b.turn_instruction.type) << " ";
util::Log(logDEBUG) << static_cast<int>(b.turn_instruction.direction_modifier) << ") ";
util::Log(logDEBUG) << static_cast<int>(b.turn_instruction.direction_modifier)
<< ") ";
}
util::Log(logDEBUG) << (target_traversed_in_reverse[0]
? segment_end_coordinates[0].target_phantom.reverse_segment_id.id
: segment_end_coordinates[0].target_phantom.forward_segment_id.id)
<< " ";
util::Log(logDEBUG)
<< (target_traversed_in_reverse[0]
? segment_end_coordinates[0].target_phantom.reverse_segment_id.id
: segment_end_coordinates[0].target_phantom.forward_segment_id.id)
<< " ";

util::Log(logDEBUG) << std::endl;
}
Expand Down Expand Up @@ -171,7 +174,8 @@ class RouteAPI : public BaseAPI
for (auto current_step_it = steps.begin(); current_step_it != steps.end();
++current_step_it)
{
util::Log(logDEBUG) << "Searching for " << current_step_it->from_id << std::endl;
util::Log(logDEBUG) << "Searching for " << current_step_it->from_id
<< std::endl;
const auto overrides =
BaseAPI::facade.GetOverridesThatStartAt(current_step_it->from_id);
if (overrides.empty())
Expand All @@ -186,13 +190,13 @@ class RouteAPI : public BaseAPI
}
util::Log(logDEBUG) << std::endl;
util::Log(logDEBUG) << "Override type is "
<< osrm::guidance::internalInstructionTypeToString(
maneuver_relation.override_type)
<< std::endl;
<< osrm::guidance::internalInstructionTypeToString(
maneuver_relation.override_type)
<< std::endl;
util::Log(logDEBUG) << "Override direction is "
<< osrm::guidance::instructionModifierToString(
maneuver_relation.direction)
<< std::endl;
<< osrm::guidance::instructionModifierToString(
maneuver_relation.direction)
<< std::endl;

util::Log(logDEBUG) << "Route sequence is ";
for (auto it = current_step_it; it != steps.end(); ++it)
Expand Down Expand Up @@ -232,16 +236,17 @@ class RouteAPI : public BaseAPI
if (search_iter == maneuver_relation.node_sequence.end())
{
util::Log(logDEBUG) << "Node sequence matched, looking for the step "
<< "that has the via node" << std::endl;
<< "that has the via node" << std::endl;
const auto via_node_coords = BaseAPI::facade.GetCoordinateOfNode(
maneuver_relation.instruction_node);
// Find the step that has the instruction_node at the intersection point
auto step_to_update = std::find_if(
current_step_it,
route_iter,
[&leg_geometry, &via_node_coords](const auto &step) {
util::Log(logDEBUG) << "Leg geom from " << step.geometry_begin << " to "
<< step.geometry_end << std::endl;
util::Log(logDEBUG) << "Leg geom from " << step.geometry_begin
<< " to " << step.geometry_end
<< std::endl;

// iterators over geometry of current step
auto begin =
Expand All @@ -254,15 +259,16 @@ class RouteAPI : public BaseAPI
if (via_match != end)
{
util::Log(logDEBUG) << "Found geometry match at "
<< (std::distance(begin, end) -
std::distance(via_match, end))
<< std::endl;
<< (std::distance(begin, end) -
std::distance(via_match, end))
<< std::endl;
}
util::Log(logDEBUG) << ((*(leg_geometry.locations.begin() +
step.geometry_begin) == via_node_coords)
? "true"
: "false")
<< std::endl;
util::Log(logDEBUG)
<< ((*(leg_geometry.locations.begin() +
step.geometry_begin) == via_node_coords)
? "true"
: "false")
<< std::endl;
return *(leg_geometry.locations.begin() +
step.geometry_begin) == via_node_coords;
// return via_match != end;
Expand All @@ -272,34 +278,36 @@ class RouteAPI : public BaseAPI
if (step_to_update != route_iter)
{
// Don't update the last step (it's an arrive instruction)
util::Log(logDEBUG) << "Updating step "
<< std::distance(steps.begin(), steps.end()) -
std::distance(step_to_update, steps.end())
<< std::endl;
util::Log(logDEBUG)
<< "Updating step "
<< std::distance(steps.begin(), steps.end()) -
std::distance(step_to_update, steps.end())
<< std::endl;
if (maneuver_relation.override_type !=
osrm::guidance::TurnType::MaxTurnType)
{
util::Log(logDEBUG) << " instruction was "
<< osrm::guidance::internalInstructionTypeToString(
step_to_update->maneuver.instruction.type)
<< " now "
<< osrm::guidance::internalInstructionTypeToString(
maneuver_relation.override_type)
<< std::endl;
util::Log(logDEBUG)
<< " instruction was "
<< osrm::guidance::internalInstructionTypeToString(
step_to_update->maneuver.instruction.type)
<< " now "
<< osrm::guidance::internalInstructionTypeToString(
maneuver_relation.override_type)
<< std::endl;
step_to_update->maneuver.instruction.type =
maneuver_relation.override_type;
}
if (maneuver_relation.direction !=
osrm::guidance::DirectionModifier::MaxDirectionModifier)
{
util::Log(logDEBUG) << " direction was "
<< osrm::guidance::instructionModifierToString(
step_to_update->maneuver.instruction
.direction_modifier)
<< " now "
<< osrm::guidance::instructionModifierToString(
maneuver_relation.direction)
<< std::endl;
util::Log(logDEBUG)
<< " direction was "
<< osrm::guidance::instructionModifierToString(
step_to_update->maneuver.instruction
.direction_modifier)
<< " now " << osrm::guidance::instructionModifierToString(
maneuver_relation.direction)
<< std::endl;
step_to_update->maneuver.instruction.direction_modifier =
maneuver_relation.direction;
}
Expand Down
34 changes: 19 additions & 15 deletions include/engine/datafacade/contiguous_internalmem_datafacade.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -919,25 +919,29 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
// heterogeneous comparison:
struct Comp
{
bool operator() ( const extractor::StorageManeuverOverride& s, NodeID i ) const { return s.start_node < i; }
bool operator() ( NodeID i, const extractor::StorageManeuverOverride& s ) const { return i < s.start_node; }
bool operator()(const extractor::StorageManeuverOverride &s, NodeID i) const
{
return s.start_node < i;
}
bool operator()(NodeID i, const extractor::StorageManeuverOverride &s) const
{
return i < s.start_node;
}
};

auto found_range = std::equal_range(m_maneuver_overrides.begin(), m_maneuver_overrides.end(),
edge_based_node_id, Comp{});

std::for_each(found_range.first, found_range.second, [&](const auto &override) {
std::vector<NodeID> sequence(m_maneuver_override_node_sequences.begin() +
override.node_sequence_offset_begin,
m_maneuver_override_node_sequences.begin() +
override.node_sequence_offset_end);
results.push_back(extractor::ManeuverOverride{std::move(sequence),
override.instruction_node,
override.override_type,
override.direction});
auto found_range = std::equal_range(
m_maneuver_overrides.begin(), m_maneuver_overrides.end(), edge_based_node_id, Comp{});

std::for_each(found_range.first, found_range.second, [&](const auto & override) {
std::vector<NodeID> sequence(
m_maneuver_override_node_sequences.begin() + override.node_sequence_offset_begin,
m_maneuver_override_node_sequences.begin() + override.node_sequence_offset_end);
results.push_back(extractor::ManeuverOverride{std::move(sequence),
override.instruction_node,
override.override_type,
override.direction});
});
return results;

}
};

Expand Down

0 comments on commit 5b4c4d1

Please sign in to comment.