restructured to only return valid turns to the outside + cleanup

This commit is contained in:
Moritz Kobitzsch 2016-03-17 14:09:09 +01:00 committed by Patrick Niklaus
parent a3cf7f09e8
commit 1cc9a2f4a1
8 changed files with 1286 additions and 1155 deletions

View File

@ -0,0 +1,202 @@
@routing @guidance
Feature: Basic Roundabout
Background:
Given the profile "testbot"
Given a grid size of 10 meters
Scenario: Ramp Exit Right
Given the node map
| a | b | c | d | e |
| | | | f | g |
And the ways
| nodes | highway |
| abcde | motorway |
| bfg | motorway_link |
When I route I should get
| waypoints | route | turns |
| a,e | abcde, abcde | depart, arrive |
| a,g | abcde, bfg, bfg | depart, ramp-slight-right, arrive |
Scenario: Ramp Exit Right Curved Right
Given the node map
| a | b | c | | |
| | | f | d | |
| | | | g | e |
And the ways
| nodes | highway |
| abcde | motorway |
| bfg | motorway_link |
When I route I should get
| waypoints | route | turns |
| a,e | abcde, abcde | depart, arrive |
| a,g | abcde, bfg, bfg | depart, ramp-slight-right, arrive |
Scenario: Ramp Exit Right Curved Left
Given the node map
| | | | | e |
| | | | d | g |
| a | b | c | f | |
And the ways
| nodes | highway |
| abcde | motorway |
| cfg | motorway_link |
When I route I should get
| waypoints | route | turns |
| a,e | abcde, abcde | depart, arrive |
| a,g | abcde, cfg, cfg | depart, ramp-slight-right, arrive |
Scenario: Ramp Exit Left
Given the node map
| | | | f | g |
| a | b | c | d | e |
And the ways
| nodes | highway |
| abcde | motorway |
| bfg | motorway_link |
When I route I should get
| waypoints | route | turns |
| a,e | abcde, abcde | depart, arrive |
| a,g | abcde, bfg, bfg | depart, ramp-slight-left, arrive |
Scenario: Ramp Exit Left Curved Left
Given the node map
| | | | g | e |
| | | f | d | |
| a | b | c | | |
And the ways
| nodes | highway |
| abcde | motorway |
| bfg | motorway_link |
When I route I should get
| waypoints | route | turns |
| a,e | abcde, abcde | depart, arrive |
| a,g | abcde, bfg, bfg | depart, ramp-slight-left, arrive |
Scenario: Ramp Exit Left Curved Right
Given the node map
| a | b | c | f | |
| | | | d | g |
| | | | | e |
And the ways
| nodes | highway |
| abcde | motorway |
| cfg | motorway_link |
When I route I should get
| waypoints | route | turns |
| a,e | abcde, abcde | depart, arrive |
| a,g | abcde, cfg, cfg | depart, ramp-slight-left, arrive |
Scenario: On Ramp Right
Given the node map
| a | b | c | d | e |
| f | g | | | |
And the ways
| nodes | highway |
| abcde | motorway |
| fgd | motorway_link |
When I route I should get
| waypoints | route | turns |
| a,e | abcde, abcde | depart, arrive |
| f,e | abcde, fgd, fgd | depart, merge-slight-left, arrive |
Scenario: On Ramp Left
Given the node map
| f | g | | | |
| a | b | c | d | e |
And the ways
| nodes | highway |
| abcde | motorway |
| fgd | motorway_link |
When I route I should get
| waypoints | route | turns |
| a,e | abcde, abcde | depart, arrive |
| f,e | abcde, fgd, fgd | depart, merge-slight-right, arrive |
Scenario: Highway Fork
Given the node map
| | | | | d | e |
| a | b | c | | | |
| | | | | f | g |
And the ways
| nodes | highway |
| abcde | motorway |
| cfg | motorway |
When I route I should get
| waypoints | route | turns |
| a,e | abcde, abcde, abcde | depart, fork-left, arrive |
| a,g | abcde, cfg, cfg | depart, fork-right, arrive |
Scenario: Fork After Ramp
Given the node map
| | | | | d | e |
| a | b | c | | | |
| | | | | f | g |
And the ways
| nodes | highway |
| abc | motorway_link |
| cde | motorway |
| cfg | motorway |
When I route I should get
| waypoints | route | turns |
| a,e | abc, cde, cde | depart, fork-left, arrive |
| a,g | abc, cfg, cfg | depart, fork-right, arrive |
Scenario: On And Off Ramp Right
Given the node map
| a | b | | c | | d | e |
| f | g | | | | h | i |
And the ways
| nodes | highway |
| abcde | motorway |
| fgc | motorway_link |
| chi | motorway_link |
When I route I should get
| waypoints | route | turns |
| a,e | abcde, abcde | depart, arrive |
| f,e | fgc, abcde, abcde | depart, merge-slight-left, arrive |
| a,i | abcde, chi, chi | depart, ramp-slight-right, arrive |
| f,i | fgc, chi, chi | depart, turn-slight-right, arrive |
Scenario: On And Off Ramp Left
Given the node map
| f | g | | | | h | i |
| a | b | | c | | d | e |
And the ways
| nodes | highway |
| abcde | motorway |
| fgc | motorway_link |
| chi | motorway_link |
When I route I should get
| waypoints | route | turns |
| a,e | abcde, abcde | depart, arrive |
| f,e | fgc, abcde, abcde | depart, merge-slight-right, arrive |
| a,i | abcde, chi, chi | depart, ramp-slight-left, arrive |
| f,i | fgc, chi, chi | depart, turn-slight-left, arrive |

View File

@ -7,19 +7,19 @@ Feature: Basic Roundabout
Scenario: Enter and Exit Scenario: Enter and Exit
Given the node map Given the node map
| | | a | | | | | | a | | |
| | | b | | | | | | b | | |
| h | g | | c | d | | h | g | | c | d |
| | | e | | | | | | e | | |
| | | f | | | | | | f | | |
And the ways And the ways
| nodes | roundabout | | nodes | roundabout |
| ab | false | | ab | no |
| cd | false | | cd | no |
| ef | false | | ef | no |
| gh | false | | gh | no |
| bcegb | true | | bcegb | yes |
When I route I should get When I route I should get
| waypoints | route | turns | | waypoints | route | turns |
@ -38,19 +38,19 @@ Feature: Basic Roundabout
Scenario: Only Enter Scenario: Only Enter
Given the node map Given the node map
| | | a | | | | | | a | | |
| | | b | | | | | | b | | |
| h | g | | c | d | | h | g | | c | d |
| | | e | | | | | | e | | |
| | | f | | | | | | f | | |
And the ways And the ways
| nodes | roundabout | | nodes | roundabout |
| ab | false | | ab | no |
| cd | false | | cd | no |
| ef | false | | ef | no |
| gh | false | | gh | no |
| bcegb | true | | bcegb | yes |
When I route I should get When I route I should get
| waypoints | route | turns | | waypoints | route | turns |
@ -73,19 +73,19 @@ Feature: Basic Roundabout
Scenario: Only Exit Scenario: Only Exit
Given the node map Given the node map
| | | a | | | | | | a | | |
| | | b | | | | | | b | | |
| h | g | | c | d | | h | g | | c | d |
| | | e | | | | | | e | | |
| | | f | | | | | | f | | |
And the ways And the ways
| nodes | roundabout | | nodes | roundabout |
| ab | false | | ab | no |
| cd | false | | cd | no |
| ef | false | | ef | no |
| gh | false | | gh | no |
| bcegb | true | | bcegb | yes |
When I route I should get When I route I should get
| waypoints | route | turns | | waypoints | route | turns |
@ -108,19 +108,19 @@ Feature: Basic Roundabout
Scenario: Drive Around Scenario: Drive Around
Given the node map Given the node map
| | | a | | | | | | a | | |
| | | b | | | | | | b | | |
| h | g | | c | d | | h | g | | c | d |
| | | e | | | | | | e | | |
| | | f | | | | | | f | | |
And the ways And the ways
| nodes | roundabout | | nodes | roundabout |
| ab | false | | ab | no |
| cd | false | | cd | no |
| ef | false | | ef | no |
| gh | false | | gh | no |
| bcegb | true | | bcegb | yes |
When I route I should get When I route I should get
| waypoints | route | turns | | waypoints | route | turns |
@ -138,3 +138,36 @@ Feature: Basic Roundabout
| g,e | bcegb,bcegb | depart, arrive | | g,e | bcegb,bcegb | depart, arrive |
Scenario: Mixed Entry and Exit Scenario: Mixed Entry and Exit
Given the node map
| | a | | c | |
| l | | b | | d |
| | k | | e | |
| j | | h | | f |
| | i | | g | |
And the ways
| nodes | roundabout | oneway |
| abc | no | yes |
| def | no | yes |
| ghi | no | yes |
| jkl | no | yes |
| behkb | yes | yes |
When I route I should get
| waypoints | route | turns |
| a,c | abc,abc,abc | depart, roundabout-exit-1, arrive |
| a,f | abc,def,def | depart, roundabout-exit-2, arrive |
| a,i | abc,ghi,ghi | depart, roundabout-exit-3, arrive |
| a,l | abc,jkl,jkl | depart, roundabout-exit-4, arrive |
| d,f | def,def,def | depart, roundabout-exit-1, arrive |
| d,i | def,ghi,ghi | depart, roundabout-exit-2, arrive |
| d,l | def,jkl,jkl | depart, roundabout-exit-3, arrive |
| d,c | def,abc,abc | depart, roundabout-exit-4, arrive |
| g,i | ghi,ghi,ghi | depart, roundabout-exit-1, arrive |
| g,l | ghi,jkl,jkl | depart, roundabout-exit-2, arrive |
| g,c | ghi,abc,abc | depart, roundabout-exit-3, arrive |
| g,f | ghi,edf,edf | depart, roundabout-exit-4, arrive |
| j,l | jkl,jkl,jkl | depart, roundabout-exit-1, arrive |
| j,c | jkl,abc,abc | depart, roundabout-exit-2, arrive |
| j,f | jkl,def,def | depart, roundabout-exit-3, arrive |
| j,i | jkl,ghi,ghi | depart, roundabout-exit-4, arrive |

View File

@ -17,7 +17,6 @@
#include <cmath> #include <cmath>
#include <cstdint> #include <cstdint>
#include <string> #include <string>
#include <iostream>
namespace osrm namespace osrm
{ {
@ -391,6 +390,9 @@ inline bool requiresNameAnnounced(const std::string &from, const std::string &to
inline int getPriority( const FunctionalRoadClass road_class ) inline int getPriority( const FunctionalRoadClass road_class )
{ {
//The road priorities indicate which roads can bee seen as more or less equal.
//They are used in Fork-Discovery. Possibly should be moved to profiles post v5?
//A fork can happen between road types that are at most 1 priority apart from each other
const constexpr int road_priority[] = {10, 0, 10, 2, 10, 4, 10, 6, 10, 8, 10, 11, 10, 12, 10, 14}; const constexpr int road_priority[] = {10, 0, 10, 2, 10, 4, 10, 6, 10, 8, 10, 11, 10, 12, 10, 14};
return road_priority[static_cast<int>(road_class)]; return road_priority[static_cast<int>(road_class)];
} }
@ -398,6 +400,9 @@ inline int getPriority( const FunctionalRoadClass road_class )
inline bool canBeSeenAsFork(const FunctionalRoadClass first, const FunctionalRoadClass second) inline bool canBeSeenAsFork(const FunctionalRoadClass first, const FunctionalRoadClass second)
{ {
// forks require similar road categories // forks require similar road categories
// Based on the priorities assigned above, we can set forks only if the road priorities match closely.
// Potentially we could include features like number of lanes here and others?
// Should also be moved to profiles
return std::abs(getPriority(first) - getPriority(second)) <= 1; return std::abs(getPriority(first) - getPriority(second)) <= 1;
} }

View File

@ -23,33 +23,49 @@ namespace extractor
namespace guidance namespace guidance
{ {
struct TurnCandidate // What is exposed to the outside
struct TurnOperation final
{ {
EdgeID eid; // the id of the arc EdgeID eid;
bool valid; // a turn may be relevant to good instructions, even if we cannot take the road double angle;
double angle; // the approximated angle of the turn TurnInstruction instruction;
TurnInstruction instruction; // a proposed instruction };
double confidence; // how close to the border is the turn?
// For the turn analysis, we require a full list of all connected roads to determine the outcome.
// Invalid turns can influence the perceived angles
//
// aaa(2)aa
// a - bbbbb
// aaa(1)aa
//
// will not be perceived as a turn from (1) -> b, and as a U-turn from (1) -> (2).
// In addition, they can influence whether a turn is obvious or not.
struct ConnectedRoad final
{
ConnectedRoad(const TurnOperation turn, const bool entry_allowed = false);
TurnOperation turn;
bool entry_allowed; // a turn may be relevant to good instructions, even if we cannot take
// the road
std::string toString() const std::string toString() const
{ {
std::string result = "[turn] "; std::string result = "[connection] ";
result += std::to_string(eid); result += std::to_string(turn.eid);
result += " valid: "; result += " allows entry: ";
result += std::to_string(valid); result += std::to_string(entry_allowed);
result += " angle: "; result += " angle: ";
result += std::to_string(angle); result += std::to_string(turn.angle);
result += " instruction: "; result += " instruction: ";
result += std::to_string(static_cast<std::int32_t>(instruction.type)) + " " + result += std::to_string(static_cast<std::int32_t>(turn.instruction.type)) + " " +
std::to_string(static_cast<std::int32_t>(instruction.direction_modifier)); std::to_string(static_cast<std::int32_t>(turn.instruction.direction_modifier));
result += " confidence: ";
result += std::to_string(confidence);
return result; return result;
} }
}; };
class TurnAnalysis class TurnAnalysis
{ {
public: public:
TurnAnalysis(const util::NodeBasedDynamicGraph &node_based_graph, TurnAnalysis(const util::NodeBasedDynamicGraph &node_based_graph,
const std::vector<QueryNode> &node_info_list, const std::vector<QueryNode> &node_info_list,
@ -59,7 +75,7 @@ class TurnAnalysis
const util::NameTable &name_table); const util::NameTable &name_table);
// the entry into the turn analysis // the entry into the turn analysis
std::vector<TurnCandidate> getTurns(const NodeID from_node, const EdgeID via_eid) const; std::vector<TurnOperation> getTurns(const NodeID from_node, const EdgeID via_eid) const;
private: private:
const util::NodeBasedDynamicGraph &node_based_graph; const util::NodeBasedDynamicGraph &node_based_graph;
@ -69,11 +85,12 @@ class TurnAnalysis
const CompressedEdgeContainer &compressed_edge_container; const CompressedEdgeContainer &compressed_edge_container;
const util::NameTable &name_table; const util::NameTable &name_table;
// Check for restrictions/barriers and generate a list of valid and invalid turns present at the // Check for restrictions/barriers and generate a list of valid and invalid turns present at
// the
// node reached // node reached
// from `from_node` via `via_eid` // from `from_node` via `via_eid`
// The resulting candidates have to be analysed for their actual instructions later on. // The resulting candidates have to be analysed for their actual instructions later on.
std::vector<TurnCandidate> getTurnCandidates(const NodeID from_node, std::vector<ConnectedRoad> getConnectedRoads(const NodeID from_node,
const EdgeID via_eid) const; const EdgeID via_eid) const;
// Merge segregated roads to omit invalid turns in favor of treating segregated roads as // Merge segregated roads to omit invalid turns in favor of treating segregated roads as
@ -87,10 +104,7 @@ class TurnAnalysis
// //
// The treatment results in a straight turn angle of 180º rather than a turn angle of approx // The treatment results in a straight turn angle of 180º rather than a turn angle of approx
// 160 // 160
std::vector<TurnCandidate> std::vector<ConnectedRoad> mergeSegregatedRoads(std::vector<ConnectedRoad> intersection) const;
mergeSegregatedRoads(const NodeID from_node,
const EdgeID via_eid,
std::vector<TurnCandidate> turn_candidates) const;
// TODO distinguish roundabouts and rotaries // TODO distinguish roundabouts and rotaries
// TODO handle bike/walk cases that allow crossing a roundabout! // TODO handle bike/walk cases that allow crossing a roundabout!
@ -98,108 +112,86 @@ class TurnAnalysis
// Processing of roundabouts // Processing of roundabouts
// Produces instructions to enter/exit a roundabout or to stay on it. // Produces instructions to enter/exit a roundabout or to stay on it.
// Performs the distinction between roundabout and rotaries. // Performs the distinction between roundabout and rotaries.
std::vector<TurnCandidate> handleRoundabouts(const NodeID from, std::vector<ConnectedRoad> handleRoundabouts(const EdgeID via_edge,
const EdgeID via_edge,
const bool on_roundabout, const bool on_roundabout,
const bool can_enter_roundabout,
const bool can_exit_roundabout, const bool can_exit_roundabout,
std::vector<TurnCandidate> turn_candidates) const; std::vector<ConnectedRoad> intersection) const;
// Indicates a Junction containing a motoryway // Indicates a Junction containing a motoryway
bool isMotorwayJunction(const NodeID from, bool isMotorwayJunction(const EdgeID via_edge,
const EdgeID via_edge, const std::vector<ConnectedRoad> &intersection) const;
const std::vector<TurnCandidate> &turn_candidates) const;
// Decide whether a turn is a turn or a ramp access // Decide whether a turn is a turn or a ramp access
TurnType findBasicTurnType(const EdgeID via_edge, const TurnCandidate &candidate) const; TurnType findBasicTurnType(const EdgeID via_edge, const ConnectedRoad &candidate) const;
// Get the Instruction for an obvious turn // Get the Instruction for an obvious turn
// Instruction will be a silent instruction // Instruction will be a silent instruction
TurnInstruction getInstructionForObvious(const std::size_t number_of_candidates, TurnInstruction getInstructionForObvious(const std::size_t number_of_candidates,
const EdgeID via_edge, const EdgeID via_edge,
const TurnCandidate &candidate) const; const ConnectedRoad &candidate) const;
// Helper Function that decides between NoTurn or NewName // Helper Function that decides between NoTurn or NewName
TurnInstruction TurnInstruction
noTurnOrNewName(const NodeID from, const EdgeID via_edge, const TurnCandidate &candidate) const; noTurnOrNewName(const NodeID from, const EdgeID via_edge, const ConnectedRoad &candidate) const;
// Basic Turn Handling // Basic Turn Handling
// Dead end. // Dead end.
std::vector<TurnCandidate> handleOneWayTurn(const NodeID from, std::vector<ConnectedRoad> handleOneWayTurn(std::vector<ConnectedRoad> intersection) const;
const EdgeID via_edge,
std::vector<TurnCandidate> turn_candidates) const;
// Mode Changes, new names... // Mode Changes, new names...
std::vector<TurnCandidate> handleTwoWayTurn(const NodeID from, std::vector<ConnectedRoad> handleTwoWayTurn(const EdgeID via_edge,
const EdgeID via_edge, std::vector<ConnectedRoad> intersection) const;
std::vector<TurnCandidate> turn_candidates) const;
// Forks, T intersections and similar // Forks, T intersections and similar
std::vector<TurnCandidate> handleThreeWayTurn(const NodeID from, std::vector<ConnectedRoad> handleThreeWayTurn(const EdgeID via_edge,
const EdgeID via_edge, std::vector<ConnectedRoad> intersection) const;
std::vector<TurnCandidate> turn_candidates) const;
// Normal Intersection. Can still contain forks... // Handling of turns larger then degree three
std::vector<TurnCandidate> handleFourWayTurn(const NodeID from, std::vector<ConnectedRoad> handleComplexTurn(const EdgeID via_edge,
const EdgeID via_edge, std::vector<ConnectedRoad> intersection) const;
std::vector<TurnCandidate> turn_candidates) const;
// Fallback for turns of high complexion
std::vector<TurnCandidate> handleComplexTurn(const NodeID from,
const EdgeID via_edge,
std::vector<TurnCandidate> turn_candidates) const;
// Any Junction containing motorways // Any Junction containing motorways
std::vector<TurnCandidate> handleMotorwayJunction( std::vector<ConnectedRoad> handleMotorwayJunction(
const NodeID from, const EdgeID via_edge, std::vector<TurnCandidate> turn_candidates) const; const EdgeID via_edge, std::vector<ConnectedRoad> intersection) const;
std::vector<TurnCandidate> handleFromMotorway(const NodeID from, std::vector<ConnectedRoad> handleFromMotorway(const EdgeID via_edge,
const EdgeID via_edge, std::vector<ConnectedRoad> intersection) const;
std::vector<TurnCandidate> turn_candidates) const;
std::vector<TurnCandidate> handleMotorwayRamp(const NodeID from, std::vector<ConnectedRoad> handleMotorwayRamp(const EdgeID via_edge,
const EdgeID via_edge, std::vector<ConnectedRoad> intersection) const;
std::vector<TurnCandidate> turn_candidates) const;
// Utility function, setting basic turn types. Prepares for normal turn handling. // Utility function, setting basic turn types. Prepares for normal turn handling.
std::vector<TurnCandidate> setTurnTypes(const NodeID from, std::vector<ConnectedRoad> setTurnTypes(const NodeID from,
const EdgeID via_edge, const EdgeID via_edge,
std::vector<TurnCandidate> turn_candidates) const; std::vector<ConnectedRoad> intersection) const;
// Utility function to handle direction modifier conflicts if reasonably possible
std::vector<TurnCandidate> handleConflicts(const NodeID from,
const EdgeID via_edge,
std::vector<TurnCandidate> turn_candidates) const;
// node_u -- (edge_1) --> node_v -- (edge_2) --> node_w
TurnInstruction AnalyzeTurn(const NodeID node_u,
const EdgeID edge1,
const NodeID node_v,
const EdgeID edge2,
const NodeID node_w,
const double angle) const;
// Assignment of specific turn types // Assignment of specific turn types
void assignFork(const EdgeID via_edge, TurnCandidate &left, TurnCandidate &right) const; void assignFork(const EdgeID via_edge, ConnectedRoad &left, ConnectedRoad &right) const;
void assignFork(const EdgeID via_edge, void assignFork(const EdgeID via_edge,
TurnCandidate &left, ConnectedRoad &left,
TurnCandidate &center, ConnectedRoad &center,
TurnCandidate &right) const; ConnectedRoad &right) const;
void void
handleDistinctConflict(const EdgeID via_edge, TurnCandidate &left, TurnCandidate &right) const; handleDistinctConflict(const EdgeID via_edge, ConnectedRoad &left, ConnectedRoad &right) const;
// Type specific fallbacks // Type specific fallbacks
std::vector<TurnCandidate> std::vector<ConnectedRoad>
fallbackTurnAssignmentMotorway(std::vector<TurnCandidate> turn_candidates) const; fallbackTurnAssignmentMotorway(std::vector<ConnectedRoad> intersection) const;
//Classification // Classification
std::size_t findObviousTurn( const EdgeID via_edge, const std::vector<TurnCandidate> &turn_candidates) const; std::size_t findObviousTurn(const EdgeID via_edge,
std::pair<std::size_t,std::size_t> findFork( const EdgeID via_edge, const std::vector<TurnCandidate> &turn_candidates) const; const std::vector<ConnectedRoad> &intersection) const;
std::pair<std::size_t, std::size_t>
findFork(const std::vector<ConnectedRoad> &intersection) const;
std::vector<TurnCandidate> assignLeftTurns( const EdgeID via_edge, std::vector<TurnCandidate> turn_candidates, const std::size_t starting_at ) const; std::vector<ConnectedRoad> assignLeftTurns(const EdgeID via_edge,
std::vector<TurnCandidate> assignRightTurns( const EdgeID via_edge, std::vector<TurnCandidate> turn_candidates, const std::size_t up_to ) const; std::vector<ConnectedRoad> intersection,
const std::size_t starting_at) const;
std::vector<ConnectedRoad> assignRightTurns(const EdgeID via_edge,
std::vector<ConnectedRoad> intersection,
const std::size_t up_to) const;
}; // class TurnAnalysis }; // class TurnAnalysis

View File

@ -10,14 +10,19 @@ namespace osrm
{ {
namespace util namespace util
{ {
// While this could, theoretically, hold any names in the fitting format,
// the NameTable allows access to a part of the Datafacade to allow
// processing based on name indices.
class NameTable class NameTable
{ {
private: private:
//FIXME should this use shared memory // FIXME should this use shared memory
RangeTable<16, false> m_name_table; RangeTable<16, false> m_name_table;
ShM<char, false>::vector m_names_char_list; ShM<char, false>::vector m_names_char_list;
public: public:
NameTable( const std::string &filename ); NameTable(const std::string &filename);
std::string get_name_for_id(const unsigned name_id) const; std::string get_name_for_id(const unsigned name_id) const;
}; };
} // namespace util } // namespace util

View File

@ -318,15 +318,12 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
} }
++node_based_edge_counter; ++node_based_edge_counter;
auto turn_candidates = turn_analysis.getTurns(node_u, edge_from_u); auto possible_turns = turn_analysis.getTurns(node_u, edge_from_u);
const NodeID node_v = m_node_based_graph->GetTarget(edge_from_u); const NodeID node_v = m_node_based_graph->GetTarget(edge_from_u);
for (const auto turn : turn_candidates) for (const auto turn : possible_turns)
{ {
if (!turn.valid)
continue;
const double turn_angle = turn.angle; const double turn_angle = turn.angle;
// only add an edge if turn is not prohibited // only add an edge if turn is not prohibited

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,6 @@
#include "util/name_table.hpp" #include "util/name_table.hpp"
#include "util/simple_logger.hpp" #include "util/simple_logger.hpp"
#include "util/exception.hpp"
#include <algorithm> #include <algorithm>
#include <limits> #include <limits>
@ -16,14 +17,23 @@ NameTable::NameTable(const std::string &filename)
{ {
boost::filesystem::ifstream name_stream(filename, std::ios::binary); boost::filesystem::ifstream name_stream(filename, std::ios::binary);
if( !name_stream )
throw exception("Failed to open " + filename + " for reading.");
name_stream >> m_name_table; name_stream >> m_name_table;
unsigned number_of_chars = 0; unsigned number_of_chars = 0;
name_stream.read(reinterpret_cast<char *>(&number_of_chars), sizeof(number_of_chars)); name_stream.read(reinterpret_cast<char *>(&number_of_chars), sizeof(number_of_chars));
if( !name_stream )
throw exception("Encountered invalid file, failed to read number of contained chars");
BOOST_ASSERT_MSG(0 != number_of_chars, "name file broken"); BOOST_ASSERT_MSG(0 != number_of_chars, "name file broken");
m_names_char_list.resize(number_of_chars + 1); //+1 gives sentinel element m_names_char_list.resize(number_of_chars + 1); //+1 gives sentinel element
name_stream.read(reinterpret_cast<char *>(&m_names_char_list[0]), name_stream.read(reinterpret_cast<char *>(&m_names_char_list[0]),
number_of_chars * sizeof(m_names_char_list[0])); number_of_chars * sizeof(m_names_char_list[0]));
if( !name_stream )
throw exception("Failed to read " + std::to_string(number_of_chars) + " characters from file.");
if (0 == m_names_char_list.size()) if (0 == m_names_char_list.size())
{ {
util::SimpleLogger().Write(logWARNING) << "list of street names is empty"; util::SimpleLogger().Write(logWARNING) << "list of street names is empty";