From 3e6f27d1736f66caee08fca43fae6802bd6df9d1 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Sat, 9 Aug 2014 11:23:41 +0200 Subject: [PATCH 01/49] rename contra_flow to travel_mode, use unsigned char --- Contractor/EdgeBasedGraphFactory.cpp | 4 ++-- DataStructures/ImportEdge.cpp | 4 ++-- DataStructures/ImportEdge.h | 4 ++-- DataStructures/NodeBasedGraph.h | 8 ++++---- Extractor/ExtractionContainers.cpp | 2 +- Extractor/InternalExtractorEdge.h | 8 ++++---- Util/GraphLoader.h | 13 +++++++------ 7 files changed, 22 insertions(+), 21 deletions(-) diff --git a/Contractor/EdgeBasedGraphFactory.cpp b/Contractor/EdgeBasedGraphFactory.cpp index 0eeaeced7..3adea2a97 100644 --- a/Contractor/EdgeBasedGraphFactory.cpp +++ b/Contractor/EdgeBasedGraphFactory.cpp @@ -718,11 +718,11 @@ TurnInstruction EdgeBasedGraphFactory::AnalyzeTurn(const NodeID node_u, const EdgeData &data1 = m_node_based_graph->GetEdgeData(edge1); const EdgeData &data2 = m_node_based_graph->GetEdgeData(edge2); - if (!data1.contraFlow && data2.contraFlow) + if (!data1.travel_mode && data2.travel_mode) { return TurnInstruction::EnterAgainstAllowedDirection; } - if (data1.contraFlow && !data2.contraFlow) + if (data1.travel_mode && !data2.travel_mode) { return TurnInstruction::LeaveAgainstAllowedDirection; } diff --git a/DataStructures/ImportEdge.cpp b/DataStructures/ImportEdge.cpp index 0d04b9fb0..b8c157dff 100644 --- a/DataStructures/ImportEdge.cpp +++ b/DataStructures/ImportEdge.cpp @@ -56,11 +56,11 @@ NodeBasedEdge::NodeBasedEdge(NodeID source, bool roundabout, bool in_tiny_cc, bool access_restricted, - bool contra_flow, + TravelMode travel_mode, bool is_split) : source(source), target(target), name_id(name_id), weight(weight), type(type), forward(forward), backward(backward), roundabout(roundabout), in_tiny_cc(in_tiny_cc), - access_restricted(access_restricted), contra_flow(contra_flow), is_split(is_split) + access_restricted(access_restricted), travel_mode(travel_mode), is_split(is_split) { BOOST_ASSERT_MSG(type > 0, "negative edge type"); } diff --git a/DataStructures/ImportEdge.h b/DataStructures/ImportEdge.h index ecaffc97c..d8ddf49ae 100644 --- a/DataStructures/ImportEdge.h +++ b/DataStructures/ImportEdge.h @@ -44,7 +44,7 @@ struct NodeBasedEdge bool roundabout, bool in_tiny_cc, bool access_restricted, - bool contra_flow, + TravelMode travel_mode, bool is_split); NodeID source; @@ -57,7 +57,7 @@ struct NodeBasedEdge bool roundabout : 1; bool in_tiny_cc : 1; bool access_restricted : 1; - bool contra_flow : 1; + TravelMode travel_mode : 1; bool is_split : 1; NodeBasedEdge() = delete; diff --git a/DataStructures/NodeBasedGraph.h b/DataStructures/NodeBasedGraph.h index 580c71d86..464c31605 100644 --- a/DataStructures/NodeBasedGraph.h +++ b/DataStructures/NodeBasedGraph.h @@ -15,7 +15,7 @@ struct NodeBasedEdgeData : distance(INVALID_EDGE_WEIGHT), edgeBasedNodeID(SPECIAL_NODEID), nameID(std::numeric_limits::max()), type(std::numeric_limits::max()), isAccessRestricted(false), shortcut(false), forward(false), backward(false), - roundabout(false), ignore_in_grid(false), contraFlow(false) + roundabout(false), ignore_in_grid(false), travel_mode(false) { } @@ -29,7 +29,7 @@ struct NodeBasedEdgeData bool backward : 1; bool roundabout : 1; bool ignore_in_grid : 1; - bool contraFlow : 1; + TravelMode travel_mode : 1; void SwapDirectionFlags() { @@ -42,7 +42,7 @@ struct NodeBasedEdgeData { return (forward == other.forward) && (backward == other.backward) && (nameID == other.nameID) && (ignore_in_grid == other.ignore_in_grid) && - (contraFlow == other.contraFlow); + (travel_mode == other.travel_mode); } }; @@ -93,7 +93,7 @@ NodeBasedDynamicGraphFromImportEdges(int number_of_nodes, std::vectoris_roundabout, sizeof(bool)); file_out_stream.write((char *)&edge_iterator->is_in_tiny_cc, sizeof(bool)); file_out_stream.write((char *)&edge_iterator->is_access_restricted, sizeof(bool)); - file_out_stream.write((char *)&edge_iterator->is_contra_flow, sizeof(bool)); + file_out_stream.write((char *)&edge_iterator->travel_mode, sizeof(TravelMode)); file_out_stream.write((char *)&edge_iterator->is_split, sizeof(bool)); ++number_of_used_edges; } diff --git a/Extractor/InternalExtractorEdge.h b/Extractor/InternalExtractorEdge.h index 852f9f929..0e3e7dfd7 100644 --- a/Extractor/InternalExtractorEdge.h +++ b/Extractor/InternalExtractorEdge.h @@ -38,7 +38,7 @@ struct InternalExtractorEdge InternalExtractorEdge() : start(0), target(0), type(0), direction(0), speed(0), name_id(0), is_roundabout(false), is_in_tiny_cc(false), is_duration_set(false), is_access_restricted(false), - is_contra_flow(false), is_split(false) + travel_mode(0), is_split(false) { } @@ -52,12 +52,12 @@ struct InternalExtractorEdge bool is_in_tiny_cc, bool is_duration_set, bool is_access_restricted, - bool is_contra_flow, + TravelMode travel_mode, bool is_split) : start(start), target(target), type(type), direction(direction), speed(speed), name_id(name_id), is_roundabout(is_roundabout), is_in_tiny_cc(is_in_tiny_cc), is_duration_set(is_duration_set), is_access_restricted(is_access_restricted), - is_contra_flow(is_contra_flow), is_split(is_split) + travel_mode(travel_mode), is_split(is_split) { BOOST_ASSERT(0 <= type); } @@ -83,7 +83,7 @@ struct InternalExtractorEdge bool is_in_tiny_cc; bool is_duration_set; bool is_access_restricted; - bool is_contra_flow; + TravelMode travel_mode; bool is_split; FixedPointCoordinate source_coordinate; diff --git a/Util/GraphLoader.h b/Util/GraphLoader.h index c943b789c..6a61676cb 100644 --- a/Util/GraphLoader.h +++ b/Util/GraphLoader.h @@ -129,8 +129,8 @@ NodeID readBinaryOSRMGraphFromStream(std::istream &input_stream, short type; NodeID nameID; int length; - bool is_roundabout, ignore_in_grid, is_access_restricted, is_contra_flow, is_split; - + bool is_roundabout, ignore_in_grid, is_access_restricted, is_split; + TravelMode travel_mode; for (EdgeID i = 0; i < m; ++i) { input_stream.read((char *)&source, sizeof(unsigned)); @@ -143,7 +143,7 @@ NodeID readBinaryOSRMGraphFromStream(std::istream &input_stream, input_stream.read((char *)&is_roundabout, sizeof(bool)); input_stream.read((char *)&ignore_in_grid, sizeof(bool)); input_stream.read((char *)&is_access_restricted, sizeof(bool)); - input_stream.read((char *)&is_contra_flow, sizeof(bool)); + input_stream.read((char *)&travel_mode, sizeof(TravelMode)); input_stream.read((char *)&is_split, sizeof(bool)); BOOST_ASSERT_MSG(length > 0, "loaded null length edge"); @@ -200,7 +200,7 @@ NodeID readBinaryOSRMGraphFromStream(std::istream &input_stream, is_roundabout, ignore_in_grid, is_access_restricted, - is_contra_flow, + travel_mode, is_split); } @@ -306,7 +306,8 @@ NodeID readBinaryOSRMGraphFromStream(std::istream &input_stream, short type; NodeID nameID; int length; - bool is_roundabout, ignore_in_grid, is_access_restricted, is_contra_flow, is_split; + bool is_roundabout, ignore_in_grid, is_access_restricted, is_split; + TravelMode travel_mode; for (EdgeID i = 0; i < m; ++i) { @@ -320,7 +321,7 @@ NodeID readBinaryOSRMGraphFromStream(std::istream &input_stream, input_stream.read((char *)&is_roundabout, sizeof(bool)); input_stream.read((char *)&ignore_in_grid, sizeof(bool)); input_stream.read((char *)&is_access_restricted, sizeof(bool)); - input_stream.read((char *)&is_contra_flow, sizeof(bool)); + input_stream.read((char *)&travel_mode, sizeof(TravelMode)); input_stream.read((char *)&is_split, sizeof(bool)); BOOST_ASSERT_MSG(length > 0, "loaded null length edge"); From d09394ed525d8950f3ece5f3dc72cea106989a47 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Sat, 9 Aug 2014 11:44:35 +0200 Subject: [PATCH 02/49] add failing tests for travel mode --- features/bicycle/mode.feature | 210 ++++++++++++++++++++++------------ features/testbot/mode.feature | 154 ++++++++++++++++++++++--- 2 files changed, 273 insertions(+), 91 deletions(-) diff --git a/features/bicycle/mode.feature b/features/bicycle/mode.feature index eac04302c..30be18418 100644 --- a/features/bicycle/mode.feature +++ b/features/bicycle/mode.feature @@ -1,89 +1,151 @@ -@routing @bicycle @mode +routing @bicycle @mode Feature: Bike - Mode flag - Background: - Given the profile "bicycle" +# bicycle modes: +# 1 bike +# 2 pushing +# 3 ferry +# 4 train - @todo + Background: + Given the profile "bicycle" + Scenario: Bike - Mode when using a ferry - Given the node map - | a | b | | - | | c | d | + Given the node map + | a | b | | + | | c | d | - And the ways - | nodes | highway | route | duration | - | ab | primary | | | - | bc | | ferry | 0:01 | - | cd | primary | | | + And the ways + | nodes | highway | route | duration | + | ab | primary | | | + | bc | | ferry | 0:01 | + | cd | primary | | | - When I route I should get - | from | to | route | turns | modes | - | a | d | ab,bc,cd | head,right,left, destination | bike,ferry,bike | - | d | a | cd,bc,ab | head,right,left, destination | bike,ferry,bike | - | c | a | bc,ab | head,left,destination | ferry,bike | - | d | b | cd,bc | head,right,destination | bike,ferry | - | a | c | ab,bc | head,right,destination | bike,ferry | - | b | d | bc,cd | head,left,destination | ferry,bike | + When I route I should get + | from | to | route | turns | modes | + | a | d | ab,bc,cd | head,right,left,destination | 1,3,1 | + | d | a | cd,bc,ab | head,right,left,destination | 1,3,1 | + | c | a | bc,ab | head,left,destination | 3,1 | + | d | b | cd,bc | head,right,destination | 1,3 | + | a | c | ab,bc | head,right,destination | 1,3 | + | b | d | bc,cd | head,left,destination | 3,1 | - @todo - Scenario: Bike - Mode when pushing bike against oneways - Given the node map - | a | b | | - | | c | d | + Scenario: Bike - Mode when using a train + Given the node map + | a | b | | + | | c | d | - And the ways - | nodes | highway | oneway | - | ab | primary | | - | bc | primary | yes | - | cd | primary | | + And the ways + | nodes | highway | railway | bicycle | + | ab | primary | | | + | bc | | train | yes | + | cd | primary | | | - When I route I should get - | from | to | route | turns | modes | - | a | d | ab,bc,cd | head,right,left,destination | bike,push,bike | - | d | a | cd,bc,ab | head,right,left,destination | bike,push,bike | - | c | a | bc,ab | head,left,destination | push,bike | - | d | b | cd,bc | head,right,destination | bike,push | - | a | c | ab,bc | head,right,destination | bike,push | - | b | d | bc,cd | head,left,destination | push,bike | + When I route I should get + | from | to | route | turns | modes | + | a | d | ab,bc,cd | head,right,left,destination | 1,4,1 | + | d | a | cd,bc,ab | head,right,left,destination | 1,4,1 | + | c | a | bc,ab | head,left,destination | 4,1 | + | d | b | cd,bc | head,right,destination | 1,4 | + | a | c | ab,bc | head,right,destination | 1,4 | + | b | d | bc,cd | head,left,destination | 4,1 | - @todo - Scenario: Bike - Mode when pushing on pedestrain streets - Given the node map - | a | b | | - | | c | d | + Scenario: Bike - Mode when pushing bike against oneways + Given the node map + | a | b | | + | | c | d | - And the ways - | nodes | highway | - | ab | primary | - | bc | pedestrian | - | cd | primary | + And the ways + | nodes | highway | oneway | + | ab | primary | | + | bc | primary | yes | + | cd | primary | | - When I route I should get - | from | to | route | turns | modes | - | a | d | ab,bc,cd | head,right,left,destination | bike,push,bike | - | d | a | cd,bc,ab | head,right,left,destination | bike,push,bike | - | c | a | bc,ab | head,left,destination | push,bike | - | d | b | cd,bc | head,right,destination | bike,push | - | a | c | ab,bc | head,right,destination | bike,push | - | b | d | bc,cd | head,left,destination | push,bike | + When I route I should get + | from | to | route | turns | modes | + | a | d | ab,bc,cd | head,right,left,destination | 1,1,1 | + | d | a | cd,bc,ab | head,right,left,destination | 1,2,1 | + | c | a | bc,ab | head,left,destination | 2,1 | + | d | b | cd,bc | head,right,destination | 1,2 | + | a | c | ab,bc | head,right,destination | 1,1 | + | b | d | bc,cd | head,left,destination | 1,1 | - @todo - Scenario: Bike - Mode when pushing on pedestrain areas - Given the node map - | a | b | | | - | | c | d | f | + Scenario: Bike - Mode when pushing on pedestrain streets + Given the node map + | a | b | | + | | c | d | - And the ways - | nodes | highway | area | - | ab | primary | | - | bcd | pedestrian | yes | - | df | primary | | + And the ways + | nodes | highway | + | ab | primary | + | bc | pedestrian | + | cd | primary | - When I route I should get - | from | to | route | modes | - | a | f | ab,bcd,df | bike,push,bike | - | f | a | df,bcd,ab | bike,push,bike | - | d | a | bcd,ab | push,bike | - | f | b | df,bcd | bike,push | - | a | d | ab,bcd | bike,push | - | b | f | bcd,df | push,bike | + When I route I should get + | from | to | route | turns | modes | + | a | d | ab,bc,cd | head,right,left,destination | 1,2,1 | + | d | a | cd,bc,ab | head,right,left,destination | 1,2,1 | + | c | a | bc,ab | head,left,destination | 2,1 | + | d | b | cd,bc | head,right,destination | 1,2 | + | a | c | ab,bc | head,right,destination | 1,2 | + | b | d | bc,cd | head,left,destination | 2,1 | + + Scenario: Bike - Mode when pushing on pedestrain areas + Given the node map + | a | b | | | + | | c | d | f | + + And the ways + | nodes | highway | area | + | ab | primary | | + | bcd | pedestrian | yes | + | df | primary | | + + When I route I should get + | from | to | route | modes | + | a | f | ab,bcd,df | 1,2,1 | + | f | a | df,bcd,ab | 1,2,1 | + | d | a | bcd,ab | 2,1 | + | f | b | df,bcd | 1,2 | + | a | d | ab,bcd | 1,2 | + | b | f | bcd,df | 2,1 | + + Scenario: Bike - Mode when pushing on steps + Given the node map + | a | b | | | + | | c | d | f | + + And the ways + | nodes | highway | + | ab | primary | + | bc | steps | + | cd | primary | + + When I route I should get + | from | to | route | turns | modes | + | a | d | ab,bc,cd | head,right,left,destination | 1,2,1 | + | d | a | cd,bc,ab | head,right,left,destination | 1,2,1 | + | c | a | bc,ab | head,left,destination | 2,1 | + | d | b | cd,bc | head,right,destination | 1,2 | + | a | c | ab,bc | head,right,destination | 1,2 | + | b | d | bc,cd | head,left,destination | 2,1 | + + Scenario: Bike - Mode when bicycle=dismount + Given the node map + | a | b | | | + | | c | d | f | + + And the ways + | nodes | highway | bicycle | + | ab | primary | | + | bc | primary | dismount | + | cd | primary | | + + When I route I should get + | from | to | route | turns | modes | + | a | d | ab,bc,cd | head,right,left,destination | 1,2,1 | + | d | a | cd,bc,ab | head,right,left,destination | 1,2,1 | + | c | a | bc,ab | head,left,destination | 2,1 | + | d | b | cd,bc | head,right,destination | 1,2 | + | a | c | ab,bc | head,right,destination | 1,2 | + | b | d | bc,cd | head,left,destination | 2,1 | \ No newline at end of file diff --git a/features/testbot/mode.feature b/features/testbot/mode.feature index bcc087ec4..a761488f5 100644 --- a/features/testbot/mode.feature +++ b/features/testbot/mode.feature @@ -1,26 +1,146 @@ @routing @testbot @mode Feature: Testbot - Mode flag - Background: - Given the profile "testbot" +# testbot modes: +# 1 normal +# 2 route +# 3 river downstream +# 4 river upstream +# 5 steps down +# 6 steps up - @todo - Scenario: Bike - Mode + Background: + Given the profile "testbot" + + Scenario: Testbot - Mode for routes + Given the node map + | a | b | | | | + | | c | d | e | f | + + And the ways + | nodes | highway | route | duration | + | ab | primary | | | + | bc | | ferry | 0:01 | + | cd | primary | | | + | de | primary | | | + | ef | primary | | | + + When I route I should get + | from | to | route | turns | modes | + | a | d | ab,bc,cd | head,right,left,destination | 1,2,1 | + | d | a | cd,bc,ab | head,right,left,destination | 1,2,1 | + | c | a | bc,ab | head,left,destination | 2,1 | + | d | b | cd,bc | head,right,destination | 1,2 | + | a | c | ab,bc | head,right,destination | 1,2 | + | b | d | bc,cd | head,left,destination | 2,1 | + | a | f | ab,bc,cd,de,ef | head,right,left,straight,straight,destination | 1,2,1,1,1 | + + Scenario: Testbot - Modes for each direction + Given the node map + | | | | | | | d | + | | | | | | 2 | | + | | | | | 6 | | 5 | + | a | 0 | b | c | | | | + | | | | | 4 | | 1 | + | | | | | | 3 | | + | | | | | | | e | + + And the ways + | nodes | highway | oneway | + | abc | primary | | + | cd | primary | yes | + | ce | river | | + | de | primary | | + + When I route I should get + | from | to | route | modes | + | 0 | 1 | abc,ce,de | 1,3,1 | + | 1 | 0 | de,ce,abc | 1,4,1 | + | 0 | 2 | abc,cd | 1,1 | + | 2 | 0 | cd,de,ce,abc | 1,1,4,1 | + | 0 | 3 | abc,ce | 1,3 | + | 3 | 0 | ce,abc | 4,1 | + | 4 | 3 | ce | 3 | + | 3 | 4 | ce | 4 | + | 3 | 1 | ce,de | 3,1 | + | 1 | 3 | de,ce | 1,4 | + | a | e | abc,ce | 1,3 | + | e | a | ce,abc | 4,1 | + | a | d | abc,cd | 1,1 | + | d | a | de,ce,abc | 1,4,1 | + + Scenario: Testbot - Modes in each direction (simple) Given the node map - | a | b | | - | | c | d | + | | 0 | 1 | | + | a | | | b | And the ways - | nodes | highway | route | duration | - | ab | primary | | | - | bc | | ferry | 0:01 | - | cd | primary | | | + | nodes | highway | oneway | + | ab | river | | When I route I should get - | from | to | route | turns | modes | - | a | d | ab,bc,cd | head,right,left,destination | bot,ferry,bot | - | d | a | cd,bc,ab | head,right left,destination | bot,ferry,bot | - | c | a | bc,ab | head,left,destination | ferry,bot | - | d | b | cd,bc | head,right,destination | bot,ferry | - | a | c | ab,bc | head,right,destination | bot,ferry | - | b | d | bc,cd | head,left,destination | ferry,bot | + | from | to | route | modes | + | 0 | 1 | ab | 3 | + | 1 | 0 | ab | 4 | + + Scenario: Testbot - Modes in each direction (same speed in both direction) + Given the node map + | | 0 | 1 | | + | a | | | b | + + And the ways + | nodes | highway | + | ab | steps | + + When I route I should get + | from | to | route | modes | time | + | 0 | 1 | ab | 5 | 60s +-1 | + | 1 | 0 | ab | 6 | 60s +-1 | + + Scenario: Testbot - Modes for opposite direction + Given the node map + | | 0 | 1 | | + | a | | | b | + + And the ways + | nodes | highway | oneway | + | ab | steps | -1 | + + When I route I should get + | from | to | route | modes | + | 0 | 1 | | | + | 1 | 0 | ab | 6 | + + @via + Scenario: Testbot - Modes and via point at dead end + Given the node map + | a | b | c | + | | d | | + + And the ways + | nodes | highway | + | abc | primary | + | bd | steps | + + When I route I should get + | waypoints | route | modes | + | a,d,c | abc,bd,bd,abc | 1,5,6,1 | + | c,d,a | abc,bd,bd,abc | 1,5,6,1 | + + @via + Scenario: Testbot - Modes and via point at river + Given the node map + | | | 0 | | | + | a | b | | c | d | + + + And the ways + | nodes | highway | + | ab | primary | + | bc | river | + | cd | primary | + + When I route I should get + | waypoints | route | modes | + | a,0,d | ab,bc,cd | 1,3,1 | + | d,0,a | cd,bc,ab | 1,4,1 | \ No newline at end of file From 6fd615b9cd8d2f46e305915a2de9a4946884c673 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Sat, 9 Aug 2014 15:13:04 +0200 Subject: [PATCH 03/49] first cut at porting travel mode, some tests fail --- Contractor/EdgeBasedGraphFactory.cpp | 11 ++++++++--- Contractor/Prepare.cpp | 8 ++++++-- DataStructures/EdgeBasedNode.h | 14 +++++++++++--- DataStructures/ImportEdge.h | 2 +- DataStructures/NodeBasedGraph.h | 5 +++-- DataStructures/OriginalEdgeData.h | 9 ++++++--- DataStructures/PhantomNodes.h | 15 +++++++++++---- DataStructures/RawRouteData.h | 13 ++++++++++--- DataStructures/SegmentInformation.h | 15 ++++++++++----- DataStructures/StaticRTree.h | 8 ++++++-- Descriptors/DescriptionFactory.cpp | 11 ++++++++--- Descriptors/JSONDescriptor.h | 1 + Extractor/ExtractionWay.h | 20 ++++++++++++++++++++ Extractor/ExtractorCallbacks.cpp | 10 ++++++---- Extractor/InternalExtractorEdge.h | 4 ++-- Extractor/ScriptingEnvironment.cpp | 2 ++ Rakefile | 2 +- RoutingAlgorithms/BasicRoutingInterface.h | 15 +++++++++------ Server/DataStructures/BaseDataFacade.h | 2 ++ Server/DataStructures/InternalDataFacade.h | 8 ++++++++ Server/DataStructures/SharedDataFacade.h | 10 +++++++++- Util/GraphLoader.h | 3 +++ features/bicycle/mode.feature | 2 +- profiles/bicycle.lua | 14 +++++++++++++- profiles/testbot.lua | 12 ++++++++++++ 25 files changed, 169 insertions(+), 47 deletions(-) diff --git a/Contractor/EdgeBasedGraphFactory.cpp b/Contractor/EdgeBasedGraphFactory.cpp index 3adea2a97..e2a48f4a5 100644 --- a/Contractor/EdgeBasedGraphFactory.cpp +++ b/Contractor/EdgeBasedGraphFactory.cpp @@ -181,7 +181,9 @@ EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, const NodeID nod reverse_dist_prefix_sum[i], m_geometry_compressor.GetPositionForID(e1), i, - belongs_to_tiny_cc); + belongs_to_tiny_cc, + forward_data.travel_mode, + reverse_data.travel_mode); current_edge_source_coordinate_id = current_edge_target_coordinate_id; BOOST_ASSERT(m_edge_based_node_list.back().IsCompressed()); @@ -231,7 +233,9 @@ EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, const NodeID nod 0, SPECIAL_EDGEID, 0, - belongs_to_tiny_cc); + belongs_to_tiny_cc, + forward_data.travel_mode, + reverse_data.travel_mode); BOOST_ASSERT(!m_edge_based_node_list.back().IsCompressed()); } } @@ -648,7 +652,8 @@ EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(const std::string &original_edg (edge_is_compressed ? m_geometry_compressor.GetPositionForID(e1) : v), edge_data1.nameID, turn_instruction, - edge_is_compressed); + edge_is_compressed, + edge_data2.travel_mode); ++original_edges_counter; diff --git a/Contractor/Prepare.cpp b/Contractor/Prepare.cpp index d5c0208f6..4fff40fb5 100644 --- a/Contractor/Prepare.cpp +++ b/Contractor/Prepare.cpp @@ -134,8 +134,12 @@ int Prepare::Process(int argc, char *argv[]) #ifdef WIN32 #pragma message("Memory consumption on Windows can be higher due to different bit packing") #else - static_assert(sizeof(ImportEdge) == 20, - "changing ImportEdge type has influence on memory consumption!"); + SimpleLogger().Write() << "sizeof(ImportEdge): " << sizeof(ImportEdge); + SimpleLogger().Write() << "sizeof(NodeBasedEdgeData): " << sizeof(NodeBasedEdgeData); + + //TODO + //static_assert(sizeof(ImportEdge) == 21, + // "changing ImportEdge type has influence on memory consumption!"); #endif NodeID number_of_node_based_nodes = readBinaryOSRMGraphFromStream(input_stream, diff --git a/DataStructures/EdgeBasedNode.h b/DataStructures/EdgeBasedNode.h index 90f8b7c11..ae1ca579e 100644 --- a/DataStructures/EdgeBasedNode.h +++ b/DataStructures/EdgeBasedNode.h @@ -25,7 +25,9 @@ struct EdgeBasedNode reverse_offset(0), packed_geometry_id(SPECIAL_EDGEID), fwd_segment_position( std::numeric_limits::max() ), - is_in_tiny_cc(false) + is_in_tiny_cc(false), + travel_mode(0), + backward_travel_mode(0) { } explicit EdgeBasedNode( @@ -40,7 +42,9 @@ struct EdgeBasedNode int reverse_offset, unsigned packed_geometry_id, unsigned short fwd_segment_position, - bool belongs_to_tiny_component + bool belongs_to_tiny_component, + TravelMode travel_mode, + TravelMode backward_travel_mode ) : forward_edge_based_node_id(forward_edge_based_node_id), reverse_edge_based_node_id(reverse_edge_based_node_id), @@ -53,7 +57,9 @@ struct EdgeBasedNode reverse_offset(reverse_offset), packed_geometry_id(packed_geometry_id), fwd_segment_position(fwd_segment_position), - is_in_tiny_cc(belongs_to_tiny_component) + is_in_tiny_cc(belongs_to_tiny_component), + travel_mode(travel_mode), + backward_travel_mode(backward_travel_mode) { BOOST_ASSERT((forward_edge_based_node_id != SPECIAL_NODEID) || (reverse_edge_based_node_id != SPECIAL_NODEID)); @@ -85,6 +91,8 @@ struct EdgeBasedNode unsigned packed_geometry_id; // if set, then the edge represents a packed geometry unsigned short fwd_segment_position; // segment id in a compressed geometry bool is_in_tiny_cc; + TravelMode travel_mode; + TravelMode backward_travel_mode; }; #endif //EDGE_BASED_NODE_H diff --git a/DataStructures/ImportEdge.h b/DataStructures/ImportEdge.h index d8ddf49ae..761cf386e 100644 --- a/DataStructures/ImportEdge.h +++ b/DataStructures/ImportEdge.h @@ -57,8 +57,8 @@ struct NodeBasedEdge bool roundabout : 1; bool in_tiny_cc : 1; bool access_restricted : 1; - TravelMode travel_mode : 1; bool is_split : 1; + TravelMode travel_mode; NodeBasedEdge() = delete; }; diff --git a/DataStructures/NodeBasedGraph.h b/DataStructures/NodeBasedGraph.h index 464c31605..77c5251e5 100644 --- a/DataStructures/NodeBasedGraph.h +++ b/DataStructures/NodeBasedGraph.h @@ -29,7 +29,7 @@ struct NodeBasedEdgeData bool backward : 1; bool roundabout : 1; bool ignore_in_grid : 1; - TravelMode travel_mode : 1; + TravelMode travel_mode; void SwapDirectionFlags() { @@ -59,7 +59,8 @@ using SimpleNodeBasedDynamicGraph = DynamicGraph; inline std::shared_ptr NodeBasedDynamicGraphFromImportEdges(int number_of_nodes, std::vector &input_edge_list) { - static_assert(sizeof(NodeBasedEdgeData) == 16, "changing node based edge data size changes memory consumption"); + //TODO + //static_assert(sizeof(NodeBasedEdgeData) == 16, "changing node based edge data size changes memory consumption"); DeallocatingVector edges_list; NodeBasedDynamicGraph::InputEdge edge; diff --git a/DataStructures/OriginalEdgeData.h b/DataStructures/OriginalEdgeData.h index f75aeda5c..38a6b81a1 100644 --- a/DataStructures/OriginalEdgeData.h +++ b/DataStructures/OriginalEdgeData.h @@ -38,16 +38,18 @@ struct OriginalEdgeData explicit OriginalEdgeData(NodeID via_node, unsigned name_id, TurnInstruction turn_instruction, - bool compressed_geometry) + bool compressed_geometry, + TravelMode travel_mode) : via_node(via_node), name_id(name_id), turn_instruction(turn_instruction), - compressed_geometry(compressed_geometry) + compressed_geometry(compressed_geometry), travel_mode(travel_mode) { } OriginalEdgeData() : via_node(std::numeric_limits::max()), name_id(std::numeric_limits::max()), - turn_instruction(TurnInstruction::NoTurn), compressed_geometry(false) + turn_instruction(TurnInstruction::NoTurn), compressed_geometry(false), + travel_mode(0) { } @@ -55,6 +57,7 @@ struct OriginalEdgeData unsigned name_id; TurnInstruction turn_instruction; bool compressed_geometry; + TravelMode travel_mode; }; #endif // ORIGINAL_EDGE_DATA_H diff --git a/DataStructures/PhantomNodes.h b/DataStructures/PhantomNodes.h index c46b14573..66e97d61a 100644 --- a/DataStructures/PhantomNodes.h +++ b/DataStructures/PhantomNodes.h @@ -39,7 +39,8 @@ struct PhantomNode PhantomNode(NodeID forward_node_id, NodeID reverse_node_id, unsigned name_id, int forward_weight, int reverse_weight, int forward_offset, int reverse_offset, unsigned packed_geometry_id, FixedPointCoordinate &location, - unsigned short fwd_segment_position) : + unsigned short fwd_segment_position, + TravelMode travel_mode, TravelMode backward_travel_mode) : forward_node_id(forward_node_id), reverse_node_id(reverse_node_id), name_id(name_id), @@ -49,7 +50,9 @@ struct PhantomNode reverse_offset(reverse_offset), packed_geometry_id(packed_geometry_id), location(location), - fwd_segment_position(fwd_segment_position) + fwd_segment_position(fwd_segment_position), + travel_mode(travel_mode), + backward_travel_mode(backward_travel_mode) { } PhantomNode() : @@ -61,7 +64,9 @@ struct PhantomNode forward_offset(0), reverse_offset(0), packed_geometry_id(SPECIAL_EDGEID), - fwd_segment_position(0) + fwd_segment_position(0), + travel_mode(0), + backward_travel_mode(0) { } NodeID forward_node_id; @@ -74,7 +79,9 @@ struct PhantomNode unsigned packed_geometry_id; FixedPointCoordinate location; unsigned short fwd_segment_position; - + TravelMode travel_mode; + TravelMode backward_travel_mode; + int GetForwardWeightPlusOffset() const { if (SPECIAL_NODEID == forward_node_id) diff --git a/DataStructures/RawRouteData.h b/DataStructures/RawRouteData.h index f799841b2..3a7d1e871 100644 --- a/DataStructures/RawRouteData.h +++ b/DataStructures/RawRouteData.h @@ -41,18 +41,25 @@ struct PathData PathData() : node(SPECIAL_NODEID), name_id(INVALID_EDGE_WEIGHT), segment_duration(INVALID_EDGE_WEIGHT), - turn_instruction(TurnInstruction::NoTurn) + turn_instruction(TurnInstruction::NoTurn), + travel_mode(0) { } - PathData(NodeID node, unsigned name_id, TurnInstruction turn_instruction, EdgeWeight segment_duration) - : node(node), name_id(name_id), segment_duration(segment_duration), turn_instruction(turn_instruction) + PathData(NodeID node, + unsigned name_id, + TurnInstruction turn_instruction, + EdgeWeight segment_duration, + TravelMode travel_mode) + : node(node), name_id(name_id), segment_duration(segment_duration), turn_instruction(turn_instruction), + travel_mode(travel_mode) { } NodeID node; unsigned name_id; EdgeWeight segment_duration; TurnInstruction turn_instruction; + TravelMode travel_mode; }; struct RawRouteData diff --git a/DataStructures/SegmentInformation.h b/DataStructures/SegmentInformation.h index f14580449..df3bfbaed 100644 --- a/DataStructures/SegmentInformation.h +++ b/DataStructures/SegmentInformation.h @@ -45,16 +45,19 @@ struct SegmentInformation TurnInstruction turn_instruction; bool necessary:1; bool is_via_location:1; - + TravelMode travel_mode; + explicit SegmentInformation(const FixedPointCoordinate &location, const NodeID name_id, const EdgeWeight duration, const float length, const TurnInstruction turn_instruction, const bool necessary, - const bool is_via_location) + const bool is_via_location, + const TravelMode travel_mode) : location(location), name_id(name_id), duration(duration), length(length), bearing(0), - turn_instruction(turn_instruction), necessary(necessary), is_via_location(is_via_location) + turn_instruction(turn_instruction), necessary(necessary), is_via_location(is_via_location), + travel_mode(travel_mode) { } @@ -62,9 +65,11 @@ struct SegmentInformation const NodeID name_id, const EdgeWeight duration, const float length, - const TurnInstruction turn_instruction) + const TurnInstruction turn_instruction, + const TravelMode travel_mode) : location(location), name_id(name_id), duration(duration), length(length), bearing(0), - turn_instruction(turn_instruction), necessary(turn_instruction != TurnInstruction::NoTurn), is_via_location(false) + turn_instruction(turn_instruction), necessary(turn_instruction != TurnInstruction::NoTurn), is_via_location(false), + travel_mode(travel_mode) { } }; diff --git a/DataStructures/StaticRTree.h b/DataStructures/StaticRTree.h index b17f61428..0c42ecfeb 100644 --- a/DataStructures/StaticRTree.h +++ b/DataStructures/StaticRTree.h @@ -801,7 +801,9 @@ class StaticRTree current_segment.reverse_offset, current_segment.packed_geometry_id, foot_point_coordinate_on_segment, - current_segment.fwd_segment_position); + current_segment.fwd_segment_position, + current_segment.travel_mode, + current_segment.backward_travel_mode); // Hack to fix rounding errors and wandering via nodes. FixUpRoundingIssue(input_coordinate, result_phantom_node_vector.back()); @@ -1077,7 +1079,9 @@ class StaticRTree current_edge.reverse_offset, current_edge.packed_geometry_id, nearest, - current_edge.fwd_segment_position}; + current_edge.fwd_segment_position, + current_edge.travel_mode, + current_edge.backward_travel_mode}; nearest_edge = current_edge; } } diff --git a/Descriptors/DescriptionFactory.cpp b/Descriptors/DescriptionFactory.cpp index 38f2f32fe..4e3412229 100644 --- a/Descriptors/DescriptionFactory.cpp +++ b/Descriptors/DescriptionFactory.cpp @@ -45,8 +45,10 @@ void DescriptionFactory::SetStartSegment(const PhantomNode &source, const bool t start_phantom = source; const EdgeWeight segment_duration = (traversed_in_reverse ? source.reverse_weight : source.forward_weight); + const TravelMode travel_mode = + (traversed_in_reverse ? source.backward_travel_mode : source.travel_mode); AppendSegment(source.location, - PathData(0, source.name_id, TurnInstruction::HeadOn, segment_duration)); + PathData(0, source.name_id, TurnInstruction::HeadOn, segment_duration, travel_mode)); BOOST_ASSERT(path_description.back().duration == segment_duration); } @@ -57,6 +59,7 @@ void DescriptionFactory::SetEndSegment(const PhantomNode &target, target_phantom = target; const EdgeWeight segment_duration = (traversed_in_reverse ? target.reverse_weight : target.forward_weight); +<<<<<<< HEAD path_description.emplace_back(target.location, target.name_id, segment_duration, @@ -64,7 +67,8 @@ void DescriptionFactory::SetEndSegment(const PhantomNode &target, is_via_location ? TurnInstruction::ReachViaLocation : TurnInstruction::NoTurn, true, - true); + true, + travel_mode); BOOST_ASSERT(path_description.back().duration == segment_duration); } @@ -81,7 +85,8 @@ void DescriptionFactory::AppendSegment(const FixedPointCoordinate &coordinate, path_point.name_id, path_point.segment_duration, 0.f, - path_point.turn_instruction); + path_point.turn_instruction, + path_point.travel_mode); } JSON::Value DescriptionFactory::AppendEncodedPolylineString(const bool return_encoded) diff --git a/Descriptors/JSONDescriptor.h b/Descriptors/JSONDescriptor.h index c5e1becba..33728b740 100644 --- a/Descriptors/JSONDescriptor.h +++ b/Descriptors/JSONDescriptor.h @@ -356,6 +356,7 @@ template class JSONDescriptor : public BaseDescriptor(round(bearing_value))); + json_instruction_row.values.push_back(segment.travel_mode); route_segments_list.emplace_back( segment.name_id, diff --git a/Extractor/ExtractionWay.h b/Extractor/ExtractionWay.h index 6c3c93d63..4a14b3534 100644 --- a/Extractor/ExtractionWay.h +++ b/Extractor/ExtractionWay.h @@ -53,6 +53,8 @@ struct ExtractionWay roundabout = false; isAccessRestricted = false; ignoreInGrid = false; + travel_mode = 0; + backward_travel_mode = 0; } enum Directions @@ -60,6 +62,22 @@ struct ExtractionWay oneway, bidirectional, opposite }; + + inline bool IsBidirectional() { return travel_mode!=0 && backward_travel_mode!=0; } + inline bool IsOneway() { return travel_mode!=0 && backward_travel_mode==0; } + inline bool IsOpposite() { return travel_mode==0 && backward_travel_mode!=0; } + inline bool HasDiffDirections() { return (travel_mode != backward_travel_mode) || (speed != backward_speed); } + inline Directions Direction() + { + if( IsOneway() ) { + return ExtractionWay::oneway; + } + if( IsOpposite() ) { + return ExtractionWay::opposite; + } + return ExtractionWay::bidirectional; + } + unsigned id; unsigned nameID; double speed; @@ -74,6 +92,8 @@ struct ExtractionWay bool ignoreInGrid; std::vector path; HashTable keyVals; + TravelMode travel_mode; + TravelMode backward_travel_mode; }; #endif // EXTRACTION_WAY_H diff --git a/Extractor/ExtractorCallbacks.cpp b/Extractor/ExtractorCallbacks.cpp index 5e27817c6..48b8b7835 100644 --- a/Extractor/ExtractorCallbacks.cpp +++ b/Extractor/ExtractorCallbacks.cpp @@ -112,8 +112,10 @@ void ExtractorCallbacks::ProcessWay(ExtractionWay &parsed_way) parsed_way.direction = ExtractionWay::oneway; } - const bool split_edge = - (parsed_way.backward_speed > 0) && (parsed_way.speed != parsed_way.backward_speed); + bool split_edge = parsed_way.IsBidirectional() && parsed_way.HasDiffDirections(); + + //const bool split_edge = + // (parsed_way.backward_speed > 0) && (parsed_way.speed != parsed_way.backward_speed); for (unsigned n = 0; n < (parsed_way.path.size() - 1); ++n) { @@ -128,7 +130,7 @@ void ExtractorCallbacks::ProcessWay(ExtractionWay &parsed_way) parsed_way.ignoreInGrid, (0 < parsed_way.duration), parsed_way.isAccessRestricted, - false, + parsed_way.travel_mode, split_edge)); external_memory.used_node_id_list.push_back(parsed_way.path[n]); } @@ -158,7 +160,7 @@ void ExtractorCallbacks::ProcessWay(ExtractionWay &parsed_way) parsed_way.ignoreInGrid, (0 < parsed_way.duration), parsed_way.isAccessRestricted, - (ExtractionWay::oneway == parsed_way.direction), + parsed_way.backward_travel_mode, split_edge)); } external_memory.way_start_end_id_list.push_back( diff --git a/Extractor/InternalExtractorEdge.h b/Extractor/InternalExtractorEdge.h index 0e3e7dfd7..492367f28 100644 --- a/Extractor/InternalExtractorEdge.h +++ b/Extractor/InternalExtractorEdge.h @@ -65,12 +65,12 @@ struct InternalExtractorEdge // necessary static util functions for stxxl's sorting static InternalExtractorEdge min_value() { - return InternalExtractorEdge(0, 0, 0, 0, 0, 0, false, false, false, false, false, false); + return InternalExtractorEdge(0, 0, 0, 0, 0, 0, false, false, false, false, 0, false); } static InternalExtractorEdge max_value() { return InternalExtractorEdge( - SPECIAL_NODEID, SPECIAL_NODEID, 0, 0, 0, 0, false, false, false, false, false, false); + SPECIAL_NODEID, SPECIAL_NODEID, 0, 0, 0, 0, false, false, false, false, 0, false); } NodeID start; diff --git a/Extractor/ScriptingEnvironment.cpp b/Extractor/ScriptingEnvironment.cpp index 660c35ca7..084d22ffd 100644 --- a/Extractor/ScriptingEnvironment.cpp +++ b/Extractor/ScriptingEnvironment.cpp @@ -86,6 +86,8 @@ void ScriptingEnvironment::initLuaState(lua_State* lua_state) .def_readwrite("ignore_in_grid", &ExtractionWay::ignoreInGrid) .def_readwrite("tags", &ExtractionWay::keyVals) .def_readwrite("direction", &ExtractionWay::direction) + .def_readwrite("mode", &ExtractionWay::travel_mode) + .def_readwrite("backward_mode", &ExtractionWay::backward_travel_mode) .enum_("constants")[ luabind::value("notSure", 0), luabind::value("oneway", 1), diff --git a/Rakefile b/Rakefile index 1c2ce9ded..21e95cfb2 100644 --- a/Rakefile +++ b/Rakefile @@ -6,7 +6,7 @@ require 'sys/proctable' BUILD_FOLDER = 'build' DATA_FOLDER = 'sandbox' -PROFILE = 'examples/postgis' +PROFILE = 'bicycle' OSRM_PORT = 5000 PROFILES_FOLDER = '../profiles' diff --git a/RoutingAlgorithms/BasicRoutingInterface.h b/RoutingAlgorithms/BasicRoutingInterface.h index 807a8610f..8a310f975 100644 --- a/RoutingAlgorithms/BasicRoutingInterface.h +++ b/RoutingAlgorithms/BasicRoutingInterface.h @@ -227,14 +227,16 @@ template class BasicRoutingInterface BOOST_ASSERT_MSG(!ed.shortcut, "original edge flagged as shortcut"); unsigned name_index = facade->GetNameIndexFromEdgeID(ed.id); const TurnInstruction turn_instruction = facade->GetTurnInstructionForEdgeID(ed.id); - + const TravelMode travel_mode = facade->GetTravelModeForEdgeID(ed.id); + if (!facade->EdgeIsCompressed(ed.id)) { BOOST_ASSERT(!facade->EdgeIsCompressed(ed.id)); unpacked_path.emplace_back(facade->GetGeometryIndexForEdgeID(ed.id), name_index, turn_instruction, - ed.distance); + ed.distance, + travel_mode); } else { @@ -255,7 +257,7 @@ template class BasicRoutingInterface BOOST_ASSERT(start_index <= end_index); for (std::size_t i = start_index; i < end_index; ++i) { - unpacked_path.emplace_back(id_vector[i], name_index, TurnInstruction::NoTurn, 0); + unpacked_path.emplace_back(id_vector[i], name_index, TurnInstruction::NoTurn, 0, 0); } unpacked_path.back().turn_instruction = turn_instruction; unpacked_path.back().segment_duration = ed.distance; @@ -299,9 +301,10 @@ template class BasicRoutingInterface { BOOST_ASSERT(i < id_vector.size()); unpacked_path.emplace_back(PathData{id_vector[i], - phantom_node_pair.target_phantom.name_id, - TurnInstruction::NoTurn, - 0}); + phantom_node_pair.target_phantom.name_id, + TurnInstruction::NoTurn, + 0, + 0}); } } diff --git a/Server/DataStructures/BaseDataFacade.h b/Server/DataStructures/BaseDataFacade.h index 4f2ba5446..33695cbc8 100644 --- a/Server/DataStructures/BaseDataFacade.h +++ b/Server/DataStructures/BaseDataFacade.h @@ -92,6 +92,8 @@ template class BaseDataFacade virtual TurnInstruction GetTurnInstructionForEdgeID(const unsigned id) const = 0; + virtual TravelMode GetTravelModeForEdgeID(const unsigned id) const = 0; + virtual bool LocateClosestEndPointForCoordinate(const FixedPointCoordinate &input_coordinate, FixedPointCoordinate &result, const unsigned zoom_level = 18) = 0; diff --git a/Server/DataStructures/InternalDataFacade.h b/Server/DataStructures/InternalDataFacade.h index 3abab2aba..b2f36e1da 100644 --- a/Server/DataStructures/InternalDataFacade.h +++ b/Server/DataStructures/InternalDataFacade.h @@ -66,6 +66,7 @@ template class InternalDataFacade : public BaseDataFacade::vector m_via_node_list; ShM::vector m_name_ID_list; ShM::vector m_turn_instruction_list; + ShM::vector m_travel_mode_list; ShM::vector m_names_char_list; ShM::vector m_egde_is_compressed; ShM::vector m_geometry_indices; @@ -145,6 +146,7 @@ template class InternalDataFacade : public BaseDataFacade class InternalDataFacade : public BaseDataFacade class InternalDataFacade : public BaseDataFacade class SharedDataFacade : public BaseDataFacade::vector m_via_node_list; ShM::vector m_name_ID_list; ShM::vector m_turn_instruction_list; + ShM::vector m_travel_mode_list; ShM::vector m_names_char_list; ShM::vector m_name_begin_indices; ShM::vector m_egde_is_compressed; @@ -150,7 +151,9 @@ template class SharedDataFacade : public BaseDataFacadenum_entries[SharedDataLayout::TURN_INSTRUCTION]); m_turn_instruction_list.swap(turn_instruction_list); - + + //TODO m_travel_mode_list + unsigned *name_id_list_ptr = data_layout->GetBlockPtr(shared_memory, SharedDataLayout::NAME_ID_LIST); typename ShM::vector name_id_list( @@ -346,6 +349,11 @@ template class SharedDataFacade : public BaseDataFacade 0, "loaded null length edge"); BOOST_ASSERT_MSG(weight > 0, "loaded null weight"); BOOST_ASSERT_MSG(0 <= dir && dir <= 2, "loaded bogus direction"); diff --git a/features/bicycle/mode.feature b/features/bicycle/mode.feature index 30be18418..9c3305904 100644 --- a/features/bicycle/mode.feature +++ b/features/bicycle/mode.feature @@ -1,4 +1,4 @@ -routing @bicycle @mode +@routing @bicycle @mode Feature: Bike - Mode flag # bicycle modes: diff --git a/profiles/bicycle.lua b/profiles/bicycle.lua index 3efa3d025..7c20ed369 100644 --- a/profiles/bicycle.lua +++ b/profiles/bicycle.lua @@ -94,7 +94,13 @@ u_turn_penalty = 20 use_turn_restrictions = false turn_penalty = 60 turn_bias = 1.4 --- End of globals + + +--modes +mode_normal = 1 +mode_pushing = 2 +mode_ferry = 3 +mode_train = 4 local function parse_maxspeed(source) @@ -229,6 +235,7 @@ function way_function (way) -- public_transport platforms (new tagging platform) way.speed = platform_speeds[public_transport] elseif railway and railway_speeds[railway] then + way.mode = mode_train -- railways if access and access_tag_whitelist[access] then way.speed = railway_speeds[railway] @@ -251,11 +258,14 @@ function way_function (way) if pedestrian_speeds[highway] then -- pedestrian-only ways and areas way.speed = pedestrian_speeds[highway] + way.mode = mode_pushing elseif man_made and man_made_speeds[man_made] then -- man made structures way.speed = man_made_speeds[man_made] + way.mode = mode_pushing elseif foot == 'yes' then way.speed = walking_speed + way.mode = mode_pushing end end end @@ -308,9 +318,11 @@ function way_function (way) if junction ~= "roundabout" then if way.direction == Way.oneway then way.backward_speed = walking_speed + way.mode = mode_pushing elseif way.direction == Way.opposite then way.backward_speed = walking_speed way.speed = way.speed + way.mode = mode_pushing end end end diff --git a/profiles/testbot.lua b/profiles/testbot.lua index 66d659974..ffba89c22 100644 --- a/profiles/testbot.lua +++ b/profiles/testbot.lua @@ -6,6 +6,14 @@ -- Secondary road: 18km/h = 18000m/3600s = 100m/20s -- Tertiary road: 12km/h = 12000m/3600s = 100m/30s +-- modes: +-- 1: normal +-- 2: route +-- 3: river downstream +-- 4: river upstream +-- 5: steps down +-- 6: steps up + speed_profile = { ["primary"] = 36, ["secondary"] = 18, @@ -61,12 +69,16 @@ function way_function (way) if route ~= nil and durationIsValid(duration) then way.duration = math.max( 1, parseDuration(duration) ) + way.mode = 2 + way.backward_mode = 2 else local speed_forw = speed_profile[highway] or speed_profile['default'] local speed_back = speed_forw if highway == "river" then local temp_speed = speed_forw; + way.mode = 3 + way.backward_mode = 4 speed_forw = temp_speed*1.5 speed_back = temp_speed/1.5 end From 6d6d299ea4800252e3ab7750b557a4978853e552 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Mon, 11 Aug 2014 08:30:04 +0200 Subject: [PATCH 04/49] most tests passing --- Contractor/EdgeBasedGraphFactory.cpp | 9 --------- Extractor/ExtractionWay.h | 2 +- RoutingAlgorithms/BasicRoutingInterface.h | 2 +- RoutingAlgorithms/ShortestPathRouting.h | 7 +++++++ Server/DataStructures/InternalDataFacade.h | 3 ++- features/testbot/mode.feature | 17 ++++++++++++++++- profiles/testbot.lua | 6 +++++- 7 files changed, 32 insertions(+), 14 deletions(-) diff --git a/Contractor/EdgeBasedGraphFactory.cpp b/Contractor/EdgeBasedGraphFactory.cpp index e2a48f4a5..e54d10a52 100644 --- a/Contractor/EdgeBasedGraphFactory.cpp +++ b/Contractor/EdgeBasedGraphFactory.cpp @@ -723,15 +723,6 @@ TurnInstruction EdgeBasedGraphFactory::AnalyzeTurn(const NodeID node_u, const EdgeData &data1 = m_node_based_graph->GetEdgeData(edge1); const EdgeData &data2 = m_node_based_graph->GetEdgeData(edge2); - if (!data1.travel_mode && data2.travel_mode) - { - return TurnInstruction::EnterAgainstAllowedDirection; - } - if (data1.travel_mode && !data2.travel_mode) - { - return TurnInstruction::LeaveAgainstAllowedDirection; - } - // roundabouts need to be handled explicitely if (data1.roundabout && data2.roundabout) { diff --git a/Extractor/ExtractionWay.h b/Extractor/ExtractionWay.h index 4a14b3534..b5698849f 100644 --- a/Extractor/ExtractionWay.h +++ b/Extractor/ExtractionWay.h @@ -53,7 +53,7 @@ struct ExtractionWay roundabout = false; isAccessRestricted = false; ignoreInGrid = false; - travel_mode = 0; + travel_mode = 1; backward_travel_mode = 0; } diff --git a/RoutingAlgorithms/BasicRoutingInterface.h b/RoutingAlgorithms/BasicRoutingInterface.h index 8a310f975..e38d176b2 100644 --- a/RoutingAlgorithms/BasicRoutingInterface.h +++ b/RoutingAlgorithms/BasicRoutingInterface.h @@ -228,7 +228,7 @@ template class BasicRoutingInterface unsigned name_index = facade->GetNameIndexFromEdgeID(ed.id); const TurnInstruction turn_instruction = facade->GetTurnInstructionForEdgeID(ed.id); const TravelMode travel_mode = facade->GetTravelModeForEdgeID(ed.id); - + if (!facade->EdgeIsCompressed(ed.id)) { BOOST_ASSERT(!facade->EdgeIsCompressed(ed.id)); diff --git a/RoutingAlgorithms/ShortestPathRouting.h b/RoutingAlgorithms/ShortestPathRouting.h index deac8bb30..646a41c62 100644 --- a/RoutingAlgorithms/ShortestPathRouting.h +++ b/RoutingAlgorithms/ShortestPathRouting.h @@ -309,6 +309,13 @@ template class ShortestPathRouting : public BasicRoutingInte } raw_route_data.unpacked_path_segments.resize(packed_legs1.size()); + //TODO - needed? + // set mode of first instruction + // if the best route started from the opposite edge, use backward mode rather than forward + //if( packed_legs1.front() == phantom_nodes_vector[0].source_phantom.reverse_node_id ) { + // phantom_nodes_vector[0].source_phantom.travel_mode = phantom_nodes_vector[0].source_phantom.backward_travel_mode; + //} + for (const std::size_t index : osrm::irange(0, packed_legs1.size())) { BOOST_ASSERT(!phantom_nodes_vector.empty()); diff --git a/Server/DataStructures/InternalDataFacade.h b/Server/DataStructures/InternalDataFacade.h index b2f36e1da..33a8caa5b 100644 --- a/Server/DataStructures/InternalDataFacade.h +++ b/Server/DataStructures/InternalDataFacade.h @@ -155,6 +155,7 @@ template class InternalDataFacade : public BaseDataFacade class InternalDataFacade : public BaseDataFacade 0 then speed_forw = maxspeed_forward From dae9c9a7ed9699580bab9138b6d7f79571aea1c8 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Mon, 11 Aug 2014 14:07:00 +0200 Subject: [PATCH 05/49] use 4 bits for travel mode --- DataStructures/EdgeBasedNode.h | 6 +++--- DataStructures/ImportEdge.h | 2 +- DataStructures/NodeBasedGraph.h | 2 +- DataStructures/PhantomNodes.h | 4 ++-- DataStructures/RawRouteData.h | 2 +- DataStructures/SegmentInformation.h | 2 +- Extractor/ExtractionContainers.cpp | 6 +++++- Extractor/ExtractionWay.h | 10 ++++++++-- Extractor/InternalExtractorEdge.h | 2 +- Extractor/ScriptingEnvironment.cpp | 4 ++-- Server/DataStructures/InternalDataFacade.h | 1 - Util/GraphLoader.h | 3 --- 12 files changed, 25 insertions(+), 19 deletions(-) diff --git a/DataStructures/EdgeBasedNode.h b/DataStructures/EdgeBasedNode.h index ae1ca579e..f433ddbca 100644 --- a/DataStructures/EdgeBasedNode.h +++ b/DataStructures/EdgeBasedNode.h @@ -43,7 +43,7 @@ struct EdgeBasedNode unsigned packed_geometry_id, unsigned short fwd_segment_position, bool belongs_to_tiny_component, - TravelMode travel_mode, + TravelMode travel_mode , TravelMode backward_travel_mode ) : forward_edge_based_node_id(forward_edge_based_node_id), @@ -91,8 +91,8 @@ struct EdgeBasedNode unsigned packed_geometry_id; // if set, then the edge represents a packed geometry unsigned short fwd_segment_position; // segment id in a compressed geometry bool is_in_tiny_cc; - TravelMode travel_mode; - TravelMode backward_travel_mode; + TravelMode travel_mode : 4; + TravelMode backward_travel_mode : 4; }; #endif //EDGE_BASED_NODE_H diff --git a/DataStructures/ImportEdge.h b/DataStructures/ImportEdge.h index 761cf386e..20c277318 100644 --- a/DataStructures/ImportEdge.h +++ b/DataStructures/ImportEdge.h @@ -58,7 +58,7 @@ struct NodeBasedEdge bool in_tiny_cc : 1; bool access_restricted : 1; bool is_split : 1; - TravelMode travel_mode; + TravelMode travel_mode : 4; NodeBasedEdge() = delete; }; diff --git a/DataStructures/NodeBasedGraph.h b/DataStructures/NodeBasedGraph.h index 77c5251e5..376c8ffae 100644 --- a/DataStructures/NodeBasedGraph.h +++ b/DataStructures/NodeBasedGraph.h @@ -29,7 +29,7 @@ struct NodeBasedEdgeData bool backward : 1; bool roundabout : 1; bool ignore_in_grid : 1; - TravelMode travel_mode; + TravelMode travel_mode : 4; void SwapDirectionFlags() { diff --git a/DataStructures/PhantomNodes.h b/DataStructures/PhantomNodes.h index 66e97d61a..c1598df9b 100644 --- a/DataStructures/PhantomNodes.h +++ b/DataStructures/PhantomNodes.h @@ -79,8 +79,8 @@ struct PhantomNode unsigned packed_geometry_id; FixedPointCoordinate location; unsigned short fwd_segment_position; - TravelMode travel_mode; - TravelMode backward_travel_mode; + TravelMode travel_mode : 4; + TravelMode backward_travel_mode : 4; int GetForwardWeightPlusOffset() const { diff --git a/DataStructures/RawRouteData.h b/DataStructures/RawRouteData.h index 3a7d1e871..b48b62f3c 100644 --- a/DataStructures/RawRouteData.h +++ b/DataStructures/RawRouteData.h @@ -59,7 +59,7 @@ struct PathData unsigned name_id; EdgeWeight segment_duration; TurnInstruction turn_instruction; - TravelMode travel_mode; + TravelMode travel_mode : 4; }; struct RawRouteData diff --git a/DataStructures/SegmentInformation.h b/DataStructures/SegmentInformation.h index df3bfbaed..fe1704a92 100644 --- a/DataStructures/SegmentInformation.h +++ b/DataStructures/SegmentInformation.h @@ -45,7 +45,7 @@ struct SegmentInformation TurnInstruction turn_instruction; bool necessary:1; bool is_via_location:1; - TravelMode travel_mode; + TravelMode travel_mode : 4; explicit SegmentInformation(const FixedPointCoordinate &location, const NodeID name_id, diff --git a/Extractor/ExtractionContainers.cpp b/Extractor/ExtractionContainers.cpp index 23ef88af6..9a88a56ac 100644 --- a/Extractor/ExtractionContainers.cpp +++ b/Extractor/ExtractionContainers.cpp @@ -376,7 +376,11 @@ void ExtractionContainers::PrepareData(const std::string &output_file_name, file_out_stream.write((char *)&edge_iterator->is_roundabout, sizeof(bool)); file_out_stream.write((char *)&edge_iterator->is_in_tiny_cc, sizeof(bool)); file_out_stream.write((char *)&edge_iterator->is_access_restricted, sizeof(bool)); - file_out_stream.write((char *)&edge_iterator->travel_mode, sizeof(TravelMode)); + + // cannot take adress of bit field, so use local + const TravelMode travel_mode = edge_iterator->travel_mode; + file_out_stream.write((char *)&travel_mode, sizeof(TravelMode)); + file_out_stream.write((char *)&edge_iterator->is_split, sizeof(bool)); ++number_of_used_edges; } diff --git a/Extractor/ExtractionWay.h b/Extractor/ExtractionWay.h index b5698849f..158aef6d4 100644 --- a/Extractor/ExtractionWay.h +++ b/Extractor/ExtractionWay.h @@ -63,6 +63,7 @@ struct ExtractionWay bidirectional, opposite }; + inline bool HasDuration() { return duration>0; } inline bool IsBidirectional() { return travel_mode!=0 && backward_travel_mode!=0; } inline bool IsOneway() { return travel_mode!=0 && backward_travel_mode==0; } inline bool IsOpposite() { return travel_mode==0 && backward_travel_mode!=0; } @@ -78,6 +79,11 @@ struct ExtractionWay return ExtractionWay::bidirectional; } + inline void set_mode(const TravelMode m) { travel_mode = m; } + inline const TravelMode get_mode() { return travel_mode; } + inline void set_backward_mode(const TravelMode m) { backward_travel_mode = m; } + inline const TravelMode get_backward_mode() { return backward_travel_mode; } + unsigned id; unsigned nameID; double speed; @@ -92,8 +98,8 @@ struct ExtractionWay bool ignoreInGrid; std::vector path; HashTable keyVals; - TravelMode travel_mode; - TravelMode backward_travel_mode; + TravelMode travel_mode : 4; + TravelMode backward_travel_mode : 4; }; #endif // EXTRACTION_WAY_H diff --git a/Extractor/InternalExtractorEdge.h b/Extractor/InternalExtractorEdge.h index 492367f28..104d23c05 100644 --- a/Extractor/InternalExtractorEdge.h +++ b/Extractor/InternalExtractorEdge.h @@ -83,7 +83,7 @@ struct InternalExtractorEdge bool is_in_tiny_cc; bool is_duration_set; bool is_access_restricted; - TravelMode travel_mode; + TravelMode travel_mode : 4; bool is_split; FixedPointCoordinate source_coordinate; diff --git a/Extractor/ScriptingEnvironment.cpp b/Extractor/ScriptingEnvironment.cpp index 084d22ffd..d56b7b45f 100644 --- a/Extractor/ScriptingEnvironment.cpp +++ b/Extractor/ScriptingEnvironment.cpp @@ -86,8 +86,8 @@ void ScriptingEnvironment::initLuaState(lua_State* lua_state) .def_readwrite("ignore_in_grid", &ExtractionWay::ignoreInGrid) .def_readwrite("tags", &ExtractionWay::keyVals) .def_readwrite("direction", &ExtractionWay::direction) - .def_readwrite("mode", &ExtractionWay::travel_mode) - .def_readwrite("backward_mode", &ExtractionWay::backward_travel_mode) + .property("mode", &ExtractionWay::get_mode, &ExtractionWay::set_mode) + .property("backward_mode", &ExtractionWay::get_backward_mode, &ExtractionWay::set_backward_mode) .enum_("constants")[ luabind::value("notSure", 0), luabind::value("oneway", 1), diff --git a/Server/DataStructures/InternalDataFacade.h b/Server/DataStructures/InternalDataFacade.h index 33a8caa5b..5f0a2517b 100644 --- a/Server/DataStructures/InternalDataFacade.h +++ b/Server/DataStructures/InternalDataFacade.h @@ -155,7 +155,6 @@ template class InternalDataFacade : public BaseDataFacade 0, "loaded null length edge"); BOOST_ASSERT_MSG(weight > 0, "loaded null weight"); BOOST_ASSERT_MSG(0 <= dir && dir <= 2, "loaded bogus direction"); From 181dbe84933261923a3b6e10bbe55062b4bcfd8a Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Mon, 11 Aug 2014 14:08:00 +0200 Subject: [PATCH 06/49] improve tests for travel mode --- features/testbot/mode.feature | 39 +++++++++++------------- features/testbot/oneway.feature | 54 +++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 21 deletions(-) diff --git a/features/testbot/mode.feature b/features/testbot/mode.feature index b7076b966..d2e81614c 100644 --- a/features/testbot/mode.feature +++ b/features/testbot/mode.feature @@ -97,10 +97,22 @@ Feature: Testbot - Mode flag | 0 | 1 | ab | 5 | 60s +-1 | | 1 | 0 | ab | 6 | 60s +-1 | - Scenario: Testbot - Modes for opposite direction + Scenario: Testbot - Modes for oneway Given the node map - | | 0 | 1 | | - | a | | | b | + | a | b | + + And the ways + | nodes | highway | oneway | + | ab | steps | yes | + + When I route I should get + | from | to | route | modes | + | a | b | ab | 5 | + | b | a | | | + + Scenario: Testbot - Modes for reverse oneway + Given the node map + | a | b | And the ways | nodes | highway | oneway | @@ -108,8 +120,8 @@ Feature: Testbot - Mode flag When I route I should get | from | to | route | modes | - | 0 | 1 | | | - | 1 | 0 | ab | 6 | + | b | a | ab | 6 | + | a | b | | | @via Scenario: Testbot - Modes and via point at dead end @@ -143,19 +155,4 @@ Feature: Testbot - Mode flag When I route I should get | waypoints | route | modes | | a,0,d | ab,bc,cd | 1,3,1 | - | d,0,a | cd,bc,ab | 1,4,1 | - - Scenario: Testbot - Modes for opposite direction - Given the node map - | a | b | c | d | e | - - And the ways - | nodes | highway | - | ab | primary | - | bc | primary | - | cd | river | - | de | river | - - When I route I should get - | from | to | route | modes | - | a | e | ab,bc,cd,de | 1,1,3,3 | + | d,0,a | cd,bc,ab | 1,4,1 | \ No newline at end of file diff --git a/features/testbot/oneway.feature b/features/testbot/oneway.feature index c21d8b1cb..9b4693ddf 100644 --- a/features/testbot/oneway.feature +++ b/features/testbot/oneway.feature @@ -42,3 +42,57 @@ Feature: Testbot - oneways | g | f | gh,ha,ab,bc,cd,de,ef | | h | g | ha,ab,bc,cd,de,ef,fg | | a | h | ab,bc,cd,de,ef,fg,gh | + + Scenario: Testbot - Simple oneway + Then routability should be + | highway | foot | oneway | forw | backw | + | primary | no | yes | x | | + + Scenario: Simple reverse oneway + Then routability should be + | highway | foot | oneway | forw | backw | + | primary | no | -1 | | x | + + Scenario: Testbot - Around the Block + Given the node map + | a | b | + | d | c | + + And the ways + | nodes | oneway | foot | + | ab | yes | no | + | bc | | no | + | cd | | no | + | da | | no | + + When I route I should get + | from | to | route | + | a | b | ab | + | b | a | bc,cd,da | + + Scenario: Testbot - Handle various oneway tag values + Then routability should be + | foot | oneway | forw | backw | + | no | | x | x | + | no | nonsense | x | x | + | no | no | x | x | + | no | false | x | x | + | no | 0 | x | x | + | no | yes | x | | + | no | true | x | | + | no | 1 | x | | + | no | -1 | | x | + + Scenario: Testbot - Two consecutive oneways + Given the node map + | a | b | c | + + And the ways + | nodes | oneway | + | ab | yes | + | bc | yes | + + + When I route I should get + | from | to | route | + | a | c | ab,bc | From a5ee7e78f63874753ba5c1630db960e63bf7f0bb Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Tue, 12 Aug 2014 10:02:29 +0200 Subject: [PATCH 07/49] fixes --- DataStructures/NodeBasedGraph.h | 1 + Extractor/ExtractionWay.h | 2 +- Extractor/ExtractorCallbacks.cpp | 3 --- RoutingAlgorithms/BasicRoutingInterface.h | 7 ++++--- RoutingAlgorithms/ShortestPathRouting.h | 7 ------- features/testbot/mode.feature | 14 +++++++++++++- 6 files changed, 19 insertions(+), 15 deletions(-) diff --git a/DataStructures/NodeBasedGraph.h b/DataStructures/NodeBasedGraph.h index 376c8ffae..05b3a0fba 100644 --- a/DataStructures/NodeBasedGraph.h +++ b/DataStructures/NodeBasedGraph.h @@ -95,6 +95,7 @@ NodeBasedDynamicGraphFromImportEdges(int number_of_nodes, std::vector 0) && (parsed_way.speed != parsed_way.backward_speed); - for (unsigned n = 0; n < (parsed_way.path.size() - 1); ++n) { external_memory.all_edges_list.push_back(InternalExtractorEdge( diff --git a/RoutingAlgorithms/BasicRoutingInterface.h b/RoutingAlgorithms/BasicRoutingInterface.h index e38d176b2..d36686ccd 100644 --- a/RoutingAlgorithms/BasicRoutingInterface.h +++ b/RoutingAlgorithms/BasicRoutingInterface.h @@ -228,7 +228,8 @@ template class BasicRoutingInterface unsigned name_index = facade->GetNameIndexFromEdgeID(ed.id); const TurnInstruction turn_instruction = facade->GetTurnInstructionForEdgeID(ed.id); const TravelMode travel_mode = facade->GetTravelModeForEdgeID(ed.id); - + + if (!facade->EdgeIsCompressed(ed.id)) { BOOST_ASSERT(!facade->EdgeIsCompressed(ed.id)); @@ -257,7 +258,7 @@ template class BasicRoutingInterface BOOST_ASSERT(start_index <= end_index); for (std::size_t i = start_index; i < end_index; ++i) { - unpacked_path.emplace_back(id_vector[i], name_index, TurnInstruction::NoTurn, 0, 0); + unpacked_path.emplace_back(id_vector[i], name_index, TurnInstruction::NoTurn, 0, travel_mode); } unpacked_path.back().turn_instruction = turn_instruction; unpacked_path.back().segment_duration = ed.distance; @@ -304,7 +305,7 @@ template class BasicRoutingInterface phantom_node_pair.target_phantom.name_id, TurnInstruction::NoTurn, 0, - 0}); + phantom_node_pair.target_phantom.travel_mode}); } } diff --git a/RoutingAlgorithms/ShortestPathRouting.h b/RoutingAlgorithms/ShortestPathRouting.h index 646a41c62..deac8bb30 100644 --- a/RoutingAlgorithms/ShortestPathRouting.h +++ b/RoutingAlgorithms/ShortestPathRouting.h @@ -309,13 +309,6 @@ template class ShortestPathRouting : public BasicRoutingInte } raw_route_data.unpacked_path_segments.resize(packed_legs1.size()); - //TODO - needed? - // set mode of first instruction - // if the best route started from the opposite edge, use backward mode rather than forward - //if( packed_legs1.front() == phantom_nodes_vector[0].source_phantom.reverse_node_id ) { - // phantom_nodes_vector[0].source_phantom.travel_mode = phantom_nodes_vector[0].source_phantom.backward_travel_mode; - //} - for (const std::size_t index : osrm::irange(0, packed_legs1.size())) { BOOST_ASSERT(!phantom_nodes_vector.empty()); diff --git a/features/testbot/mode.feature b/features/testbot/mode.feature index d2e81614c..4a4ec1ad3 100644 --- a/features/testbot/mode.feature +++ b/features/testbot/mode.feature @@ -155,4 +155,16 @@ Feature: Testbot - Mode flag When I route I should get | waypoints | route | modes | | a,0,d | ab,bc,cd | 1,3,1 | - | d,0,a | cd,bc,ab | 1,4,1 | \ No newline at end of file + | d,0,a | cd,bc,ab | 1,4,1 | + + Scenario: Testbot - Modes when starting on opposite oneway + Given the node map + | a | b | + + And the ways + | nodes | highway | oneway | + | ab | river | -1 | + + When I route I should get + | from | to | route | modes | + | b | a | ab | 4 | From 235a52032adb588795684656230ac891e65d7781 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Tue, 12 Aug 2014 14:18:02 +0200 Subject: [PATCH 08/49] more tests passing --- Contractor/Prepare.cpp | 7 +- Extractor/ExtractorCallbacks.cpp | 18 ++++- features/bicycle/pushing.feature | 26 +++---- features/step_definitions/routability.rb | 6 +- features/step_definitions/routing.rb | 12 +-- features/testbot/mode.feature | 16 +++- profiles/bicycle.lua | 95 +++++++++++++----------- profiles/lib/maxspeed.lua | 17 +++++ 8 files changed, 125 insertions(+), 72 deletions(-) create mode 100644 profiles/lib/maxspeed.lua diff --git a/Contractor/Prepare.cpp b/Contractor/Prepare.cpp index 4fff40fb5..cd602dfad 100644 --- a/Contractor/Prepare.cpp +++ b/Contractor/Prepare.cpp @@ -134,12 +134,9 @@ int Prepare::Process(int argc, char *argv[]) #ifdef WIN32 #pragma message("Memory consumption on Windows can be higher due to different bit packing") #else - SimpleLogger().Write() << "sizeof(ImportEdge): " << sizeof(ImportEdge); - SimpleLogger().Write() << "sizeof(NodeBasedEdgeData): " << sizeof(NodeBasedEdgeData); - //TODO - //static_assert(sizeof(ImportEdge) == 21, - // "changing ImportEdge type has influence on memory consumption!"); + static_assert(sizeof(ImportEdge) == 20, + "changing ImportEdge type has influence on memory consumption!"); #endif NodeID number_of_node_based_nodes = readBinaryOSRMGraphFromStream(input_stream, diff --git a/Extractor/ExtractorCallbacks.cpp b/Extractor/ExtractorCallbacks.cpp index 798936d2e..4a175b6ab 100644 --- a/Extractor/ExtractorCallbacks.cpp +++ b/Extractor/ExtractorCallbacks.cpp @@ -106,14 +106,28 @@ void ExtractorCallbacks::ProcessWay(ExtractionWay &parsed_way) parsed_way.nameID = string_map_iterator->second; } + if (0 == parsed_way.travel_mode ) + { + parsed_way.direction = ExtractionWay::opposite; + } + + if (0 == parsed_way.backward_travel_mode ) + { + parsed_way.direction = ExtractionWay::oneway; + } + if (ExtractionWay::opposite == parsed_way.direction) { std::reverse(parsed_way.path.begin(), parsed_way.path.end()); parsed_way.direction = ExtractionWay::oneway; } - bool split_edge = parsed_way.IsBidirectional() && parsed_way.HasDiffDirections(); - + const bool split_edge = + (parsed_way.speed>0) && (parsed_way.travel_mode>0) && + (parsed_way.backward_speed>0) && (parsed_way.backward_travel_mode>0) && + ((parsed_way.speed != parsed_way.backward_speed) || + (parsed_way.travel_mode != parsed_way.backward_travel_mode)); + for (unsigned n = 0; n < (parsed_way.path.size() - 1); ++n) { external_memory.all_edges_list.push_back(InternalExtractorEdge( diff --git a/features/bicycle/pushing.feature b/features/bicycle/pushing.feature index 2b238292a..5741fb1c0 100644 --- a/features/bicycle/pushing.feature +++ b/features/bicycle/pushing.feature @@ -4,9 +4,9 @@ Feature: Bike - Accessability of different way types Background: Given the profile "bicycle" Given the shortcuts - | key | value | - | bike | 49s ~20% | - | foot | 121s ~20% | + | key | value | + | bike | 15 km/h ~20% | + | foot | 5 km/h ~20% | Scenario: Bike - Pushing bikes on pedestrian-only ways Then routability should be @@ -98,11 +98,11 @@ Feature: Bike - Accessability of different way types | cd | primary | | When I route I should get - | from | to | route | turns | - | a | d | ab,bc,cd | head,right,left,destination | - | d | a | cd,bc,ab | head,enter_contraflow,leave_contraflow,destination | - | c | a | bc,ab | head,leave_contraflow,destination | - | d | b | cd,bc | head,enter_contraflow,destination | + | from | to | route | turns | + | a | d | ab,bc,cd | head,right,left,destination | + | d | a | cd,bc,ab | head,right,left,destination | + | c | a | bc,ab | head,left,destination | + | d | b | cd,bc | head,right,destination | @todo Scenario: Bike - Instructions when pushing bike on footway/pedestrian, etc. @@ -117,8 +117,8 @@ Feature: Bike - Accessability of different way types | cd | primary | When I route I should get - | from | to | route | turns | - | a | d | ab,bc,cd | head,right,left,destination | - | d | a | cd,bc,ab | head,enter_contraflow,leave_contraflow,destination | - | c | a | bc,ab | head,leave_contraflow,destination | - | d | b | cd,bc | head,enter_contraflow,destination | + | from | to | route | turns | + | a | d | ab,bc,cd | head,right,left,destination | + | d | a | cd,bc,ab | head,right,left,destination | + | c | a | bc,ab | head,left,destination | + | d | b | cd,bc | head,right,destination | diff --git a/features/step_definitions/routability.rb b/features/step_definitions/routability.rb index 03336e583..1881a5c19 100644 --- a/features/step_definitions/routability.rb +++ b/features/step_definitions/routability.rb @@ -54,11 +54,11 @@ Then /^routability should be$/ do |table| want = shortcuts_hash[row[direction]] || row[direction] #expand shortcuts case want when '', 'x' - output_row[direction] = result[direction][:status].to_s + output_row[direction] = result[direction][:time] ? result[direction][:status].to_s : '' when /^\d+s/ - output_row[direction] = "#{result[direction][:time]}s" + output_row[direction] = result[direction][:time] ? "#{result[direction][:time]}s" : '' when /^\d+ km\/h/ - output_row[direction] = "#{result[direction][:speed]} km/h" + output_row[direction] = result[direction][:speed] ? "#{result[direction][:speed]} km/h" : '' else raise "*** Unknown expectation format: #{want}" end diff --git a/features/step_definitions/routing.rb b/features/step_definitions/routing.rb index 73bd5381d..4d944f32b 100644 --- a/features/step_definitions/routing.rb +++ b/features/step_definitions/routing.rb @@ -104,22 +104,22 @@ When /^I route I should get$/ do |table| end end if table.headers.include? 'bearing' - got['bearing'] = bearings + got['bearing'] = instructions ? bearings : '' end if table.headers.include? 'compass' - got['compass'] = compasses + got['compass'] = instructions ? compasses : '' end if table.headers.include? 'turns' - got['turns'] = turns + got['turns'] = instructions ? turns : '' end if table.headers.include? 'modes' - got['modes'] = modes + got['modes'] = instructions ? modes : '' end if table.headers.include? 'times' - got['times'] = times + got['times'] = instructions ? times : '' end if table.headers.include? 'distances' - got['distances'] = distances + got['distances'] = instructions ? distances : '' end end end diff --git a/features/testbot/mode.feature b/features/testbot/mode.feature index 4a4ec1ad3..ed528fe6f 100644 --- a/features/testbot/mode.feature +++ b/features/testbot/mode.feature @@ -157,7 +157,20 @@ Feature: Testbot - Mode flag | a,0,d | ab,bc,cd | 1,3,1 | | d,0,a | cd,bc,ab | 1,4,1 | - Scenario: Testbot - Modes when starting on opposite oneway + Scenario: Testbot - Modes when starting on forward oneway + Given the node map + | a | b | + + And the ways + | nodes | highway | oneway | + | ab | river | yes | + + When I route I should get + | from | to | route | modes | + | a | b | ab | 3 | + | b | a | | | + + Scenario: Testbot - Modes when starting on reverse oneway Given the node map | a | b | @@ -167,4 +180,5 @@ Feature: Testbot - Mode flag When I route I should get | from | to | route | modes | + | a | b | | | | b | a | ab | 4 | diff --git a/profiles/bicycle.lua b/profiles/bicycle.lua index 7c20ed369..c10cd580a 100644 --- a/profiles/bicycle.lua +++ b/profiles/bicycle.lua @@ -1,4 +1,5 @@ require("lib/access") +require("lib/maxspeed") -- Begin of globals barrier_whitelist = { [""] = true, ["cycle_barrier"] = true, ["bollard"] = true, ["entrance"] = true, ["cattle_grid"] = true, ["border_control"] = true, ["toll_booth"] = true, ["sally_port"] = true, ["gate"] = true, ["no"] = true } @@ -221,115 +222,121 @@ function way_function (way) -- speed if route_speeds[route] then -- ferries (doesn't cover routes tagged using relations) + way.mode = mode_ferry way.direction = Way.bidirectional way.ignore_in_grid = true if durationIsValid(duration) then way.duration = math.max( 1, parseDuration(duration) ) else way.speed = route_speeds[route] + way.backward_speed = route_speeds[route] end elseif railway and platform_speeds[railway] then -- railway platforms (old tagging scheme) way.speed = platform_speeds[railway] + way.backward_speed = platform_speeds[railway] elseif platform_speeds[public_transport] then -- public_transport platforms (new tagging platform) way.speed = platform_speeds[public_transport] + way.backward_speed = platform_speeds[public_transport] elseif railway and railway_speeds[railway] then way.mode = mode_train -- railways if access and access_tag_whitelist[access] then way.speed = railway_speeds[railway] + way.backward_speed = railway_speeds[railway] way.direction = Way.bidirectional end elseif amenity and amenity_speeds[amenity] then -- parking areas way.speed = amenity_speeds[amenity] + way.backward_speed = amenity_speeds[amenity] elseif bicycle_speeds[highway] then -- regular ways way.speed = bicycle_speeds[highway] + way.backward_speed = bicycle_speeds[highway] elseif access and access_tag_whitelist[access] then -- unknown way, but valid access tag way.speed = default_speed + way.backward_speed = default_speed else -- biking not allowed, maybe we can push our bike? -- essentially requires pedestrian profiling, for example foot=no mean we can't push a bike - -- TODO: if we can push, the way should be marked as pedestrion mode, but there's no way to do it yet from lua.. - if foot ~= 'no' then + if foot ~= 'no' and junction ~= "roundabout" then if pedestrian_speeds[highway] then -- pedestrian-only ways and areas way.speed = pedestrian_speeds[highway] way.mode = mode_pushing + way.backward_mode = mode_pushing elseif man_made and man_made_speeds[man_made] then -- man made structures way.speed = man_made_speeds[man_made] way.mode = mode_pushing + way.backward_mode = mode_pushing elseif foot == 'yes' then way.speed = walking_speed way.mode = mode_pushing + way.backward_mode = mode_pushing + elseif foot_forward == 'yes' then + way.speed = walking_speed + way.mode = mode_pushing + way.backward_mode = 0 + elseif foot_backward == 'yes' then + way.speed = walking_speed + way.mode = 0 + way.backward_mode = mode_pushing end end end -- direction - way.direction = Way.bidirectional local impliedOneway = false if junction == "roundabout" or highway == "motorway_link" or highway == "motorway" then - way.direction = Way.oneway impliedOneway = true end if onewayClass == "yes" or onewayClass == "1" or onewayClass == "true" then - way.direction = Way.oneway + way.backward_mode = 0 elseif onewayClass == "no" or onewayClass == "0" or onewayClass == "false" then - way.direction = Way.bidirectional + -- prevent implied oneway elseif onewayClass == "-1" then - way.direction = Way.opposite + way.mode = 0 elseif oneway == "no" or oneway == "0" or oneway == "false" then - way.direction = Way.bidirectional + -- prevent implied oneway elseif cycleway and string.find(cycleway, "opposite") == 1 then if impliedOneway then - way.direction = Way.opposite - else - way.direction = Way.bidirectional + way.mode = 0 + way.backward_mode = mode_normal end elseif cycleway_left and cycleway_tags[cycleway_left] and cycleway_right and cycleway_tags[cycleway_right] then - way.direction = Way.bidirectional + -- prevent implied elseif cycleway_left and cycleway_tags[cycleway_left] then if impliedOneway then - way.direction = Way.opposite - else - way.direction = Way.bidirectional + way.mode = 0 + way.backward_mode = mode_normal end elseif cycleway_right and cycleway_tags[cycleway_right] then if impliedOneway then - way.direction = Way.oneway - else - way.direction = Way.bidirectional + way.mode = mode_normal + way.backward_mode = 0 end elseif oneway == "-1" then - way.direction = Way.opposite - elseif oneway == "yes" or oneway == "1" or oneway == "true" then - way.direction = Way.oneway + way.mode = 0 + elseif oneway == "yes" or oneway == "1" or oneway == "true" or impliedOneway then + way.backward_mode = 0 end - + -- pushing bikes if bicycle_speeds[highway] or pedestrian_speeds[highway] then - if foot ~= 'no' then - if junction ~= "roundabout" then - if way.direction == Way.oneway then - way.backward_speed = walking_speed - way.mode = mode_pushing - elseif way.direction == Way.opposite then - way.backward_speed = walking_speed - way.speed = way.speed - way.mode = mode_pushing - end + if foot ~= "no" and junction ~= "roundabout" then + if way.backward_mode == 0 then + way.backward_speed = walking_speed + way.backward_mode = mode_pushing + elseif way.mode == 0 then + way.speed = walking_speed + way.mode = mode_pushing end end - if way.backward_speed == way.speed then - -- TODO: no way yet to mark a way as pedestrian mode if forward/backward speeds are equal - way.direction = Way.bidirectional - end end -- cycleways @@ -341,6 +348,14 @@ function way_function (way) way.speed = bicycle_speeds["cycleway"] end + -- dismount + if bicycle == "dismount" then + way.mode = mode_pushing + way.backward_mode = mode_pushing + way.speed = walking_speed + way.backward_speed = walking_speed + end + -- surfaces if surface then surface_speed = surface_speeds[surface] @@ -355,12 +370,8 @@ function way_function (way) end -- maxspeed - -- TODO: maxspeed of backward direction - if take_minimum_of_speeds then - if maxspeed and maxspeed>0 then - way.speed = math.min(way.speed, maxspeed) - end - end + MaxSpeed.limit( way, maxspeed, maxspeed_forward, maxspeed_backward ) + -- Override speed settings if explicit forward/backward maxspeeds are given if way.speed > 0 and maxspeed_forward ~= nil and maxspeed_forward > 0 then diff --git a/profiles/lib/maxspeed.lua b/profiles/lib/maxspeed.lua new file mode 100644 index 000000000..a99399b1d --- /dev/null +++ b/profiles/lib/maxspeed.lua @@ -0,0 +1,17 @@ +local math = math + +module "MaxSpeed" + +function limit(way,max,maxf,maxb) + if maxf and maxf>0 then + way.speed = math.min(way.speed, maxf) + elseif max and max>0 then + way.speed = math.min(way.speed, max) + end + + if maxb and maxb>0 then + way.backward_speed = math.min(way.backward_speed, maxb) + elseif max and max>0 then + way.backward_speed = math.min(way.backward_speed, max) + end +end From ff0dfacc48076d468d094c15109663e5bf788071 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Tue, 12 Aug 2014 15:10:55 +0200 Subject: [PATCH 09/49] fix initialization order to avoid compiler warning --- DataStructures/ImportEdge.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DataStructures/ImportEdge.cpp b/DataStructures/ImportEdge.cpp index b8c157dff..8d4c9df07 100644 --- a/DataStructures/ImportEdge.cpp +++ b/DataStructures/ImportEdge.cpp @@ -60,7 +60,7 @@ NodeBasedEdge::NodeBasedEdge(NodeID source, bool is_split) : source(source), target(target), name_id(name_id), weight(weight), type(type), forward(forward), backward(backward), roundabout(roundabout), in_tiny_cc(in_tiny_cc), - access_restricted(access_restricted), travel_mode(travel_mode), is_split(is_split) + access_restricted(access_restricted), is_split(is_split), travel_mode(travel_mode) { BOOST_ASSERT_MSG(type > 0, "negative edge type"); } From 687892890bd679a93a507058931e2eb628006b44 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Tue, 12 Aug 2014 16:34:31 +0200 Subject: [PATCH 10/49] remove spurious comment --- Contractor/Prepare.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Contractor/Prepare.cpp b/Contractor/Prepare.cpp index cd602dfad..d5c0208f6 100644 --- a/Contractor/Prepare.cpp +++ b/Contractor/Prepare.cpp @@ -134,7 +134,6 @@ int Prepare::Process(int argc, char *argv[]) #ifdef WIN32 #pragma message("Memory consumption on Windows can be higher due to different bit packing") #else - //TODO static_assert(sizeof(ImportEdge) == 20, "changing ImportEdge type has influence on memory consumption!"); #endif From 8ea88468f3dfc4e72f89b7bb28e77f3b184b58f9 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Tue, 12 Aug 2014 16:34:44 +0200 Subject: [PATCH 11/49] remove unneeded methods --- Extractor/ExtractionWay.h | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/Extractor/ExtractionWay.h b/Extractor/ExtractionWay.h index 2780115b9..ed94d1f57 100644 --- a/Extractor/ExtractionWay.h +++ b/Extractor/ExtractionWay.h @@ -63,22 +63,6 @@ struct ExtractionWay bidirectional, opposite }; - inline bool HasDuration() { return duration>0; } - inline bool IsBidirectional() { return travel_mode!=0 && backward_travel_mode!=0; } - inline bool IsOneway() { return travel_mode!=0 && backward_travel_mode==0; } - inline bool IsOpposite() { return travel_mode==0 && backward_travel_mode!=0; } - inline bool HasDiffDirections() { return (travel_mode != backward_travel_mode) || (speed != backward_speed); } - inline Directions Direction() - { - if( IsOneway() ) { - return ExtractionWay::oneway; - } - if( IsOpposite() ) { - return ExtractionWay::opposite; - } - return ExtractionWay::bidirectional; - } - inline void set_mode(const TravelMode m) { travel_mode = m; } inline const TravelMode get_mode() { return travel_mode; } inline void set_backward_mode(const TravelMode m) { backward_travel_mode = m; } From 62495a6de438f20816829bf0ead328893a850a97 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Tue, 12 Aug 2014 16:35:55 +0200 Subject: [PATCH 12/49] remove comment --- Server/DataStructures/SharedDataFacade.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/Server/DataStructures/SharedDataFacade.h b/Server/DataStructures/SharedDataFacade.h index 0712bce80..7ce36f7ce 100644 --- a/Server/DataStructures/SharedDataFacade.h +++ b/Server/DataStructures/SharedDataFacade.h @@ -152,8 +152,6 @@ template class SharedDataFacade : public BaseDataFacadenum_entries[SharedDataLayout::TURN_INSTRUCTION]); m_turn_instruction_list.swap(turn_instruction_list); - //TODO m_travel_mode_list - unsigned *name_id_list_ptr = data_layout->GetBlockPtr(shared_memory, SharedDataLayout::NAME_ID_LIST); typename ShM::vector name_id_list( From 7a2d214cc4bd5d7f006afb4244bcace3b09837e3 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Tue, 12 Aug 2014 16:39:34 +0200 Subject: [PATCH 13/49] reactivate assert of sizeof(NodeBasedEdgeData) --- DataStructures/NodeBasedGraph.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/DataStructures/NodeBasedGraph.h b/DataStructures/NodeBasedGraph.h index 05b3a0fba..c4b2a2594 100644 --- a/DataStructures/NodeBasedGraph.h +++ b/DataStructures/NodeBasedGraph.h @@ -59,8 +59,7 @@ using SimpleNodeBasedDynamicGraph = DynamicGraph; inline std::shared_ptr NodeBasedDynamicGraphFromImportEdges(int number_of_nodes, std::vector &input_edge_list) { - //TODO - //static_assert(sizeof(NodeBasedEdgeData) == 16, "changing node based edge data size changes memory consumption"); + static_assert(sizeof(NodeBasedEdgeData) == 16, "changing node based edge data size changes memory consumption"); DeallocatingVector edges_list; NodeBasedDynamicGraph::InputEdge edge; From 6e1ab9fe3a340379368195fb476d6a699ca26e39 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Tue, 12 Aug 2014 19:31:31 +0200 Subject: [PATCH 14/49] profile fixes --- features/bicycle/mode.feature | 28 +++++++++++++++++++++++++++- profiles/bicycle.lua | 15 +++------------ profiles/testbot.lua | 12 ++++-------- 3 files changed, 34 insertions(+), 21 deletions(-) diff --git a/features/bicycle/mode.feature b/features/bicycle/mode.feature index 9c3305904..37e51fb77 100644 --- a/features/bicycle/mode.feature +++ b/features/bicycle/mode.feature @@ -148,4 +148,30 @@ Feature: Bike - Mode flag | c | a | bc,ab | head,left,destination | 2,1 | | d | b | cd,bc | head,right,destination | 1,2 | | a | c | ab,bc | head,right,destination | 1,2 | - | b | d | bc,cd | head,left,destination | 2,1 | \ No newline at end of file + | b | d | bc,cd | head,left,destination | 2,1 | + + Scenario: Bicycle - Modes when starting on forward oneway + Given the node map + | a | b | + + And the ways + | nodes | oneway | + | ab | yes | + + When I route I should get + | from | to | route | modes | + | a | b | ab | 2 | + | b | a | | | + + Scenario: Bicycle - Modes when starting on reverse oneway + Given the node map + | a | b | + + And the ways + | nodes | oneway | + | ab | -1 | + + When I route I should get + | from | to | route | modes | + | a | b | | | + | b | a | ab | 2 | diff --git a/profiles/bicycle.lua b/profiles/bicycle.lua index c10cd580a..9f6a64062 100644 --- a/profiles/bicycle.lua +++ b/profiles/bicycle.lua @@ -200,6 +200,7 @@ function way_function (way) local area = way.tags:Find("area") local foot = way.tags:Find("foot") local surface = way.tags:Find("surface") + local bicycle = way.tags:Find("bicycle") -- name if "" ~= ref and "" ~= name then @@ -223,6 +224,7 @@ function way_function (way) if route_speeds[route] then -- ferries (doesn't cover routes tagged using relations) way.mode = mode_ferry + way.backward_mode = mode_ferry way.direction = Way.bidirectional way.ignore_in_grid = true if durationIsValid(duration) then @@ -241,6 +243,7 @@ function way_function (way) way.backward_speed = platform_speeds[public_transport] elseif railway and railway_speeds[railway] then way.mode = mode_train + way.backward_mode = mode_train -- railways if access and access_tag_whitelist[access] then way.speed = railway_speeds[railway] @@ -372,18 +375,6 @@ function way_function (way) -- maxspeed MaxSpeed.limit( way, maxspeed, maxspeed_forward, maxspeed_backward ) - - -- Override speed settings if explicit forward/backward maxspeeds are given - if way.speed > 0 and maxspeed_forward ~= nil and maxspeed_forward > 0 then - if Way.bidirectional == way.direction then - way.backward_speed = way.speed - end - way.speed = maxspeed_forward - end - if maxspeed_backward ~= nil and maxspeed_backward > 0 then - way.backward_speed = maxspeed_backward - end - way.type = 1 return 1 end diff --git a/profiles/testbot.lua b/profiles/testbot.lua index fb32ca642..2e83c8d69 100644 --- a/profiles/testbot.lua +++ b/profiles/testbot.lua @@ -104,19 +104,15 @@ function way_function (way) end way.speed = speed_forw - if speed_back ~= way_forw then - way.backward_speed = speed_back - end + way.backward_speed = speed_back end if oneway == "no" or oneway == "0" or oneway == "false" then - way.direction = Way.bidirectional + -- nothing to do elseif oneway == "-1" then - way.direction = Way.opposite + way.mode = 0 elseif oneway == "yes" or oneway == "1" or oneway == "true" or junction == "roundabout" then - way.direction = Way.oneway - else - way.direction = Way.bidirectional + way.backward_mode = 0 end if junction == 'roundabout' then From 4dd0377eb81a84145718de1dbbf40064d9890c01 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Tue, 12 Aug 2014 19:36:59 +0200 Subject: [PATCH 15/49] fix compilation of tests --- Descriptors/DescriptionFactory.cpp | 3 ++- UnitTests/DataStructures/StaticRTreeTest.cpp | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Descriptors/DescriptionFactory.cpp b/Descriptors/DescriptionFactory.cpp index 4e3412229..ebccf0b2b 100644 --- a/Descriptors/DescriptionFactory.cpp +++ b/Descriptors/DescriptionFactory.cpp @@ -59,7 +59,8 @@ void DescriptionFactory::SetEndSegment(const PhantomNode &target, target_phantom = target; const EdgeWeight segment_duration = (traversed_in_reverse ? target.reverse_weight : target.forward_weight); -<<<<<<< HEAD + const TravelMode travel_mode = + (traversed_in_reverse ? target.backward_travel_mode : target.travel_mode); path_description.emplace_back(target.location, target.name_id, segment_duration, diff --git a/UnitTests/DataStructures/StaticRTreeTest.cpp b/UnitTests/DataStructures/StaticRTreeTest.cpp index 8e7511daa..f8d86cfab 100644 --- a/UnitTests/DataStructures/StaticRTreeTest.cpp +++ b/UnitTests/DataStructures/StaticRTreeTest.cpp @@ -109,7 +109,9 @@ class LinearSearchNN e.reverse_offset, e.packed_geometry_id, nearest, - e.fwd_segment_position}; + e.fwd_segment_position, + e.travel_mode, + e.backward_travel_mode}; nearest_edge = e; } } From 3460bd0ba97f8ebdb0941fa09202c3d842198585 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Wed, 13 Aug 2014 11:28:41 +0200 Subject: [PATCH 16/49] fix problems with mode, 1 failing test left --- Extractor/ExtractorCallbacks.cpp | 4 ++++ RoutingAlgorithms/BasicRoutingInterface.h | 1 + features/bicycle/mode.feature | 8 +++---- features/testbot/mode.feature | 27 ++++++++++++++++++----- 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/Extractor/ExtractorCallbacks.cpp b/Extractor/ExtractorCallbacks.cpp index 4a175b6ab..a8881fcde 100644 --- a/Extractor/ExtractorCallbacks.cpp +++ b/Extractor/ExtractorCallbacks.cpp @@ -120,6 +120,8 @@ void ExtractorCallbacks::ProcessWay(ExtractionWay &parsed_way) { std::reverse(parsed_way.path.begin(), parsed_way.path.end()); parsed_way.direction = ExtractionWay::oneway; + parsed_way.travel_mode = parsed_way.backward_travel_mode; + parsed_way.backward_travel_mode = 0; } const bool split_edge = @@ -128,6 +130,7 @@ void ExtractorCallbacks::ProcessWay(ExtractionWay &parsed_way) ((parsed_way.speed != parsed_way.backward_speed) || (parsed_way.travel_mode != parsed_way.backward_travel_mode)); + BOOST_ASSERT(parsed_way.travel_mode>0); for (unsigned n = 0; n < (parsed_way.path.size() - 1); ++n) { external_memory.all_edges_list.push_back(InternalExtractorEdge( @@ -157,6 +160,7 @@ void ExtractorCallbacks::ProcessWay(ExtractionWay &parsed_way) if (split_edge) { // Only true if the way should be split + BOOST_ASSERT(parsed_way.backward_travel_mode>0); std::reverse(parsed_way.path.begin(), parsed_way.path.end()); for (std::vector::size_type n = 0; n < parsed_way.path.size() - 1; ++n) { diff --git a/RoutingAlgorithms/BasicRoutingInterface.h b/RoutingAlgorithms/BasicRoutingInterface.h index d36686ccd..8e2eedafc 100644 --- a/RoutingAlgorithms/BasicRoutingInterface.h +++ b/RoutingAlgorithms/BasicRoutingInterface.h @@ -301,6 +301,7 @@ template class BasicRoutingInterface for (std::size_t i = start_index; i != end_index; (start_index < end_index ? ++i : --i)) { BOOST_ASSERT(i < id_vector.size()); + BOOST_ASSERT(phantom_node_pair.target_phantom.travel_mode>0 ); unpacked_path.emplace_back(PathData{id_vector[i], phantom_node_pair.target_phantom.name_id, TurnInstruction::NoTurn, diff --git a/features/bicycle/mode.feature b/features/bicycle/mode.feature index 37e51fb77..2bfa4de5b 100644 --- a/features/bicycle/mode.feature +++ b/features/bicycle/mode.feature @@ -160,8 +160,8 @@ Feature: Bike - Mode flag When I route I should get | from | to | route | modes | - | a | b | ab | 2 | - | b | a | | | + | a | b | ab | 1 | + | b | a | ab | 2 | Scenario: Bicycle - Modes when starting on reverse oneway Given the node map @@ -173,5 +173,5 @@ Feature: Bike - Mode flag When I route I should get | from | to | route | modes | - | a | b | | | - | b | a | ab | 2 | + | a | b | ab | 2 | + | b | a | ab | 1 | diff --git a/features/testbot/mode.feature b/features/testbot/mode.feature index ed528fe6f..d68082aaf 100644 --- a/features/testbot/mode.feature +++ b/features/testbot/mode.feature @@ -135,9 +135,9 @@ Feature: Testbot - Mode flag | bd | steps | When I route I should get - | waypoints | route | modes | - | a,d,c | abc,bd,bd,abc | 1,5,6,1 | - | c,d,a | abc,bd,bd,abc | 1,5,6,1 | + | waypoints | route | modes | turns | + | a,d,c | abc,bd,bd,bd,abc | 1,5,5,6,1 | head,right,via,u_turn,right,destination | + | c,d,a | abc,bd,bd,bd,abc | 1,5,5,6,1 | head,left,via,u_turn,left,destination | @via Scenario: Testbot - Modes and via point at river @@ -153,9 +153,9 @@ Feature: Testbot - Mode flag | cd | primary | When I route I should get - | waypoints | route | modes | - | a,0,d | ab,bc,cd | 1,3,1 | - | d,0,a | cd,bc,ab | 1,4,1 | + | waypoints | route | modes | turns | + | a,0,d | ab,bc,bc,cd | 1,3,3,1 | head,straight,via,straight,destination | + | d,0,a | cd,bc,bc,ab | 1,4,4,1 | head,straight,via,straight,destination | Scenario: Testbot - Modes when starting on forward oneway Given the node map @@ -182,3 +182,18 @@ Feature: Testbot - Mode flag | from | to | route | modes | | a | b | | | | b | a | ab | 4 | + + Scenario: Testbot - Modes for each direction + Given the node map + | b | c | | | | + | | | | e | d | + + And the ways + | nodes | highway | + | bc | primary | + | ce | river | + | ed | primary | + + When I route I should get + | from | to | route | modes | + | e | b | ce,bc | 4,1 | From 8e625a5d0715fafc6986626ecc90a127a6c2671e Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Wed, 13 Aug 2014 11:52:19 +0200 Subject: [PATCH 17/49] rename test --- features/testbot/mode.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/testbot/mode.feature b/features/testbot/mode.feature index d68082aaf..1b8723fca 100644 --- a/features/testbot/mode.feature +++ b/features/testbot/mode.feature @@ -183,7 +183,7 @@ Feature: Testbot - Mode flag | a | b | | | | b | a | ab | 4 | - Scenario: Testbot - Modes for each direction + Scenario: Testbot - Starting at a tricky node Given the node map | b | c | | | | | | | | e | d | From bfdc296f43008a960a630a9bfe89294633b4ac9b Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Wed, 13 Aug 2014 15:21:16 +0200 Subject: [PATCH 18/49] reduce failing test --- Util/UUID.cpp | 109 ++++++++++++++++++++++++++++++++++ features/testbot/mode.feature | 15 +++-- 2 files changed, 118 insertions(+), 6 deletions(-) create mode 100644 Util/UUID.cpp diff --git a/Util/UUID.cpp b/Util/UUID.cpp new file mode 100644 index 000000000..3bdc0b096 --- /dev/null +++ b/Util/UUID.cpp @@ -0,0 +1,109 @@ +/* + +Copyright (c) 2013, Project OSRM, Dennis Luxen, others +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#include "UUID.h" + +#include "OSRMException.h" +#include "../typedefs.h" + +#include // generators +#include // streaming operators etc. + +#include + +#include +#include +#include + +#define HAS64BITS 0 +#define MD5PREPARE "0942f9ef6f5912b4fbeae8249dd4df4b" +#define MD5RTREE "40c04fc573a4cea3832d0587908807c9" +#define MD5GRAPH "9f3a0e84509ff908655bbe2464d852b7" +#define MD5OBJECTS "7135d52fa59aa3f2babbb8f307d8dde3" + +UUID::UUID() : magic_number(1297240911) +{ + md5_prepare[32] = md5_tree[32] = md5_graph[32] = md5_objects[32] = '\0'; + + boost::uuids::name_generator gen(named_uuid); + std::string temp_string(__DATE__); + temp_string += __TIME__; + + std::copy(MD5PREPARE, MD5PREPARE + strlen(MD5PREPARE), md5_prepare); + temp_string += md5_prepare; + std::copy(MD5RTREE, MD5RTREE + 32, md5_tree); + temp_string += md5_tree; + std::copy(MD5GRAPH, MD5GRAPH + 32, md5_graph); + temp_string += md5_graph; + std::copy(MD5OBJECTS, MD5OBJECTS + 32, md5_objects); + temp_string += md5_objects; + + named_uuid = gen(temp_string); + has_64_bits = HAS64BITS; +} + +UUID::~UUID() {} + +const boost::uuids::uuid &UUID::GetUUID() const { return named_uuid; } + +bool UUID::IsMagicNumberOK() const { return 1297240911 == magic_number; } + +bool UUID::TestGraphUtil(const UUID &other) const +{ + if (!other.IsMagicNumberOK()) + { + throw OSRMException("hsgr input file misses magic number. Check or reprocess the file"); + } + return std::equal(md5_graph, md5_graph + 32, other.md5_graph); +} + +bool UUID::TestPrepare(const UUID &other) const +{ + if (!other.IsMagicNumberOK()) + { + throw OSRMException("osrm input file misses magic number. Check or reprocess the file"); + } + return std::equal(md5_prepare, md5_prepare + 32, other.md5_prepare); +} + +bool UUID::TestRTree(const UUID &other) const +{ + if (!other.IsMagicNumberOK()) + { + throw OSRMException("r-tree input file misses magic number. Check or reprocess the file"); + } + return std::equal(md5_tree, md5_tree + 32, other.md5_tree); +} + +bool UUID::TestQueryObjects(const UUID &other) const +{ + if (!other.IsMagicNumberOK()) + { + throw OSRMException("missing magic number. Check or reprocess the file"); + } + return std::equal(md5_objects, md5_objects + 32, other.md5_objects); +} diff --git a/features/testbot/mode.feature b/features/testbot/mode.feature index 1b8723fca..322fa9678 100644 --- a/features/testbot/mode.feature +++ b/features/testbot/mode.feature @@ -184,16 +184,19 @@ Feature: Testbot - Mode flag | b | a | ab | 4 | Scenario: Testbot - Starting at a tricky node + Given a grid size of 1 meters Given the node map - | b | c | | | | - | | | | e | d | + | a | 1 | | | | + | | 2 | b | | c | + | | 3 | | | | And the ways | nodes | highway | + | ab | river | | bc | primary | - | ce | river | - | ed | primary | When I route I should get - | from | to | route | modes | - | e | b | ce,bc | 4,1 | + | from | to | route | modes | + | 1 | a | ab | 4 | + | 2 | a | ab | 4 | + | 3 | a | ab | 4 | From 0244060806ce2c0085a0da00ec6a5606c480aa36 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Thu, 14 Aug 2014 10:51:24 +0200 Subject: [PATCH 19/49] add a few tests --- features/testbot/mode.feature | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/features/testbot/mode.feature b/features/testbot/mode.feature index 322fa9678..0fb1d4307 100644 --- a/features/testbot/mode.feature +++ b/features/testbot/mode.feature @@ -183,7 +183,7 @@ Feature: Testbot - Mode flag | a | b | | | | b | a | ab | 4 | - Scenario: Testbot - Starting at a tricky node + Scenario: Testbot - Starting at a tricky node, 1m Given a grid size of 1 meters Given the node map | a | 1 | | | | @@ -200,3 +200,30 @@ Feature: Testbot - Mode flag | 1 | a | ab | 4 | | 2 | a | ab | 4 | | 3 | a | ab | 4 | + + Scenario: Testbot - Starting at a tricky node, 100m + Given the node map + | | a | | | | + | | | | b | c | + + And the ways + | nodes | highway | + | ab | river | + | bc | primary | + + When I route I should get + | from | to | route | modes | + | b | a | ab | 4 | + + Scenario: Testbot - Mode changes on straight way + Given the node map + | a | b | c | + + And the ways + | nodes | highway |name | + | ab | primary |Street | + | bc | river |Street | + + When I route I should get + | from | to | route | modes | turns | + | a | c | Street,Street | 1,4 | head,straight,destination | From bea63028c788c973aec464a65280002d595ea6f2 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Fri, 15 Aug 2014 13:05:48 +0200 Subject: [PATCH 20/49] remove bitfield from SegmentInformation, works around compile err --- DataStructures/SegmentInformation.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DataStructures/SegmentInformation.h b/DataStructures/SegmentInformation.h index fe1704a92..df3bfbaed 100644 --- a/DataStructures/SegmentInformation.h +++ b/DataStructures/SegmentInformation.h @@ -45,7 +45,7 @@ struct SegmentInformation TurnInstruction turn_instruction; bool necessary:1; bool is_via_location:1; - TravelMode travel_mode : 4; + TravelMode travel_mode; explicit SegmentInformation(const FixedPointCoordinate &location, const NodeID name_id, From 35988d8f09a4323876fc5a04d209f4bb7499dce3 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Fri, 15 Aug 2014 14:38:39 +0200 Subject: [PATCH 21/49] fix problem with mode of first instruction --- Descriptors/DescriptionFactory.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Descriptors/DescriptionFactory.cpp b/Descriptors/DescriptionFactory.cpp index ebccf0b2b..e58ae4adb 100644 --- a/Descriptors/DescriptionFactory.cpp +++ b/Descriptors/DescriptionFactory.cpp @@ -76,9 +76,12 @@ void DescriptionFactory::SetEndSegment(const PhantomNode &target, void DescriptionFactory::AppendSegment(const FixedPointCoordinate &coordinate, const PathData &path_point) { - if ((1 == path_description.size()) && (path_description.back().location == coordinate)) + //if the start location is on top of a node, the first movement might be zero-length, + //in which case we dont' add a new description, but instead update the existing one + if ((1 == path_description.size()) && (path_description.front().location == coordinate)) { - path_description.back().name_id = path_point.name_id; + path_description.front().name_id = path_point.name_id; + path_description.front().travel_mode = path_point.travel_mode; return; } From 207cddd50bd07ec28529569a3699dbf8c34bd0a5 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Sat, 16 Aug 2014 10:17:33 +0200 Subject: [PATCH 22/49] use enum for TravelMode --- DataStructures/EdgeBasedNode.h | 5 +++-- DataStructures/ImportEdge.h | 1 + DataStructures/NodeBasedGraph.h | 2 +- DataStructures/OriginalEdgeData.h | 3 ++- DataStructures/PhantomNodes.h | 5 +++-- DataStructures/RawRouteData.h | 3 ++- DataStructures/SegmentInformation.h | 1 + DataStructures/TravelMode.h | 35 +++++++++++++++++++++++++++++ Extractor/ExtractionWay.h | 5 +++-- Extractor/ExtractorCallbacks.cpp | 4 ++-- Extractor/InternalExtractorEdge.h | 7 +++--- 11 files changed, 57 insertions(+), 14 deletions(-) create mode 100644 DataStructures/TravelMode.h diff --git a/DataStructures/EdgeBasedNode.h b/DataStructures/EdgeBasedNode.h index f433ddbca..49a9a81b6 100644 --- a/DataStructures/EdgeBasedNode.h +++ b/DataStructures/EdgeBasedNode.h @@ -1,6 +1,7 @@ #ifndef EDGE_BASED_NODE_H #define EDGE_BASED_NODE_H +#include "../DataStructures/TravelMode.h" #include "../Util/SimpleLogger.h" #include "../typedefs.h" @@ -26,8 +27,8 @@ struct EdgeBasedNode packed_geometry_id(SPECIAL_EDGEID), fwd_segment_position( std::numeric_limits::max() ), is_in_tiny_cc(false), - travel_mode(0), - backward_travel_mode(0) + travel_mode(TravelMode::None), + backward_travel_mode(TravelMode::None) { } explicit EdgeBasedNode( diff --git a/DataStructures/ImportEdge.h b/DataStructures/ImportEdge.h index 20c277318..a6945f237 100644 --- a/DataStructures/ImportEdge.h +++ b/DataStructures/ImportEdge.h @@ -28,6 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef IMPORT_EDGE_H #define IMPORT_EDGE_H +#include "../DataStructures/TravelMode.h" #include "../typedefs.h" struct NodeBasedEdge diff --git a/DataStructures/NodeBasedGraph.h b/DataStructures/NodeBasedGraph.h index c4b2a2594..4a0c1c8ff 100644 --- a/DataStructures/NodeBasedGraph.h +++ b/DataStructures/NodeBasedGraph.h @@ -15,7 +15,7 @@ struct NodeBasedEdgeData : distance(INVALID_EDGE_WEIGHT), edgeBasedNodeID(SPECIAL_NODEID), nameID(std::numeric_limits::max()), type(std::numeric_limits::max()), isAccessRestricted(false), shortcut(false), forward(false), backward(false), - roundabout(false), ignore_in_grid(false), travel_mode(false) + roundabout(false), ignore_in_grid(false), travel_mode(TravelMode::None) { } diff --git a/DataStructures/OriginalEdgeData.h b/DataStructures/OriginalEdgeData.h index 38a6b81a1..5ca1f255d 100644 --- a/DataStructures/OriginalEdgeData.h +++ b/DataStructures/OriginalEdgeData.h @@ -29,6 +29,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define ORIGINAL_EDGE_DATA_H #include "TurnInstructions.h" +#include "../DataStructures/TravelMode.h" #include "../typedefs.h" #include @@ -49,7 +50,7 @@ struct OriginalEdgeData : via_node(std::numeric_limits::max()), name_id(std::numeric_limits::max()), turn_instruction(TurnInstruction::NoTurn), compressed_geometry(false), - travel_mode(0) + travel_mode(TravelMode::None) { } diff --git a/DataStructures/PhantomNodes.h b/DataStructures/PhantomNodes.h index c1598df9b..3654d7911 100644 --- a/DataStructures/PhantomNodes.h +++ b/DataStructures/PhantomNodes.h @@ -29,6 +29,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define PHANTOM_NODES_H #include +#include "../DataStructures/TravelMode.h" #include "../Util/SimpleLogger.h" #include "../typedefs.h" @@ -65,8 +66,8 @@ struct PhantomNode reverse_offset(0), packed_geometry_id(SPECIAL_EDGEID), fwd_segment_position(0), - travel_mode(0), - backward_travel_mode(0) + travel_mode(TravelMode::None), + backward_travel_mode(TravelMode::None) { } NodeID forward_node_id; diff --git a/DataStructures/RawRouteData.h b/DataStructures/RawRouteData.h index b48b62f3c..fc3d227d4 100644 --- a/DataStructures/RawRouteData.h +++ b/DataStructures/RawRouteData.h @@ -29,6 +29,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define RAW_ROUTE_DATA_H #include "../DataStructures/PhantomNodes.h" +#include "../DataStructures/TravelMode.h" #include "../DataStructures/TurnInstructions.h" #include "../typedefs.h" @@ -42,7 +43,7 @@ struct PathData : node(SPECIAL_NODEID), name_id(INVALID_EDGE_WEIGHT), segment_duration(INVALID_EDGE_WEIGHT), turn_instruction(TurnInstruction::NoTurn), - travel_mode(0) + travel_mode(TravelMode::None) { } diff --git a/DataStructures/SegmentInformation.h b/DataStructures/SegmentInformation.h index df3bfbaed..6d5fca36b 100644 --- a/DataStructures/SegmentInformation.h +++ b/DataStructures/SegmentInformation.h @@ -30,6 +30,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "TurnInstructions.h" +#include "../DataStructures/TravelMode.h" #include "../typedefs.h" #include diff --git a/DataStructures/TravelMode.h b/DataStructures/TravelMode.h new file mode 100644 index 000000000..86760708a --- /dev/null +++ b/DataStructures/TravelMode.h @@ -0,0 +1,35 @@ +/* + +Copyright (c) 2013, Project OSRM, Dennis Luxen, others +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef TRAVEL_MODE_H +#define TRAVEL_MODE_H + +enum TravelMode : unsigned char { + None=0, Default=1 +}; + +#endif /* TRAVEL_MODE_H */ diff --git a/Extractor/ExtractionWay.h b/Extractor/ExtractionWay.h index ed94d1f57..4059d1e1b 100644 --- a/Extractor/ExtractionWay.h +++ b/Extractor/ExtractionWay.h @@ -29,6 +29,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define EXTRACTION_WAY_H #include "../DataStructures/HashTable.h" +#include "../DataStructures/TravelMode.h" #include "../typedefs.h" #include @@ -53,8 +54,8 @@ struct ExtractionWay roundabout = false; isAccessRestricted = false; ignoreInGrid = false; - travel_mode = 1; - backward_travel_mode = 1; + travel_mode = TravelMode::Default; + backward_travel_mode = TravelMode::Default; } enum Directions diff --git a/Extractor/ExtractorCallbacks.cpp b/Extractor/ExtractorCallbacks.cpp index a8881fcde..db6f01788 100644 --- a/Extractor/ExtractorCallbacks.cpp +++ b/Extractor/ExtractorCallbacks.cpp @@ -121,12 +121,12 @@ void ExtractorCallbacks::ProcessWay(ExtractionWay &parsed_way) std::reverse(parsed_way.path.begin(), parsed_way.path.end()); parsed_way.direction = ExtractionWay::oneway; parsed_way.travel_mode = parsed_way.backward_travel_mode; - parsed_way.backward_travel_mode = 0; + parsed_way.backward_travel_mode = TravelMode::None; } const bool split_edge = (parsed_way.speed>0) && (parsed_way.travel_mode>0) && - (parsed_way.backward_speed>0) && (parsed_way.backward_travel_mode>0) && + (TravelMode::None != parsed_way.backward_speed) && (TravelMode::None != parsed_way.backward_travel_mode) && ((parsed_way.speed != parsed_way.backward_speed) || (parsed_way.travel_mode != parsed_way.backward_travel_mode)); diff --git a/Extractor/InternalExtractorEdge.h b/Extractor/InternalExtractorEdge.h index 104d23c05..dea0ec3c2 100644 --- a/Extractor/InternalExtractorEdge.h +++ b/Extractor/InternalExtractorEdge.h @@ -29,6 +29,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define INTERNAL_EXTRACTOR_EDGE_H #include "../typedefs.h" +#include "../DataStructures/TravelMode.h" #include #include @@ -38,7 +39,7 @@ struct InternalExtractorEdge InternalExtractorEdge() : start(0), target(0), type(0), direction(0), speed(0), name_id(0), is_roundabout(false), is_in_tiny_cc(false), is_duration_set(false), is_access_restricted(false), - travel_mode(0), is_split(false) + travel_mode(TravelMode::None), is_split(false) { } @@ -65,12 +66,12 @@ struct InternalExtractorEdge // necessary static util functions for stxxl's sorting static InternalExtractorEdge min_value() { - return InternalExtractorEdge(0, 0, 0, 0, 0, 0, false, false, false, false, 0, false); + return InternalExtractorEdge(0, 0, 0, 0, 0, 0, false, false, false, false, TravelMode::None, false); } static InternalExtractorEdge max_value() { return InternalExtractorEdge( - SPECIAL_NODEID, SPECIAL_NODEID, 0, 0, 0, 0, false, false, false, false, 0, false); + SPECIAL_NODEID, SPECIAL_NODEID, 0, 0, 0, 0, false, false, false, false, TravelMode::None, false); } NodeID start; From 6f6aff749312a87754a5614ea7db5731e80e1030 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Sat, 16 Aug 2014 11:02:37 +0200 Subject: [PATCH 23/49] remove direction field from ExtractionWay --- Extractor/ExtractionWay.h | 41 ++++++++++++++++++++++++++++-- Extractor/ExtractorCallbacks.cpp | 20 ++++----------- Extractor/ScriptingEnvironment.cpp | 2 +- profiles/bicycle.lua | 2 -- 4 files changed, 45 insertions(+), 20 deletions(-) diff --git a/Extractor/ExtractionWay.h b/Extractor/ExtractionWay.h index 4059d1e1b..f8c01fe00 100644 --- a/Extractor/ExtractionWay.h +++ b/Extractor/ExtractionWay.h @@ -45,7 +45,6 @@ struct ExtractionWay nameID = INVALID_NAMEID; path.clear(); keyVals.Clear(); - direction = ExtractionWay::notSure; speed = -1; backward_speed = -1; duration = -1; @@ -64,6 +63,45 @@ struct ExtractionWay bidirectional, opposite }; + inline void set_direction(const Directions m) + { + if (Directions::oneway == m ) + { + travel_mode = TravelMode::Default; + backward_travel_mode = TravelMode::None; + } + else if (Directions::opposite == m ) + { + travel_mode = TravelMode::None; + backward_travel_mode = TravelMode::Default; + } + else if (Directions::bidirectional == m ) + { + travel_mode = TravelMode::Default; + backward_travel_mode = TravelMode::Default; + } + } + + inline const Directions get_direction() + { + if (TravelMode::None != travel_mode && TravelMode::None != backward_travel_mode ) + { + return Directions::bidirectional; + } + else if (TravelMode::None != travel_mode ) + { + return Directions::oneway; + } + else if (TravelMode::None != backward_travel_mode ) + { + return Directions::opposite; + } + else + { + return Directions::notSure; + } + } + inline void set_mode(const TravelMode m) { travel_mode = m; } inline const TravelMode get_mode() { return travel_mode; } inline void set_backward_mode(const TravelMode m) { backward_travel_mode = m; } @@ -74,7 +112,6 @@ struct ExtractionWay double speed; double backward_speed; double duration; - Directions direction; std::string name; short type; bool access; diff --git a/Extractor/ExtractorCallbacks.cpp b/Extractor/ExtractorCallbacks.cpp index db6f01788..210360fb1 100644 --- a/Extractor/ExtractorCallbacks.cpp +++ b/Extractor/ExtractorCallbacks.cpp @@ -106,27 +106,16 @@ void ExtractorCallbacks::ProcessWay(ExtractionWay &parsed_way) parsed_way.nameID = string_map_iterator->second; } - if (0 == parsed_way.travel_mode ) - { - parsed_way.direction = ExtractionWay::opposite; - } - - if (0 == parsed_way.backward_travel_mode ) - { - parsed_way.direction = ExtractionWay::oneway; - } - - if (ExtractionWay::opposite == parsed_way.direction) + if (TravelMode::None == parsed_way.travel_mode) { std::reverse(parsed_way.path.begin(), parsed_way.path.end()); - parsed_way.direction = ExtractionWay::oneway; parsed_way.travel_mode = parsed_way.backward_travel_mode; parsed_way.backward_travel_mode = TravelMode::None; } const bool split_edge = - (parsed_way.speed>0) && (parsed_way.travel_mode>0) && - (TravelMode::None != parsed_way.backward_speed) && (TravelMode::None != parsed_way.backward_travel_mode) && + (parsed_way.speed>0) && (TravelMode::None != parsed_way.travel_mode) && + (parsed_way.backward_speed>0) && (TravelMode::None != parsed_way.backward_travel_mode) && ((parsed_way.speed != parsed_way.backward_speed) || (parsed_way.travel_mode != parsed_way.backward_travel_mode)); @@ -137,7 +126,8 @@ void ExtractorCallbacks::ProcessWay(ExtractionWay &parsed_way) parsed_way.path[n], parsed_way.path[n + 1], parsed_way.type, - (split_edge ? ExtractionWay::oneway : parsed_way.direction), + ((split_edge || TravelMode::None == parsed_way.backward_travel_mode) ? ExtractionWay::oneway + : ExtractionWay::bidirectional), parsed_way.speed, parsed_way.nameID, parsed_way.roundabout, diff --git a/Extractor/ScriptingEnvironment.cpp b/Extractor/ScriptingEnvironment.cpp index d56b7b45f..96a8e606f 100644 --- a/Extractor/ScriptingEnvironment.cpp +++ b/Extractor/ScriptingEnvironment.cpp @@ -85,7 +85,7 @@ void ScriptingEnvironment::initLuaState(lua_State* lua_state) .def_readwrite("is_access_restricted", &ExtractionWay::isAccessRestricted) .def_readwrite("ignore_in_grid", &ExtractionWay::ignoreInGrid) .def_readwrite("tags", &ExtractionWay::keyVals) - .def_readwrite("direction", &ExtractionWay::direction) + .property("direction", &ExtractionWay::get_direction, &ExtractionWay::set_direction) .property("mode", &ExtractionWay::get_mode, &ExtractionWay::set_mode) .property("backward_mode", &ExtractionWay::get_backward_mode, &ExtractionWay::set_backward_mode) .enum_("constants")[ diff --git a/profiles/bicycle.lua b/profiles/bicycle.lua index 9f6a64062..37777f9ec 100644 --- a/profiles/bicycle.lua +++ b/profiles/bicycle.lua @@ -225,7 +225,6 @@ function way_function (way) -- ferries (doesn't cover routes tagged using relations) way.mode = mode_ferry way.backward_mode = mode_ferry - way.direction = Way.bidirectional way.ignore_in_grid = true if durationIsValid(duration) then way.duration = math.max( 1, parseDuration(duration) ) @@ -248,7 +247,6 @@ function way_function (way) if access and access_tag_whitelist[access] then way.speed = railway_speeds[railway] way.backward_speed = railway_speeds[railway] - way.direction = Way.bidirectional end elseif amenity and amenity_speeds[amenity] then -- parking areas From 6e364ff0badbdf0a12016a4b0091a1265a9d5ebf Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Sat, 16 Aug 2014 11:40:40 +0200 Subject: [PATCH 24/49] rename travel mode None to Inaccessible --- DataStructures/EdgeBasedNode.h | 4 ++-- DataStructures/NodeBasedGraph.h | 2 +- DataStructures/OriginalEdgeData.h | 2 +- DataStructures/PhantomNodes.h | 4 ++-- DataStructures/RawRouteData.h | 2 +- DataStructures/TravelMode.h | 2 +- Extractor/ExtractionWay.h | 10 +++++----- Extractor/ExtractorCallbacks.cpp | 10 +++++----- Extractor/InternalExtractorEdge.h | 6 +++--- 9 files changed, 21 insertions(+), 21 deletions(-) diff --git a/DataStructures/EdgeBasedNode.h b/DataStructures/EdgeBasedNode.h index 49a9a81b6..c0ff1e66e 100644 --- a/DataStructures/EdgeBasedNode.h +++ b/DataStructures/EdgeBasedNode.h @@ -27,8 +27,8 @@ struct EdgeBasedNode packed_geometry_id(SPECIAL_EDGEID), fwd_segment_position( std::numeric_limits::max() ), is_in_tiny_cc(false), - travel_mode(TravelMode::None), - backward_travel_mode(TravelMode::None) + travel_mode(TravelMode::Inaccessible), + backward_travel_mode(TravelMode::Inaccessible) { } explicit EdgeBasedNode( diff --git a/DataStructures/NodeBasedGraph.h b/DataStructures/NodeBasedGraph.h index 4a0c1c8ff..6dff3eaf8 100644 --- a/DataStructures/NodeBasedGraph.h +++ b/DataStructures/NodeBasedGraph.h @@ -15,7 +15,7 @@ struct NodeBasedEdgeData : distance(INVALID_EDGE_WEIGHT), edgeBasedNodeID(SPECIAL_NODEID), nameID(std::numeric_limits::max()), type(std::numeric_limits::max()), isAccessRestricted(false), shortcut(false), forward(false), backward(false), - roundabout(false), ignore_in_grid(false), travel_mode(TravelMode::None) + roundabout(false), ignore_in_grid(false), travel_mode(TravelMode::Inaccessible) { } diff --git a/DataStructures/OriginalEdgeData.h b/DataStructures/OriginalEdgeData.h index 5ca1f255d..b7e90cd97 100644 --- a/DataStructures/OriginalEdgeData.h +++ b/DataStructures/OriginalEdgeData.h @@ -50,7 +50,7 @@ struct OriginalEdgeData : via_node(std::numeric_limits::max()), name_id(std::numeric_limits::max()), turn_instruction(TurnInstruction::NoTurn), compressed_geometry(false), - travel_mode(TravelMode::None) + travel_mode(TravelMode::Inaccessible) { } diff --git a/DataStructures/PhantomNodes.h b/DataStructures/PhantomNodes.h index 3654d7911..ebdfa94bf 100644 --- a/DataStructures/PhantomNodes.h +++ b/DataStructures/PhantomNodes.h @@ -66,8 +66,8 @@ struct PhantomNode reverse_offset(0), packed_geometry_id(SPECIAL_EDGEID), fwd_segment_position(0), - travel_mode(TravelMode::None), - backward_travel_mode(TravelMode::None) + travel_mode(TravelMode::Inaccessible), + backward_travel_mode(TravelMode::Inaccessible) { } NodeID forward_node_id; diff --git a/DataStructures/RawRouteData.h b/DataStructures/RawRouteData.h index fc3d227d4..aa841c0f9 100644 --- a/DataStructures/RawRouteData.h +++ b/DataStructures/RawRouteData.h @@ -43,7 +43,7 @@ struct PathData : node(SPECIAL_NODEID), name_id(INVALID_EDGE_WEIGHT), segment_duration(INVALID_EDGE_WEIGHT), turn_instruction(TurnInstruction::NoTurn), - travel_mode(TravelMode::None) + travel_mode(TravelMode::Inaccessible) { } diff --git a/DataStructures/TravelMode.h b/DataStructures/TravelMode.h index 86760708a..a2b2faabc 100644 --- a/DataStructures/TravelMode.h +++ b/DataStructures/TravelMode.h @@ -29,7 +29,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define TRAVEL_MODE_H enum TravelMode : unsigned char { - None=0, Default=1 + Inaccessible=0, Default=1 }; #endif /* TRAVEL_MODE_H */ diff --git a/Extractor/ExtractionWay.h b/Extractor/ExtractionWay.h index f8c01fe00..4679df6b5 100644 --- a/Extractor/ExtractionWay.h +++ b/Extractor/ExtractionWay.h @@ -68,11 +68,11 @@ struct ExtractionWay if (Directions::oneway == m ) { travel_mode = TravelMode::Default; - backward_travel_mode = TravelMode::None; + backward_travel_mode = TravelMode::Inaccessible; } else if (Directions::opposite == m ) { - travel_mode = TravelMode::None; + travel_mode = TravelMode::Inaccessible; backward_travel_mode = TravelMode::Default; } else if (Directions::bidirectional == m ) @@ -84,15 +84,15 @@ struct ExtractionWay inline const Directions get_direction() { - if (TravelMode::None != travel_mode && TravelMode::None != backward_travel_mode ) + if (TravelMode::Inaccessible != travel_mode && TravelMode::Inaccessible != backward_travel_mode ) { return Directions::bidirectional; } - else if (TravelMode::None != travel_mode ) + else if (TravelMode::Inaccessible != travel_mode ) { return Directions::oneway; } - else if (TravelMode::None != backward_travel_mode ) + else if (TravelMode::Inaccessible != backward_travel_mode ) { return Directions::opposite; } diff --git a/Extractor/ExtractorCallbacks.cpp b/Extractor/ExtractorCallbacks.cpp index 210360fb1..ffe46ee0a 100644 --- a/Extractor/ExtractorCallbacks.cpp +++ b/Extractor/ExtractorCallbacks.cpp @@ -106,16 +106,16 @@ void ExtractorCallbacks::ProcessWay(ExtractionWay &parsed_way) parsed_way.nameID = string_map_iterator->second; } - if (TravelMode::None == parsed_way.travel_mode) + if (TravelMode::Inaccessible == parsed_way.travel_mode) { std::reverse(parsed_way.path.begin(), parsed_way.path.end()); parsed_way.travel_mode = parsed_way.backward_travel_mode; - parsed_way.backward_travel_mode = TravelMode::None; + parsed_way.backward_travel_mode = TravelMode::Inaccessible; } const bool split_edge = - (parsed_way.speed>0) && (TravelMode::None != parsed_way.travel_mode) && - (parsed_way.backward_speed>0) && (TravelMode::None != parsed_way.backward_travel_mode) && + (parsed_way.speed>0) && (TravelMode::Inaccessible != parsed_way.travel_mode) && + (parsed_way.backward_speed>0) && (TravelMode::Inaccessible != parsed_way.backward_travel_mode) && ((parsed_way.speed != parsed_way.backward_speed) || (parsed_way.travel_mode != parsed_way.backward_travel_mode)); @@ -126,7 +126,7 @@ void ExtractorCallbacks::ProcessWay(ExtractionWay &parsed_way) parsed_way.path[n], parsed_way.path[n + 1], parsed_way.type, - ((split_edge || TravelMode::None == parsed_way.backward_travel_mode) ? ExtractionWay::oneway + ((split_edge || TravelMode::Inaccessible == parsed_way.backward_travel_mode) ? ExtractionWay::oneway : ExtractionWay::bidirectional), parsed_way.speed, parsed_way.nameID, diff --git a/Extractor/InternalExtractorEdge.h b/Extractor/InternalExtractorEdge.h index dea0ec3c2..d05862ce7 100644 --- a/Extractor/InternalExtractorEdge.h +++ b/Extractor/InternalExtractorEdge.h @@ -39,7 +39,7 @@ struct InternalExtractorEdge InternalExtractorEdge() : start(0), target(0), type(0), direction(0), speed(0), name_id(0), is_roundabout(false), is_in_tiny_cc(false), is_duration_set(false), is_access_restricted(false), - travel_mode(TravelMode::None), is_split(false) + travel_mode(TravelMode::Inaccessible), is_split(false) { } @@ -66,12 +66,12 @@ struct InternalExtractorEdge // necessary static util functions for stxxl's sorting static InternalExtractorEdge min_value() { - return InternalExtractorEdge(0, 0, 0, 0, 0, 0, false, false, false, false, TravelMode::None, false); + return InternalExtractorEdge(0, 0, 0, 0, 0, 0, false, false, false, false, TravelMode::Inaccessible, false); } static InternalExtractorEdge max_value() { return InternalExtractorEdge( - SPECIAL_NODEID, SPECIAL_NODEID, 0, 0, 0, 0, false, false, false, false, TravelMode::None, false); + SPECIAL_NODEID, SPECIAL_NODEID, 0, 0, 0, 0, false, false, false, false, TravelMode::Inaccessible, false); } NodeID start; From feaf8711d3285e6116655ec8c447610c9a74d9ed Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Sat, 16 Aug 2014 12:27:26 +0200 Subject: [PATCH 25/49] announce mode changes --- Descriptors/DescriptionFactory.cpp | 9 +++- features/testbot/mode.feature | 74 +++++++++++++++++------------- 2 files changed, 51 insertions(+), 32 deletions(-) diff --git a/Descriptors/DescriptionFactory.cpp b/Descriptors/DescriptionFactory.cpp index e58ae4adb..4d134e576 100644 --- a/Descriptors/DescriptionFactory.cpp +++ b/Descriptors/DescriptionFactory.cpp @@ -85,11 +85,18 @@ void DescriptionFactory::AppendSegment(const FixedPointCoordinate &coordinate, return; } + // make sure mode changes are announced, even when there otherwise is no turn + const TurnInstruction turn = + (TurnInstruction::NoTurn == path_point.turn_instruction && + path_description.front().travel_mode != path_point.travel_mode && + path_point.segment_duration>0) ? TurnInstruction::GoStraight + : path_point.turn_instruction; + path_description.emplace_back(coordinate, path_point.name_id, path_point.segment_duration, 0.f, - path_point.turn_instruction, + turn, path_point.travel_mode); } diff --git a/features/testbot/mode.feature b/features/testbot/mode.feature index 0fb1d4307..7a4686ae1 100644 --- a/features/testbot/mode.feature +++ b/features/testbot/mode.feature @@ -35,6 +35,19 @@ Feature: Testbot - Mode flag | b | d | bc,cd | head,left,destination | 2,1 | | a | f | ab,bc,cd,de,ef | head,right,left,straight,straight,destination | 1,2,1,1,1 | + Scenario: Testbot - Different modes in each direction, start between nodes + Given the node map + | a | 1 | b | + + And the ways + | nodes | highway | + | ab | river | + + When I route I should get + | from | to | route | modes | + | 1 | b | ab | 3 | + | 1 | a | ab | 4 | + Scenario: Testbot - Modes for each direction Given the node map | | | | | | | d | @@ -122,7 +135,21 @@ Feature: Testbot - Mode flag | from | to | route | modes | | b | a | ab | 6 | | a | b | | | - + + @via + Scenario: Testbot - Mode should be set at via points + Given the node map + | a | 1 | b | + + And the ways + | nodes | highway | + | ab | river | + + When I route I should get + | waypoints | route | modes | turns | + | a,1,b | ab,ab | 3,3 | head,via,destination | + | b,1,a | ab,ab | 4,4 | head,via,destination | + @via Scenario: Testbot - Modes and via point at dead end Given the node map @@ -135,9 +162,9 @@ Feature: Testbot - Mode flag | bd | steps | When I route I should get - | waypoints | route | modes | turns | - | a,d,c | abc,bd,bd,bd,abc | 1,5,5,6,1 | head,right,via,u_turn,right,destination | - | c,d,a | abc,bd,bd,bd,abc | 1,5,5,6,1 | head,left,via,u_turn,left,destination | + | waypoints | route | modes | + | a,d,c | abc,bd,bd,bd,abc | 1,5,5,6,1 | + | c,d,a | abc,bd,bd,bd,abc | 1,5,5,6,1 | @via Scenario: Testbot - Modes and via point at river @@ -183,28 +210,10 @@ Feature: Testbot - Mode flag | a | b | | | | b | a | ab | 4 | - Scenario: Testbot - Starting at a tricky node, 1m - Given a grid size of 1 meters + Scenario: Testbot - Starting at a tricky node Given the node map - | a | 1 | | | | - | | 2 | b | | c | - | | 3 | | | | - - And the ways - | nodes | highway | - | ab | river | - | bc | primary | - - When I route I should get - | from | to | route | modes | - | 1 | a | ab | 4 | - | 2 | a | ab | 4 | - | 3 | a | ab | 4 | - - Scenario: Testbot - Starting at a tricky node, 100m - Given the node map - | | a | | | | - | | | | b | c | + | | a | | | | + | | | | b | c | And the ways | nodes | highway | @@ -215,15 +224,18 @@ Feature: Testbot - Mode flag | from | to | route | modes | | b | a | ab | 4 | - Scenario: Testbot - Mode changes on straight way + Scenario: Testbot - Mode changes on straight way without name change Given the node map - | a | b | c | + | a | 1 | b | 2 | c | And the ways - | nodes | highway |name | - | ab | primary |Street | - | bc | river |Street | + | nodes | highway | name | + | ab | primary | Avenue | + | bc | river | Avenue | When I route I should get | from | to | route | modes | turns | - | a | c | Street,Street | 1,4 | head,straight,destination | + | a | c | Avenue,Avenue | 1,3 | head,straight,destination | + | c | a | Avenue,Avenue | 3,1 | head,straight,destination | + | 1 | 2 | Avenue,Avenue | 1,3 | head,straight,destination | + | 2 | 1 | Avenue,Avenue | 3,1 | head,straight,destination | \ No newline at end of file From eb122a2b8c3f24962cf222c6fcf1bb0a3ef25993 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Sat, 16 Aug 2014 14:26:08 +0200 Subject: [PATCH 26/49] tidy feature file --- features/testbot/mode.feature | 309 +++++++++++++++------------------- 1 file changed, 136 insertions(+), 173 deletions(-) diff --git a/features/testbot/mode.feature b/features/testbot/mode.feature index 7a4686ae1..2a9afa411 100644 --- a/features/testbot/mode.feature +++ b/features/testbot/mode.feature @@ -1,5 +1,5 @@ @routing @testbot @mode -Feature: Testbot - Mode flag +Feature: Testbot - Travel mode # testbot modes: # 1 normal @@ -11,130 +11,96 @@ Feature: Testbot - Mode flag Background: Given the profile "testbot" - - Scenario: Testbot - Mode for routes - Given the node map - | a | b | | | | - | | c | d | e | f | - - And the ways - | nodes | highway | route | duration | - | ab | primary | | | - | bc | | ferry | 0:01 | - | cd | primary | | | - | de | primary | | | - | ef | primary | | | - - When I route I should get - | from | to | route | turns | modes | - | a | d | ab,bc,cd | head,right,left,destination | 1,2,1 | - | d | a | cd,bc,ab | head,right,left,destination | 1,2,1 | - | c | a | bc,ab | head,left,destination | 2,1 | - | d | b | cd,bc | head,right,destination | 1,2 | - | a | c | ab,bc | head,right,destination | 1,2 | - | b | d | bc,cd | head,left,destination | 2,1 | - | a | f | ab,bc,cd,de,ef | head,right,left,straight,straight,destination | 1,2,1,1,1 | - - Scenario: Testbot - Different modes in each direction, start between nodes + + Scenario: Testbot - Modes in each direction, different forward/backward speeds Given the node map - | a | 1 | b | + | | 0 | 1 | | + | a | | | b | And the ways - | nodes | highway | - | ab | river | + | nodes | highway | oneway | + | ab | river | | When I route I should get | from | to | route | modes | - | 1 | b | ab | 3 | + | a | 0 | ab | 3 | + | a | b | ab | 3 | + | 0 | 1 | ab | 3 | + | 0 | b | ab | 3 | + | b | 1 | ab | 4 | + | b | a | ab | 4 | + | 1 | 0 | ab | 4 | | 1 | a | ab | 4 | - Scenario: Testbot - Modes for each direction - Given the node map - | | | | | | | d | - | | | | | | 2 | | - | | | | | 6 | | 5 | - | a | 0 | b | c | | | | - | | | | | 4 | | 1 | - | | | | | | 3 | | - | | | | | | | e | - - And the ways - | nodes | highway | oneway | - | abc | primary | | - | cd | primary | yes | - | ce | river | | - | de | primary | | - - When I route I should get - | from | to | route | modes | - | 0 | 1 | abc,ce,de | 1,3,1 | - | 1 | 0 | de,ce,abc | 1,4,1 | - | 0 | 2 | abc,cd | 1,1 | - | 2 | 0 | cd,de,ce,abc | 1,1,4,1 | - | 0 | 3 | abc,ce | 1,3 | - | 3 | 0 | ce,abc | 4,1 | - | 4 | 3 | ce | 3 | - | 3 | 4 | ce | 4 | - | 3 | 1 | ce,de | 3,1 | - | 1 | 3 | de,ce | 1,4 | - | a | e | abc,ce | 1,3 | - | e | a | ce,abc | 4,1 | - | a | d | abc,cd | 1,1 | - | d | a | de,ce,abc | 1,4,1 | - - Scenario: Testbot - Modes in each direction (simple) + Scenario: Testbot - Modes in each direction, same forward/backward speeds Given the node map - | | 0 | 1 | | - | a | | | b | + | | 0 | 1 | | + | a | | | b | And the ways - | nodes | highway | oneway | - | ab | river | | + | nodes | highway | + | ab | steps | When I route I should get - | from | to | route | modes | - | 0 | 1 | ab | 3 | - | 1 | 0 | ab | 4 | + | from | to | route | modes | time | + | 0 | 1 | ab | 5 | 60s +-1 | + | 1 | 0 | ab | 6 | 60s +-1 | - Scenario: Testbot - Modes in each direction (same speed in both direction) + @oneway + Scenario: Testbot - Modes for oneway, different forward/backward speeds Given the node map - | | 0 | 1 | | - | a | | | b | + | a | b | And the ways - | nodes | highway | - | ab | steps | + | nodes | highway | oneway | + | ab | river | yes | When I route I should get - | from | to | route | modes | time | - | 0 | 1 | ab | 5 | 60s +-1 | - | 1 | 0 | ab | 6 | 60s +-1 | + | from | to | route | modes | + | a | b | ab | 3 | + | b | a | | | - Scenario: Testbot - Modes for oneway + @oneway + Scenario: Testbot - Modes for oneway, same forward/backward speeds Given the node map - | a | b | + | a | b | And the ways - | nodes | highway | oneway | - | ab | steps | yes | + | nodes | highway | oneway | + | ab | steps | yes | When I route I should get - | from | to | route | modes | - | a | b | ab | 5 | - | b | a | | | + | from | to | route | modes | + | a | b | ab | 5 | + | b | a | | | - Scenario: Testbot - Modes for reverse oneway + @oneway + Scenario: Testbot - Modes for reverse oneway, different forward/backward speeds Given the node map - | a | b | + | a | b | And the ways - | nodes | highway | oneway | - | ab | steps | -1 | + | nodes | highway | oneway | + | ab | river | -1 | When I route I should get - | from | to | route | modes | - | b | a | ab | 6 | - | a | b | | | + | from | to | route | modes | + | a | b | | | + | b | a | ab | 4 | + + @oneway + Scenario: Testbot - Modes for reverse oneway, same forward/backward speeds + Given the node map + | a | b | + + And the ways + | nodes | highway | oneway | + | ab | steps | -1 | + + When I route I should get + | from | to | route | modes | + | a | b | | | + | b | a | ab | 6 | @via Scenario: Testbot - Mode should be set at via points @@ -146,96 +112,93 @@ Feature: Testbot - Mode flag | ab | river | When I route I should get - | waypoints | route | modes | turns | - | a,1,b | ab,ab | 3,3 | head,via,destination | - | b,1,a | ab,ab | 4,4 | head,via,destination | - - @via - Scenario: Testbot - Modes and via point at dead end - Given the node map - | a | b | c | - | | d | | - - And the ways - | nodes | highway | - | abc | primary | - | bd | steps | - - When I route I should get - | waypoints | route | modes | - | a,d,c | abc,bd,bd,bd,abc | 1,5,5,6,1 | - | c,d,a | abc,bd,bd,bd,abc | 1,5,5,6,1 | - - @via - Scenario: Testbot - Modes and via point at river - Given the node map - | | | 0 | | | - | a | b | | c | d | - - - And the ways - | nodes | highway | - | ab | primary | - | bc | river | - | cd | primary | - - When I route I should get - | waypoints | route | modes | turns | - | a,0,d | ab,bc,bc,cd | 1,3,3,1 | head,straight,via,straight,destination | - | d,0,a | cd,bc,bc,ab | 1,4,4,1 | head,straight,via,straight,destination | - - Scenario: Testbot - Modes when starting on forward oneway - Given the node map - | a | b | - - And the ways - | nodes | highway | oneway | - | ab | river | yes | - - When I route I should get - | from | to | route | modes | - | a | b | ab | 3 | - | b | a | | | - - Scenario: Testbot - Modes when starting on reverse oneway - Given the node map - | a | b | - - And the ways - | nodes | highway | oneway | - | ab | river | -1 | - - When I route I should get - | from | to | route | modes | - | a | b | | | - | b | a | ab | 4 | + | waypoints | route | modes | turns | + | a,1,b | ab,ab | 3,3 | head,via,destination | + | b,1,a | ab,ab | 4,4 | head,via,destination | Scenario: Testbot - Starting at a tricky node Given the node map - | | a | | | | - | | | | b | c | + | | a | | | | + | | | | b | c | And the ways - | nodes | highway | - | ab | river | - | bc | primary | + | nodes | highway | + | ab | river | + | bc | primary | When I route I should get - | from | to | route | modes | - | b | a | ab | 4 | + | from | to | route | modes | + | b | a | ab | 4 | Scenario: Testbot - Mode changes on straight way without name change Given the node map - | a | 1 | b | 2 | c | + | a | 1 | b | 2 | c | And the ways - | nodes | highway | name | - | ab | primary | Avenue | - | bc | river | Avenue | + | nodes | highway | name | + | ab | primary | Avenue | + | bc | river | Avenue | When I route I should get - | from | to | route | modes | turns | - | a | c | Avenue,Avenue | 1,3 | head,straight,destination | - | c | a | Avenue,Avenue | 3,1 | head,straight,destination | - | 1 | 2 | Avenue,Avenue | 1,3 | head,straight,destination | - | 2 | 1 | Avenue,Avenue | 3,1 | head,straight,destination | \ No newline at end of file + | from | to | route | modes | turns | + | a | c | Avenue,Avenue | 1,3 | head,straight,destination | + | c | a | Avenue,Avenue | 4,1 | head,straight,destination | + | 1 | 2 | Avenue,Avenue | 1,3 | head,straight,destination | + | 2 | 1 | Avenue,Avenue | 4,1 | head,straight,destination | + + Scenario: Testbot - Mode for routes + Given the node map + | a | b | | | | + | | c | d | e | f | + + And the ways + | nodes | highway | route | duration | + | ab | primary | | | + | bc | | ferry | 0:01 | + | cd | primary | | | + | de | primary | | | + | ef | primary | | | + + When I route I should get + | from | to | route | turns | modes | + | a | d | ab,bc,cd | head,right,left,destination | 1,2,1 | + | d | a | cd,bc,ab | head,right,left,destination | 1,2,1 | + | c | a | bc,ab | head,left,destination | 2,1 | + | d | b | cd,bc | head,right,destination | 1,2 | + | a | c | ab,bc | head,right,destination | 1,2 | + | b | d | bc,cd | head,left,destination | 2,1 | + | a | f | ab,bc,cd,de,ef | head,right,left,straight,straight,destination | 1,2,1,1,1 | + + Scenario: Testbot - Modes, triangle map + Given the node map + | | | | | | | d | + | | | | | | 2 | | + | | | | | 6 | | 5 | + | a | 0 | b | c | | | | + | | | | | 4 | | 1 | + | | | | | | 3 | | + | | | | | | | e | + + And the ways + | nodes | highway | oneway | + | abc | primary | | + | cd | primary | yes | + | ce | river | | + | de | primary | | + + When I route I should get + | from | to | route | modes | + | 0 | 1 | abc,ce,de | 1,3,1 | + | 1 | 0 | de,ce,abc | 1,4,1 | + | 0 | 2 | abc,cd | 1,1 | + | 2 | 0 | cd,de,ce,abc | 1,1,4,1 | + | 0 | 3 | abc,ce | 1,3 | + | 3 | 0 | ce,abc | 4,1 | + | 4 | 3 | ce | 3 | + | 3 | 4 | ce | 4 | + | 3 | 1 | ce,de | 3,1 | + | 1 | 3 | de,ce | 1,4 | + | a | e | abc,ce | 1,3 | + | e | a | ce,abc | 4,1 | + | a | d | abc,cd | 1,1 | + | d | a | de,ce,abc | 1,4,1 | From 6cdc590db5cce5161baba120ba7042415857e312 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Mon, 18 Aug 2014 15:11:24 +0200 Subject: [PATCH 27/49] typedef instead of enum for TravelMode to avoid gcc warnings --- DataStructures/EdgeBasedNode.h | 4 ++-- DataStructures/NodeBasedGraph.h | 2 +- DataStructures/OriginalEdgeData.h | 2 +- DataStructures/PhantomNodes.h | 4 ++-- DataStructures/RawRouteData.h | 2 +- DataStructures/TravelMode.h | 6 +++--- Extractor/ExtractionWay.h | 22 +++++++++++----------- Extractor/ExtractorCallbacks.cpp | 10 +++++----- Extractor/InternalExtractorEdge.h | 6 +++--- 9 files changed, 29 insertions(+), 29 deletions(-) diff --git a/DataStructures/EdgeBasedNode.h b/DataStructures/EdgeBasedNode.h index c0ff1e66e..8b644535a 100644 --- a/DataStructures/EdgeBasedNode.h +++ b/DataStructures/EdgeBasedNode.h @@ -27,8 +27,8 @@ struct EdgeBasedNode packed_geometry_id(SPECIAL_EDGEID), fwd_segment_position( std::numeric_limits::max() ), is_in_tiny_cc(false), - travel_mode(TravelMode::Inaccessible), - backward_travel_mode(TravelMode::Inaccessible) + travel_mode(TRAVEL_MODE_INACCESSIBLE), + backward_travel_mode(TRAVEL_MODE_INACCESSIBLE) { } explicit EdgeBasedNode( diff --git a/DataStructures/NodeBasedGraph.h b/DataStructures/NodeBasedGraph.h index 6dff3eaf8..a4d521411 100644 --- a/DataStructures/NodeBasedGraph.h +++ b/DataStructures/NodeBasedGraph.h @@ -15,7 +15,7 @@ struct NodeBasedEdgeData : distance(INVALID_EDGE_WEIGHT), edgeBasedNodeID(SPECIAL_NODEID), nameID(std::numeric_limits::max()), type(std::numeric_limits::max()), isAccessRestricted(false), shortcut(false), forward(false), backward(false), - roundabout(false), ignore_in_grid(false), travel_mode(TravelMode::Inaccessible) + roundabout(false), ignore_in_grid(false), travel_mode(TRAVEL_MODE_INACCESSIBLE) { } diff --git a/DataStructures/OriginalEdgeData.h b/DataStructures/OriginalEdgeData.h index b7e90cd97..3d7c54330 100644 --- a/DataStructures/OriginalEdgeData.h +++ b/DataStructures/OriginalEdgeData.h @@ -50,7 +50,7 @@ struct OriginalEdgeData : via_node(std::numeric_limits::max()), name_id(std::numeric_limits::max()), turn_instruction(TurnInstruction::NoTurn), compressed_geometry(false), - travel_mode(TravelMode::Inaccessible) + travel_mode(TRAVEL_MODE_INACCESSIBLE) { } diff --git a/DataStructures/PhantomNodes.h b/DataStructures/PhantomNodes.h index ebdfa94bf..8c662cd09 100644 --- a/DataStructures/PhantomNodes.h +++ b/DataStructures/PhantomNodes.h @@ -66,8 +66,8 @@ struct PhantomNode reverse_offset(0), packed_geometry_id(SPECIAL_EDGEID), fwd_segment_position(0), - travel_mode(TravelMode::Inaccessible), - backward_travel_mode(TravelMode::Inaccessible) + travel_mode(TRAVEL_MODE_INACCESSIBLE), + backward_travel_mode(TRAVEL_MODE_INACCESSIBLE) { } NodeID forward_node_id; diff --git a/DataStructures/RawRouteData.h b/DataStructures/RawRouteData.h index aa841c0f9..d92242e7f 100644 --- a/DataStructures/RawRouteData.h +++ b/DataStructures/RawRouteData.h @@ -43,7 +43,7 @@ struct PathData : node(SPECIAL_NODEID), name_id(INVALID_EDGE_WEIGHT), segment_duration(INVALID_EDGE_WEIGHT), turn_instruction(TurnInstruction::NoTurn), - travel_mode(TravelMode::Inaccessible) + travel_mode(TRAVEL_MODE_INACCESSIBLE) { } diff --git a/DataStructures/TravelMode.h b/DataStructures/TravelMode.h index a2b2faabc..0cead0d65 100644 --- a/DataStructures/TravelMode.h +++ b/DataStructures/TravelMode.h @@ -28,8 +28,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef TRAVEL_MODE_H #define TRAVEL_MODE_H -enum TravelMode : unsigned char { - Inaccessible=0, Default=1 -}; +typedef unsigned char TravelMode; +static const TravelMode TRAVEL_MODE_INACCESSIBLE = 0; +static const TravelMode TRAVEL_MODE_DEFAULT = 1; #endif /* TRAVEL_MODE_H */ diff --git a/Extractor/ExtractionWay.h b/Extractor/ExtractionWay.h index 4679df6b5..cd5086fce 100644 --- a/Extractor/ExtractionWay.h +++ b/Extractor/ExtractionWay.h @@ -53,8 +53,8 @@ struct ExtractionWay roundabout = false; isAccessRestricted = false; ignoreInGrid = false; - travel_mode = TravelMode::Default; - backward_travel_mode = TravelMode::Default; + travel_mode = TRAVEL_MODE_DEFAULT; + backward_travel_mode = TRAVEL_MODE_DEFAULT; } enum Directions @@ -67,32 +67,32 @@ struct ExtractionWay { if (Directions::oneway == m ) { - travel_mode = TravelMode::Default; - backward_travel_mode = TravelMode::Inaccessible; + travel_mode = TRAVEL_MODE_DEFAULT; + backward_travel_mode = TRAVEL_MODE_INACCESSIBLE; } else if (Directions::opposite == m ) { - travel_mode = TravelMode::Inaccessible; - backward_travel_mode = TravelMode::Default; + travel_mode = TRAVEL_MODE_INACCESSIBLE; + backward_travel_mode = TRAVEL_MODE_DEFAULT; } else if (Directions::bidirectional == m ) { - travel_mode = TravelMode::Default; - backward_travel_mode = TravelMode::Default; + travel_mode = TRAVEL_MODE_DEFAULT; + backward_travel_mode = TRAVEL_MODE_DEFAULT; } } inline const Directions get_direction() { - if (TravelMode::Inaccessible != travel_mode && TravelMode::Inaccessible != backward_travel_mode ) + if (TRAVEL_MODE_INACCESSIBLE != travel_mode && TRAVEL_MODE_INACCESSIBLE != backward_travel_mode ) { return Directions::bidirectional; } - else if (TravelMode::Inaccessible != travel_mode ) + else if (TRAVEL_MODE_INACCESSIBLE != travel_mode ) { return Directions::oneway; } - else if (TravelMode::Inaccessible != backward_travel_mode ) + else if (TRAVEL_MODE_INACCESSIBLE != backward_travel_mode ) { return Directions::opposite; } diff --git a/Extractor/ExtractorCallbacks.cpp b/Extractor/ExtractorCallbacks.cpp index ffe46ee0a..e0a4634db 100644 --- a/Extractor/ExtractorCallbacks.cpp +++ b/Extractor/ExtractorCallbacks.cpp @@ -106,16 +106,16 @@ void ExtractorCallbacks::ProcessWay(ExtractionWay &parsed_way) parsed_way.nameID = string_map_iterator->second; } - if (TravelMode::Inaccessible == parsed_way.travel_mode) + if (TRAVEL_MODE_INACCESSIBLE == parsed_way.travel_mode) { std::reverse(parsed_way.path.begin(), parsed_way.path.end()); parsed_way.travel_mode = parsed_way.backward_travel_mode; - parsed_way.backward_travel_mode = TravelMode::Inaccessible; + parsed_way.backward_travel_mode = TRAVEL_MODE_INACCESSIBLE; } const bool split_edge = - (parsed_way.speed>0) && (TravelMode::Inaccessible != parsed_way.travel_mode) && - (parsed_way.backward_speed>0) && (TravelMode::Inaccessible != parsed_way.backward_travel_mode) && + (parsed_way.speed>0) && (TRAVEL_MODE_INACCESSIBLE != parsed_way.travel_mode) && + (parsed_way.backward_speed>0) && (TRAVEL_MODE_INACCESSIBLE != parsed_way.backward_travel_mode) && ((parsed_way.speed != parsed_way.backward_speed) || (parsed_way.travel_mode != parsed_way.backward_travel_mode)); @@ -126,7 +126,7 @@ void ExtractorCallbacks::ProcessWay(ExtractionWay &parsed_way) parsed_way.path[n], parsed_way.path[n + 1], parsed_way.type, - ((split_edge || TravelMode::Inaccessible == parsed_way.backward_travel_mode) ? ExtractionWay::oneway + ((split_edge || TRAVEL_MODE_INACCESSIBLE == parsed_way.backward_travel_mode) ? ExtractionWay::oneway : ExtractionWay::bidirectional), parsed_way.speed, parsed_way.nameID, diff --git a/Extractor/InternalExtractorEdge.h b/Extractor/InternalExtractorEdge.h index d05862ce7..5c03efd4d 100644 --- a/Extractor/InternalExtractorEdge.h +++ b/Extractor/InternalExtractorEdge.h @@ -39,7 +39,7 @@ struct InternalExtractorEdge InternalExtractorEdge() : start(0), target(0), type(0), direction(0), speed(0), name_id(0), is_roundabout(false), is_in_tiny_cc(false), is_duration_set(false), is_access_restricted(false), - travel_mode(TravelMode::Inaccessible), is_split(false) + travel_mode(TRAVEL_MODE_INACCESSIBLE), is_split(false) { } @@ -66,12 +66,12 @@ struct InternalExtractorEdge // necessary static util functions for stxxl's sorting static InternalExtractorEdge min_value() { - return InternalExtractorEdge(0, 0, 0, 0, 0, 0, false, false, false, false, TravelMode::Inaccessible, false); + return InternalExtractorEdge(0, 0, 0, 0, 0, 0, false, false, false, false, TRAVEL_MODE_INACCESSIBLE, false); } static InternalExtractorEdge max_value() { return InternalExtractorEdge( - SPECIAL_NODEID, SPECIAL_NODEID, 0, 0, 0, 0, false, false, false, false, TravelMode::Inaccessible, false); + SPECIAL_NODEID, SPECIAL_NODEID, 0, 0, 0, 0, false, false, false, false, TRAVEL_MODE_INACCESSIBLE, false); } NodeID start; From 30362cfc0c98aa15cbfca89af5db414b3ae880c4 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Mon, 18 Aug 2014 15:38:07 +0200 Subject: [PATCH 28/49] update lua interface to speed and mode --- DataStructures/EdgeBasedNode.h | 8 +-- DataStructures/PhantomNodes.h | 8 +-- DataStructures/StaticRTree.h | 4 +- Descriptors/DescriptionFactory.cpp | 4 +- Extractor/ExtractionWay.h | 22 ++++---- Extractor/ExtractorCallbacks.cpp | 22 ++++---- Extractor/ScriptingEnvironment.cpp | 4 +- RoutingAlgorithms/BasicRoutingInterface.h | 2 +- profiles/bicycle.lua | 68 +++++++++++------------ profiles/car.lua | 20 +++---- profiles/examples/postgis.lua | 4 +- profiles/foot.lua | 14 ++--- profiles/lib/maxspeed.lua | 4 +- profiles/testbot.lua | 16 +++--- 14 files changed, 100 insertions(+), 100 deletions(-) mode change 100644 => 100755 profiles/car.lua diff --git a/DataStructures/EdgeBasedNode.h b/DataStructures/EdgeBasedNode.h index 8b644535a..c88a266d1 100644 --- a/DataStructures/EdgeBasedNode.h +++ b/DataStructures/EdgeBasedNode.h @@ -27,7 +27,7 @@ struct EdgeBasedNode packed_geometry_id(SPECIAL_EDGEID), fwd_segment_position( std::numeric_limits::max() ), is_in_tiny_cc(false), - travel_mode(TRAVEL_MODE_INACCESSIBLE), + forward_travel_mode(TRAVEL_MODE_INACCESSIBLE), backward_travel_mode(TRAVEL_MODE_INACCESSIBLE) { } @@ -44,7 +44,7 @@ struct EdgeBasedNode unsigned packed_geometry_id, unsigned short fwd_segment_position, bool belongs_to_tiny_component, - TravelMode travel_mode , + TravelMode forward_travel_mode, TravelMode backward_travel_mode ) : forward_edge_based_node_id(forward_edge_based_node_id), @@ -59,7 +59,7 @@ struct EdgeBasedNode packed_geometry_id(packed_geometry_id), fwd_segment_position(fwd_segment_position), is_in_tiny_cc(belongs_to_tiny_component), - travel_mode(travel_mode), + forward_travel_mode(forward_travel_mode), backward_travel_mode(backward_travel_mode) { BOOST_ASSERT((forward_edge_based_node_id != SPECIAL_NODEID) || @@ -92,7 +92,7 @@ struct EdgeBasedNode unsigned packed_geometry_id; // if set, then the edge represents a packed geometry unsigned short fwd_segment_position; // segment id in a compressed geometry bool is_in_tiny_cc; - TravelMode travel_mode : 4; + TravelMode forward_travel_mode : 4; TravelMode backward_travel_mode : 4; }; diff --git a/DataStructures/PhantomNodes.h b/DataStructures/PhantomNodes.h index 8c662cd09..ee9e66d5f 100644 --- a/DataStructures/PhantomNodes.h +++ b/DataStructures/PhantomNodes.h @@ -41,7 +41,7 @@ struct PhantomNode int forward_weight, int reverse_weight, int forward_offset, int reverse_offset, unsigned packed_geometry_id, FixedPointCoordinate &location, unsigned short fwd_segment_position, - TravelMode travel_mode, TravelMode backward_travel_mode) : + TravelMode forward_travel_mode, TravelMode backward_travel_mode) : forward_node_id(forward_node_id), reverse_node_id(reverse_node_id), name_id(name_id), @@ -52,7 +52,7 @@ struct PhantomNode packed_geometry_id(packed_geometry_id), location(location), fwd_segment_position(fwd_segment_position), - travel_mode(travel_mode), + forward_travel_mode(forward_travel_mode), backward_travel_mode(backward_travel_mode) { } @@ -66,7 +66,7 @@ struct PhantomNode reverse_offset(0), packed_geometry_id(SPECIAL_EDGEID), fwd_segment_position(0), - travel_mode(TRAVEL_MODE_INACCESSIBLE), + forward_travel_mode(TRAVEL_MODE_INACCESSIBLE), backward_travel_mode(TRAVEL_MODE_INACCESSIBLE) { } @@ -80,7 +80,7 @@ struct PhantomNode unsigned packed_geometry_id; FixedPointCoordinate location; unsigned short fwd_segment_position; - TravelMode travel_mode : 4; + TravelMode forward_travel_mode : 4; TravelMode backward_travel_mode : 4; int GetForwardWeightPlusOffset() const diff --git a/DataStructures/StaticRTree.h b/DataStructures/StaticRTree.h index 0c42ecfeb..05e560450 100644 --- a/DataStructures/StaticRTree.h +++ b/DataStructures/StaticRTree.h @@ -802,7 +802,7 @@ class StaticRTree current_segment.packed_geometry_id, foot_point_coordinate_on_segment, current_segment.fwd_segment_position, - current_segment.travel_mode, + current_segment.forward_travel_mode, current_segment.backward_travel_mode); // Hack to fix rounding errors and wandering via nodes. @@ -1080,7 +1080,7 @@ class StaticRTree current_edge.packed_geometry_id, nearest, current_edge.fwd_segment_position, - current_edge.travel_mode, + current_edge.forward_travel_mode, current_edge.backward_travel_mode}; nearest_edge = current_edge; } diff --git a/Descriptors/DescriptionFactory.cpp b/Descriptors/DescriptionFactory.cpp index 4d134e576..56d94b831 100644 --- a/Descriptors/DescriptionFactory.cpp +++ b/Descriptors/DescriptionFactory.cpp @@ -46,7 +46,7 @@ void DescriptionFactory::SetStartSegment(const PhantomNode &source, const bool t const EdgeWeight segment_duration = (traversed_in_reverse ? source.reverse_weight : source.forward_weight); const TravelMode travel_mode = - (traversed_in_reverse ? source.backward_travel_mode : source.travel_mode); + (traversed_in_reverse ? source.backward_travel_mode : source.forward_travel_mode); AppendSegment(source.location, PathData(0, source.name_id, TurnInstruction::HeadOn, segment_duration, travel_mode)); BOOST_ASSERT(path_description.back().duration == segment_duration); @@ -60,7 +60,7 @@ void DescriptionFactory::SetEndSegment(const PhantomNode &target, const EdgeWeight segment_duration = (traversed_in_reverse ? target.reverse_weight : target.forward_weight); const TravelMode travel_mode = - (traversed_in_reverse ? target.backward_travel_mode : target.travel_mode); + (traversed_in_reverse ? target.backward_travel_mode : target.forward_travel_mode); path_description.emplace_back(target.location, target.name_id, segment_duration, diff --git a/Extractor/ExtractionWay.h b/Extractor/ExtractionWay.h index cd5086fce..703e22e46 100644 --- a/Extractor/ExtractionWay.h +++ b/Extractor/ExtractionWay.h @@ -45,7 +45,7 @@ struct ExtractionWay nameID = INVALID_NAMEID; path.clear(); keyVals.Clear(); - speed = -1; + forward_speed = -1; backward_speed = -1; duration = -1; type = -1; @@ -53,7 +53,7 @@ struct ExtractionWay roundabout = false; isAccessRestricted = false; ignoreInGrid = false; - travel_mode = TRAVEL_MODE_DEFAULT; + forward_travel_mode = TRAVEL_MODE_DEFAULT; backward_travel_mode = TRAVEL_MODE_DEFAULT; } @@ -67,28 +67,28 @@ struct ExtractionWay { if (Directions::oneway == m ) { - travel_mode = TRAVEL_MODE_DEFAULT; + forward_travel_mode = TRAVEL_MODE_DEFAULT; backward_travel_mode = TRAVEL_MODE_INACCESSIBLE; } else if (Directions::opposite == m ) { - travel_mode = TRAVEL_MODE_INACCESSIBLE; + forward_travel_mode = TRAVEL_MODE_INACCESSIBLE; backward_travel_mode = TRAVEL_MODE_DEFAULT; } else if (Directions::bidirectional == m ) { - travel_mode = TRAVEL_MODE_DEFAULT; + forward_travel_mode = TRAVEL_MODE_DEFAULT; backward_travel_mode = TRAVEL_MODE_DEFAULT; } } inline const Directions get_direction() { - if (TRAVEL_MODE_INACCESSIBLE != travel_mode && TRAVEL_MODE_INACCESSIBLE != backward_travel_mode ) + if (TRAVEL_MODE_INACCESSIBLE != forward_travel_mode && TRAVEL_MODE_INACCESSIBLE != backward_travel_mode ) { return Directions::bidirectional; } - else if (TRAVEL_MODE_INACCESSIBLE != travel_mode ) + else if (TRAVEL_MODE_INACCESSIBLE != forward_travel_mode ) { return Directions::oneway; } @@ -102,14 +102,14 @@ struct ExtractionWay } } - inline void set_mode(const TravelMode m) { travel_mode = m; } - inline const TravelMode get_mode() { return travel_mode; } + inline void set_forward_mode(const TravelMode m) { forward_travel_mode = m; } + inline const TravelMode get_forward_mode() { return forward_travel_mode; } inline void set_backward_mode(const TravelMode m) { backward_travel_mode = m; } inline const TravelMode get_backward_mode() { return backward_travel_mode; } unsigned id; unsigned nameID; - double speed; + double forward_speed; double backward_speed; double duration; std::string name; @@ -120,7 +120,7 @@ struct ExtractionWay bool ignoreInGrid; std::vector path; HashTable keyVals; - TravelMode travel_mode : 4; + TravelMode forward_travel_mode : 4; TravelMode backward_travel_mode : 4; }; diff --git a/Extractor/ExtractorCallbacks.cpp b/Extractor/ExtractorCallbacks.cpp index e0a4634db..393d5b90b 100644 --- a/Extractor/ExtractorCallbacks.cpp +++ b/Extractor/ExtractorCallbacks.cpp @@ -63,7 +63,7 @@ bool ExtractorCallbacks::ProcessRestriction(const InputRestrictionContainer &res /** warning: caller needs to take care of synchronization! */ void ExtractorCallbacks::ProcessWay(ExtractionWay &parsed_way) { - if ((0 >= parsed_way.speed) && (0 >= parsed_way.duration)) + if ((0 >= parsed_way.forward_speed) && (0 >= parsed_way.duration)) { // Only true if the way is specified by the speed profile return; } @@ -84,10 +84,10 @@ void ExtractorCallbacks::ProcessWay(ExtractionWay &parsed_way) { // TODO: iterate all way segments and set duration corresponding to the length of each // segment - parsed_way.speed = parsed_way.duration / (parsed_way.path.size() - 1); + parsed_way.forward_speed = parsed_way.duration / (parsed_way.path.size() - 1); } - if (std::numeric_limits::epsilon() >= std::abs(-1. - parsed_way.speed)) + if (std::numeric_limits::epsilon() >= std::abs(-1. - parsed_way.forward_speed)) { SimpleLogger().Write(logDEBUG) << "found way with bogus speed, id: " << parsed_way.id; return; @@ -106,20 +106,20 @@ void ExtractorCallbacks::ProcessWay(ExtractionWay &parsed_way) parsed_way.nameID = string_map_iterator->second; } - if (TRAVEL_MODE_INACCESSIBLE == parsed_way.travel_mode) + if (TRAVEL_MODE_INACCESSIBLE == parsed_way.forward_travel_mode) { std::reverse(parsed_way.path.begin(), parsed_way.path.end()); - parsed_way.travel_mode = parsed_way.backward_travel_mode; + parsed_way.forward_travel_mode = parsed_way.backward_travel_mode; parsed_way.backward_travel_mode = TRAVEL_MODE_INACCESSIBLE; } const bool split_edge = - (parsed_way.speed>0) && (TRAVEL_MODE_INACCESSIBLE != parsed_way.travel_mode) && + (parsed_way.forward_speed>0) && (TRAVEL_MODE_INACCESSIBLE != parsed_way.forward_travel_mode) && (parsed_way.backward_speed>0) && (TRAVEL_MODE_INACCESSIBLE != parsed_way.backward_travel_mode) && - ((parsed_way.speed != parsed_way.backward_speed) || - (parsed_way.travel_mode != parsed_way.backward_travel_mode)); + ((parsed_way.forward_speed != parsed_way.backward_speed) || + (parsed_way.forward_travel_mode != parsed_way.backward_travel_mode)); - BOOST_ASSERT(parsed_way.travel_mode>0); + BOOST_ASSERT(parsed_way.forward_travel_mode>0); for (unsigned n = 0; n < (parsed_way.path.size() - 1); ++n) { external_memory.all_edges_list.push_back(InternalExtractorEdge( @@ -128,13 +128,13 @@ void ExtractorCallbacks::ProcessWay(ExtractionWay &parsed_way) parsed_way.type, ((split_edge || TRAVEL_MODE_INACCESSIBLE == parsed_way.backward_travel_mode) ? ExtractionWay::oneway : ExtractionWay::bidirectional), - parsed_way.speed, + parsed_way.forward_speed, parsed_way.nameID, parsed_way.roundabout, parsed_way.ignoreInGrid, (0 < parsed_way.duration), parsed_way.isAccessRestricted, - parsed_way.travel_mode, + parsed_way.forward_travel_mode, split_edge)); external_memory.used_node_id_list.push_back(parsed_way.path[n]); } diff --git a/Extractor/ScriptingEnvironment.cpp b/Extractor/ScriptingEnvironment.cpp index 96a8e606f..ed2075f98 100644 --- a/Extractor/ScriptingEnvironment.cpp +++ b/Extractor/ScriptingEnvironment.cpp @@ -76,7 +76,7 @@ void ScriptingEnvironment::initLuaState(lua_State* lua_state) // .def(luabind::constructor<>()) .def_readonly("id", &ExtractionWay::id) .def_readwrite("name", &ExtractionWay::name) - .def_readwrite("speed", &ExtractionWay::speed) + .def_readwrite("forward_speed", &ExtractionWay::forward_speed) .def_readwrite("backward_speed", &ExtractionWay::backward_speed) .def_readwrite("duration", &ExtractionWay::duration) .def_readwrite("type", &ExtractionWay::type) @@ -86,7 +86,7 @@ void ScriptingEnvironment::initLuaState(lua_State* lua_state) .def_readwrite("ignore_in_grid", &ExtractionWay::ignoreInGrid) .def_readwrite("tags", &ExtractionWay::keyVals) .property("direction", &ExtractionWay::get_direction, &ExtractionWay::set_direction) - .property("mode", &ExtractionWay::get_mode, &ExtractionWay::set_mode) + .property("forward_mode", &ExtractionWay::get_forward_mode, &ExtractionWay::set_forward_mode) .property("backward_mode", &ExtractionWay::get_backward_mode, &ExtractionWay::set_backward_mode) .enum_("constants")[ luabind::value("notSure", 0), diff --git a/RoutingAlgorithms/BasicRoutingInterface.h b/RoutingAlgorithms/BasicRoutingInterface.h index 8e2eedafc..cd00545df 100644 --- a/RoutingAlgorithms/BasicRoutingInterface.h +++ b/RoutingAlgorithms/BasicRoutingInterface.h @@ -306,7 +306,7 @@ template class BasicRoutingInterface phantom_node_pair.target_phantom.name_id, TurnInstruction::NoTurn, 0, - phantom_node_pair.target_phantom.travel_mode}); + phantom_node_pair.target_phantom.forward_travel_mode}); } } diff --git a/profiles/bicycle.lua b/profiles/bicycle.lua index 37777f9ec..09a234b5c 100644 --- a/profiles/bicycle.lua +++ b/profiles/bicycle.lua @@ -223,42 +223,42 @@ function way_function (way) -- speed if route_speeds[route] then -- ferries (doesn't cover routes tagged using relations) - way.mode = mode_ferry + way.forward_mode = mode_ferry way.backward_mode = mode_ferry way.ignore_in_grid = true if durationIsValid(duration) then way.duration = math.max( 1, parseDuration(duration) ) else - way.speed = route_speeds[route] + way.forward_speed = route_speeds[route] way.backward_speed = route_speeds[route] end elseif railway and platform_speeds[railway] then -- railway platforms (old tagging scheme) - way.speed = platform_speeds[railway] + way.forward_speed = platform_speeds[railway] way.backward_speed = platform_speeds[railway] elseif platform_speeds[public_transport] then -- public_transport platforms (new tagging platform) - way.speed = platform_speeds[public_transport] + way.forward_speed = platform_speeds[public_transport] way.backward_speed = platform_speeds[public_transport] elseif railway and railway_speeds[railway] then - way.mode = mode_train + way.forward_mode = mode_train way.backward_mode = mode_train -- railways if access and access_tag_whitelist[access] then - way.speed = railway_speeds[railway] + way.forward_speed = railway_speeds[railway] way.backward_speed = railway_speeds[railway] end elseif amenity and amenity_speeds[amenity] then -- parking areas - way.speed = amenity_speeds[amenity] + way.forward_speed = amenity_speeds[amenity] way.backward_speed = amenity_speeds[amenity] elseif bicycle_speeds[highway] then -- regular ways - way.speed = bicycle_speeds[highway] + way.forward_speed = bicycle_speeds[highway] way.backward_speed = bicycle_speeds[highway] elseif access and access_tag_whitelist[access] then -- unknown way, but valid access tag - way.speed = default_speed + way.forward_speed = default_speed way.backward_speed = default_speed else -- biking not allowed, maybe we can push our bike? @@ -266,25 +266,25 @@ function way_function (way) if foot ~= 'no' and junction ~= "roundabout" then if pedestrian_speeds[highway] then -- pedestrian-only ways and areas - way.speed = pedestrian_speeds[highway] - way.mode = mode_pushing + way.forward_speed = pedestrian_speeds[highway] + way.forward_mode = mode_pushing way.backward_mode = mode_pushing elseif man_made and man_made_speeds[man_made] then -- man made structures - way.speed = man_made_speeds[man_made] - way.mode = mode_pushing + way.forward_speed = man_made_speeds[man_made] + way.forward_mode = mode_pushing way.backward_mode = mode_pushing elseif foot == 'yes' then - way.speed = walking_speed - way.mode = mode_pushing + way.forward_speed = walking_speed + way.forward_mode = mode_pushing way.backward_mode = mode_pushing elseif foot_forward == 'yes' then - way.speed = walking_speed - way.mode = mode_pushing + way.forward_speed = walking_speed + way.forward_mode = mode_pushing way.backward_mode = 0 elseif foot_backward == 'yes' then - way.speed = walking_speed - way.mode = 0 + way.forward_speed = walking_speed + way.forward_mode = 0 way.backward_mode = mode_pushing end end @@ -301,28 +301,28 @@ function way_function (way) elseif onewayClass == "no" or onewayClass == "0" or onewayClass == "false" then -- prevent implied oneway elseif onewayClass == "-1" then - way.mode = 0 + way.forward_mode = 0 elseif oneway == "no" or oneway == "0" or oneway == "false" then -- prevent implied oneway elseif cycleway and string.find(cycleway, "opposite") == 1 then if impliedOneway then - way.mode = 0 + way.forward_mode = 0 way.backward_mode = mode_normal end elseif cycleway_left and cycleway_tags[cycleway_left] and cycleway_right and cycleway_tags[cycleway_right] then -- prevent implied elseif cycleway_left and cycleway_tags[cycleway_left] then if impliedOneway then - way.mode = 0 + way.forward_mode = 0 way.backward_mode = mode_normal end elseif cycleway_right and cycleway_tags[cycleway_right] then if impliedOneway then - way.mode = mode_normal + way.forward_mode = mode_normal way.backward_mode = 0 end elseif oneway == "-1" then - way.mode = 0 + way.forward_mode = 0 elseif oneway == "yes" or oneway == "1" or oneway == "true" or impliedOneway then way.backward_mode = 0 end @@ -333,27 +333,27 @@ function way_function (way) if way.backward_mode == 0 then way.backward_speed = walking_speed way.backward_mode = mode_pushing - elseif way.mode == 0 then - way.speed = walking_speed - way.mode = mode_pushing + elseif way.forward_mode == 0 then + way.forward_speed = walking_speed + way.forward_mode = mode_pushing end end end -- cycleways if cycleway and cycleway_tags[cycleway] then - way.speed = bicycle_speeds["cycleway"] + way.forward_speed = bicycle_speeds["cycleway"] elseif cycleway_left and cycleway_tags[cycleway_left] then - way.speed = bicycle_speeds["cycleway"] + way.forward_speed = bicycle_speeds["cycleway"] elseif cycleway_right and cycleway_tags[cycleway_right] then - way.speed = bicycle_speeds["cycleway"] + way.forward_speed = bicycle_speeds["cycleway"] end -- dismount if bicycle == "dismount" then - way.mode = mode_pushing + way.forward_mode = mode_pushing way.backward_mode = mode_pushing - way.speed = walking_speed + way.forward_speed = walking_speed way.backward_speed = walking_speed end @@ -361,8 +361,8 @@ function way_function (way) if surface then surface_speed = surface_speeds[surface] if surface_speed then - if way.speed > 0 then - way.speed = surface_speed + if way.forward_speed > 0 then + way.forward_speed = surface_speed end if way.backward_speed > 0 then way.backward_speed = surface_speed diff --git a/profiles/car.lua b/profiles/car.lua old mode 100644 new mode 100755 index 8f8d1bcdd..f04d2667b --- a/profiles/car.lua +++ b/profiles/car.lua @@ -170,7 +170,7 @@ function way_function (way) way.duration = max( parseDuration(duration), 1 ); end way.direction = Way.bidirectional - way.speed = route_speed + way.forward_speed = route_speed end -- leave early of this way is not accessible @@ -178,30 +178,30 @@ function way_function (way) return end - if way.speed == -1 then + if way.forward_speed == -1 then local highway_speed = speed_profile[highway] local max_speed = parse_maxspeed( way.tags:Find("maxspeed") ) -- Set the avg speed on the way if it is accessible by road class if highway_speed then if max_speed > highway_speed then - way.speed = max_speed + way.forward_speed = max_speed -- max_speed = math.huge else - way.speed = highway_speed + way.forward_speed = highway_speed end else -- Set the avg speed on ways that are marked accessible if access_tag_whitelist[access] then - way.speed = speed_profile["default"] + way.forward_speed = speed_profile["default"] end end if 0 == max_speed then max_speed = math.huge end - way.speed = min(way.speed, max_speed) + way.forward_speed = min(way.forward_speed, max_speed) end - if -1 == way.speed then + if -1 == way.forward_speed then return end @@ -256,9 +256,9 @@ function way_function (way) local maxspeed_backward = parse_maxspeed(way.tags:Find( "maxspeed:backward")) if maxspeed_forward > 0 then if Way.bidirectional == way.direction then - way.backward_speed = way.speed + way.backward_speed = way.forward_speed end - way.speed = maxspeed_forward + way.forward_speed = maxspeed_forward end if maxspeed_backward > 0 then way.backward_speed = maxspeed_backward @@ -271,7 +271,7 @@ function way_function (way) way.type = 1 -- scale speeds to get better avg driving times - way.speed = way.speed * speed_reduction + way.forward_speed = way.forward_speed * speed_reduction if maxspeed_backward > 0 then way.backward_speed = way.backward_speed*speed_reduction end diff --git a/profiles/examples/postgis.lua b/profiles/examples/postgis.lua index b101a2792..6e32e4c7f 100644 --- a/profiles/examples/postgis.lua +++ b/profiles/examples/postgis.lua @@ -65,11 +65,11 @@ function way_function (way) local cursor = assert( sql_con:execute(sql_query) ) -- execute querty local row = cursor:fetch( {}, "a" ) -- fetch first (and only) row - way.speed = 20.0 -- default speed + way.forward_speed = 20.0 -- default speed if row then local val = tonumber(row.val) -- read 'val' from row if val > 10 then - way.speed = way.speed / math.log10( val ) -- reduce speed by amount of industry close by + way.forward_speed = way.forward_speed / math.log10( val ) -- reduce speed by amount of industry close by end end cursor:close() -- done with this query diff --git a/profiles/foot.lua b/profiles/foot.lua index ae0dd6083..96e72ee90 100644 --- a/profiles/foot.lua +++ b/profiles/foot.lua @@ -161,23 +161,23 @@ function way_function (way) if durationIsValid(duration) then way.duration = math.max( 1, parseDuration(duration) ) else - way.speed = route_speeds[route] + way.forward_speed = route_speeds[route] end elseif railway and platform_speeds[railway] then -- railway platforms (old tagging scheme) - way.speed = platform_speeds[railway] + way.forward_speed = platform_speeds[railway] elseif platform_speeds[public_transport] then -- public_transport platforms (new tagging platform) - way.speed = platform_speeds[public_transport] + way.forward_speed = platform_speeds[public_transport] elseif amenity and amenity_speeds[amenity] then -- parking areas - way.speed = amenity_speeds[amenity] + way.forward_speed = amenity_speeds[amenity] elseif speeds[highway] then -- regular ways - way.speed = speeds[highway] + way.forward_speed = speeds[highway] elseif access and access_tag_whitelist[access] then -- unknown way, but valid access tag - way.speed = walking_speed + way.forward_speed = walking_speed end -- oneway @@ -195,7 +195,7 @@ function way_function (way) if surface then surface_speed = surface_speeds[surface] if surface_speed then - way.speed = math.min(way.speed, surface_speed) + way.forward_speed = math.min(way.forward_speed, surface_speed) way.backward_speed = math.min(way.backward_speed, surface_speed) end end diff --git a/profiles/lib/maxspeed.lua b/profiles/lib/maxspeed.lua index a99399b1d..aca344a79 100644 --- a/profiles/lib/maxspeed.lua +++ b/profiles/lib/maxspeed.lua @@ -4,9 +4,9 @@ module "MaxSpeed" function limit(way,max,maxf,maxb) if maxf and maxf>0 then - way.speed = math.min(way.speed, maxf) + way.forward_speed = math.min(way.forward_speed, maxf) elseif max and max>0 then - way.speed = math.min(way.speed, max) + way.forward_speed = math.min(way.forward_speed, max) end if maxb and maxb>0 then diff --git a/profiles/testbot.lua b/profiles/testbot.lua index 2e83c8d69..640c81651 100644 --- a/profiles/testbot.lua +++ b/profiles/testbot.lua @@ -70,22 +70,22 @@ function way_function (way) if route ~= nil and durationIsValid(duration) then way.duration = math.max( 1, parseDuration(duration) ) - way.mode = 2 - way.backward_mode = 2 + way.forward_mode = 2 + way.backward_mode = 2 else local speed_forw = speed_profile[highway] or speed_profile['default'] local speed_back = speed_forw if highway == "river" then local temp_speed = speed_forw; - way.mode = 3 - way.backward_mode = 4 + way.forward_mode = 3 + way.backward_mode = 4 speed_forw = temp_speed*1.5 speed_back = temp_speed/1.5 elseif highway == "steps" then - way.mode = 5 + way.forward_mode = 5 way.backward_mode = 6 - end + end if maxspeed_forward ~= nil and maxspeed_forward > 0 then speed_forw = maxspeed_forward @@ -103,14 +103,14 @@ function way_function (way) end end - way.speed = speed_forw + way.forward_speed = speed_forw way.backward_speed = speed_back end if oneway == "no" or oneway == "0" or oneway == "false" then -- nothing to do elseif oneway == "-1" then - way.mode = 0 + way.forward_mode = 0 elseif oneway == "yes" or oneway == "1" or oneway == "true" or junction == "roundabout" then way.backward_mode = 0 end From 1945aae4dcb85947c8e68d75818ad316f4d35311 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Mon, 18 Aug 2014 16:27:51 +0200 Subject: [PATCH 29/49] reorder members of SegmentInformation, remove bit fields where possible --- DataStructures/SegmentInformation.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/DataStructures/SegmentInformation.h b/DataStructures/SegmentInformation.h index 6d5fca36b..8e9b047e3 100644 --- a/DataStructures/SegmentInformation.h +++ b/DataStructures/SegmentInformation.h @@ -44,10 +44,10 @@ struct SegmentInformation float length; short bearing; // more than enough [0..3600] fits into 12 bits TurnInstruction turn_instruction; - bool necessary:1; - bool is_via_location:1; - TravelMode travel_mode; - + TravelMode travel_mode; + bool necessary; + bool is_via_location; + explicit SegmentInformation(const FixedPointCoordinate &location, const NodeID name_id, const EdgeWeight duration, From 13ea12cf6ef296fcd505a77a72244bc4eb74131c Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Mon, 18 Aug 2014 16:59:10 +0200 Subject: [PATCH 30/49] fix unit test --- UnitTests/DataStructures/StaticRTreeTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnitTests/DataStructures/StaticRTreeTest.cpp b/UnitTests/DataStructures/StaticRTreeTest.cpp index f8d86cfab..aef77b1b0 100644 --- a/UnitTests/DataStructures/StaticRTreeTest.cpp +++ b/UnitTests/DataStructures/StaticRTreeTest.cpp @@ -110,7 +110,7 @@ class LinearSearchNN e.packed_geometry_id, nearest, e.fwd_segment_position, - e.travel_mode, + e.forward_travel_mode, e.backward_travel_mode}; nearest_edge = e; } From 221113cbb71ec327d9381132364c3ff9dcbb5f7d Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Mon, 18 Aug 2014 18:11:51 +0200 Subject: [PATCH 31/49] fix assert --- RoutingAlgorithms/BasicRoutingInterface.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RoutingAlgorithms/BasicRoutingInterface.h b/RoutingAlgorithms/BasicRoutingInterface.h index cd00545df..1926e9e77 100644 --- a/RoutingAlgorithms/BasicRoutingInterface.h +++ b/RoutingAlgorithms/BasicRoutingInterface.h @@ -301,7 +301,7 @@ template class BasicRoutingInterface for (std::size_t i = start_index; i != end_index; (start_index < end_index ? ++i : --i)) { BOOST_ASSERT(i < id_vector.size()); - BOOST_ASSERT(phantom_node_pair.target_phantom.travel_mode>0 ); + BOOST_ASSERT(phantom_node_pair.target_phantom.forward_travel_mode>0 ); unpacked_path.emplace_back(PathData{id_vector[i], phantom_node_pair.target_phantom.name_id, TurnInstruction::NoTurn, From 418ff955439231d8d2e25ffc8c72f4c8723f30ab Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Tue, 19 Aug 2014 09:24:05 +0200 Subject: [PATCH 32/49] fix initialization order --- DataStructures/SegmentInformation.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/DataStructures/SegmentInformation.h b/DataStructures/SegmentInformation.h index 8e9b047e3..6e8d68397 100644 --- a/DataStructures/SegmentInformation.h +++ b/DataStructures/SegmentInformation.h @@ -57,8 +57,8 @@ struct SegmentInformation const bool is_via_location, const TravelMode travel_mode) : location(location), name_id(name_id), duration(duration), length(length), bearing(0), - turn_instruction(turn_instruction), necessary(necessary), is_via_location(is_via_location), - travel_mode(travel_mode) + turn_instruction(turn_instruction), travel_mode(travel_mode), necessary(necessary), + is_via_location(is_via_location) { } @@ -69,8 +69,8 @@ struct SegmentInformation const TurnInstruction turn_instruction, const TravelMode travel_mode) : location(location), name_id(name_id), duration(duration), length(length), bearing(0), - turn_instruction(turn_instruction), necessary(turn_instruction != TurnInstruction::NoTurn), is_via_location(false), - travel_mode(travel_mode) + turn_instruction(turn_instruction), travel_mode(travel_mode), + necessary(turn_instruction != TurnInstruction::NoTurn), is_via_location(false) { } }; From 3d94638d86727aebae9cbea9f21f57130dd27d09 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Tue, 19 Aug 2014 11:23:30 +0200 Subject: [PATCH 33/49] update car profile, add ferry mode --- features/car/ferry.feature | 18 +++++++++--------- profiles/car.lua | 16 +++++++++++----- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/features/car/ferry.feature b/features/car/ferry.feature index 3e90cf005..7d16c2ed2 100644 --- a/features/car/ferry.feature +++ b/features/car/ferry.feature @@ -17,12 +17,12 @@ Feature: Car - Handle ferry routes | efg | primary | | | When I route I should get - | from | to | route | - | a | g | abc,cde,efg | - | b | f | abc,cde,efg | - | e | c | cde | - | e | b | cde,abc | - | e | a | cde,abc | - | c | e | cde | - | c | f | cde,efg | - | c | g | cde,efg | + | from | to | route | modes | + | a | g | abc,cde,efg | 1,2,1 | + | b | f | abc,cde,efg | 1,2,1 | + | e | c | cde | 2 | + | e | b | cde,abc | 2,1 | + | e | a | cde,abc | 2,1 | + | c | e | cde | 2 | + | c | f | cde,efg | 2,1 | + | c | g | cde,efg | 2,1 | diff --git a/profiles/car.lua b/profiles/car.lua index f04d2667b..990c38049 100755 --- a/profiles/car.lua +++ b/profiles/car.lua @@ -48,6 +48,11 @@ local max = math.max local speed_reduction = 0.8 +--modes +local mode_normal = 1 +local mode_ferry = 2 + + local function find_access_tag(source,access_tags_hierachy) for i,v in ipairs(access_tags_hierachy) do local has_tag = source.tags:Holds(v) @@ -169,8 +174,10 @@ function way_function (way) if durationIsValid(duration) then way.duration = max( parseDuration(duration), 1 ); end - way.direction = Way.bidirectional + way.forward_mode = mode_ferry + way.backward_mode = mode_ferry way.forward_speed = route_speed + way.backward_speed = route_speed end -- leave early of this way is not accessible @@ -237,17 +244,16 @@ function way_function (way) end -- Set direction according to tags on way - way.direction = Way.bidirectional if obey_oneway then if oneway == "-1" then - way.direction = Way.opposite + way.forward_mode = 0 elseif oneway == "yes" or oneway == "1" or oneway == "true" or junction == "roundabout" or (highway == "motorway_link" and oneway ~="no") or (highway == "motorway" and oneway ~= "no") then - way.direction = Way.oneway + way.backward_mode = 0 end end @@ -255,7 +261,7 @@ function way_function (way) local maxspeed_forward = parse_maxspeed(way.tags:Find( "maxspeed:forward")) local maxspeed_backward = parse_maxspeed(way.tags:Find( "maxspeed:backward")) if maxspeed_forward > 0 then - if Way.bidirectional == way.direction then + if 0 ~= way.forward_mode and 0 ~= way.backward_mode then way.backward_speed = way.forward_speed end way.forward_speed = maxspeed_forward From 6ee7a81f10dd1af2e330098a0bf206978bae8e08 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Tue, 19 Aug 2014 11:32:56 +0200 Subject: [PATCH 34/49] update foot profile, add ferry mode --- features/foot/ferry.feature | 18 +++++++++--------- profiles/foot.lua | 15 +++++++++------ 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/features/foot/ferry.feature b/features/foot/ferry.feature index 430875655..866644d26 100644 --- a/features/foot/ferry.feature +++ b/features/foot/ferry.feature @@ -17,15 +17,15 @@ Feature: Foot - Handle ferry routes | efg | primary | | | When I route I should get - | from | to | route | - | a | g | abc,cde,efg | - | b | f | abc,cde,efg | - | e | c | cde | - | e | b | cde,abc | - | e | a | cde,abc | - | c | e | cde | - | c | f | cde,efg | - | c | g | cde,efg | + | from | to | route | modes | + | a | g | abc,cde,efg | 1,2,1 | + | b | f | abc,cde,efg | 1,2,1 | + | e | c | cde | 2 | + | e | b | cde,abc | 2,1 | + | e | a | cde,abc | 2,1 | + | c | e | cde | 2 | + | c | f | cde,efg | 2,1 | + | c | g | cde,efg | 2,1 | Scenario: Foot - Ferry duration, single node Given the node map diff --git a/profiles/foot.lua b/profiles/foot.lua index 96e72ee90..effd54e99 100644 --- a/profiles/foot.lua +++ b/profiles/foot.lua @@ -63,6 +63,10 @@ traffic_signal_penalty = 2 u_turn_penalty = 2 use_turn_restrictions = false +--modes +local mode_normal = 1 +local mode_ferry = 2 + function get_exceptions(vector) for i,v in ipairs(restriction_exception_tags) do vector:Add(v) @@ -156,13 +160,14 @@ function way_function (way) -- speed if route_speeds[route] then -- ferries (doesn't cover routes tagged using relations) - way.direction = Way.bidirectional way.ignore_in_grid = true if durationIsValid(duration) then way.duration = math.max( 1, parseDuration(duration) ) else way.forward_speed = route_speeds[route] end + way.forward_mode = mode_ferry + way.backward_mode = mode_ferry elseif railway and platform_speeds[railway] then -- railway platforms (old tagging scheme) way.forward_speed = platform_speeds[railway] @@ -182,13 +187,11 @@ function way_function (way) -- oneway if onewayClass == "yes" or onewayClass == "1" or onewayClass == "true" then - way.direction = Way.oneway + way.backward_mode = 0 elseif onewayClass == "no" or onewayClass == "0" or onewayClass == "false" then - way.direction = Way.bidirectional + -- nothing to do elseif onewayClass == "-1" then - way.direction = Way.opposite - else - way.direction = Way.bidirectional + way.forward_mode = 0 end -- surfaces From c37c8dc21d849d530ebce4b5e988a0122b3b17d7 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Tue, 19 Aug 2014 11:35:31 +0200 Subject: [PATCH 35/49] add mode test --- features/testbot/mode.feature | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/features/testbot/mode.feature b/features/testbot/mode.feature index 2a9afa411..11fe83a42 100644 --- a/features/testbot/mode.feature +++ b/features/testbot/mode.feature @@ -202,3 +202,26 @@ Feature: Testbot - Travel mode | e | a | ce,abc | 4,1 | | a | d | abc,cd | 1,1 | | d | a | de,ce,abc | 1,4,1 | + + Scenario: Testbot - River in the middle + Given the node map + | a | b | c | | | + | | | d | | | + | | | e | f | g | + + And the ways + | nodes | highway | + | abc | primary | + | cde | river | + | efg | primary | + + When I route I should get + | from | to | route | modes | + | a | g | abc,cde,efg | 1,3,1 | + | b | f | abc,cde,efg | 1,3,1 | + | e | c | cde | 4 | + | e | b | cde,abc | 4,1 | + | e | a | cde,abc | 4,1 | + | c | e | cde | 3 | + | c | f | cde,efg | 3,1 | + | c | g | cde,efg | 3,1 | From 2780ff31b5d042335c896e5e29dd1fcea218eb1d Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Tue, 19 Aug 2014 14:51:48 +0200 Subject: [PATCH 36/49] fix bug with mode of 1st instruction --- Descriptors/DescriptionFactory.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Descriptors/DescriptionFactory.cpp b/Descriptors/DescriptionFactory.cpp index 56d94b831..36e94c6a9 100644 --- a/Descriptors/DescriptionFactory.cpp +++ b/Descriptors/DescriptionFactory.cpp @@ -80,8 +80,11 @@ void DescriptionFactory::AppendSegment(const FixedPointCoordinate &coordinate, //in which case we dont' add a new description, but instead update the existing one if ((1 == path_description.size()) && (path_description.front().location == coordinate)) { - path_description.front().name_id = path_point.name_id; - path_description.front().travel_mode = path_point.travel_mode; + if (path_point.segment_duration>0) + { + path_description.front().name_id = path_point.name_id; + path_description.front().travel_mode = path_point.travel_mode; + } return; } From fccb1aad324cac2f9422c13c6063a55d3c5d05ee Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Tue, 19 Aug 2014 16:08:38 +0200 Subject: [PATCH 37/49] remove type attribute --- Extractor/ExtractionContainers.cpp | 1 - Extractor/ExtractionWay.h | 2 -- Extractor/ExtractorCallbacks.cpp | 2 -- Extractor/InternalExtractorEdge.h | 10 ++++------ Extractor/ScriptingEnvironment.cpp | 1 - Util/GraphLoader.h | 2 -- profiles/bicycle.lua | 3 +-- profiles/car.lua | 3 +-- profiles/foot.lua | 3 +-- profiles/testbot.lua | 3 +-- 10 files changed, 8 insertions(+), 22 deletions(-) diff --git a/Extractor/ExtractionContainers.cpp b/Extractor/ExtractionContainers.cpp index 9a88a56ac..3c7c97465 100644 --- a/Extractor/ExtractionContainers.cpp +++ b/Extractor/ExtractionContainers.cpp @@ -371,7 +371,6 @@ void ExtractionContainers::PrepareData(const std::string &output_file_name, } file_out_stream.write((char *)&integer_weight, sizeof(int)); - file_out_stream.write((char *)&edge_iterator->type, sizeof(short)); file_out_stream.write((char *)&edge_iterator->name_id, sizeof(unsigned)); file_out_stream.write((char *)&edge_iterator->is_roundabout, sizeof(bool)); file_out_stream.write((char *)&edge_iterator->is_in_tiny_cc, sizeof(bool)); diff --git a/Extractor/ExtractionWay.h b/Extractor/ExtractionWay.h index 703e22e46..43ba17503 100644 --- a/Extractor/ExtractionWay.h +++ b/Extractor/ExtractionWay.h @@ -48,7 +48,6 @@ struct ExtractionWay forward_speed = -1; backward_speed = -1; duration = -1; - type = -1; access = true; roundabout = false; isAccessRestricted = false; @@ -113,7 +112,6 @@ struct ExtractionWay double backward_speed; double duration; std::string name; - short type; bool access; bool roundabout; bool isAccessRestricted; diff --git a/Extractor/ExtractorCallbacks.cpp b/Extractor/ExtractorCallbacks.cpp index 393d5b90b..33268a346 100644 --- a/Extractor/ExtractorCallbacks.cpp +++ b/Extractor/ExtractorCallbacks.cpp @@ -125,7 +125,6 @@ void ExtractorCallbacks::ProcessWay(ExtractionWay &parsed_way) external_memory.all_edges_list.push_back(InternalExtractorEdge( parsed_way.path[n], parsed_way.path[n + 1], - parsed_way.type, ((split_edge || TRAVEL_MODE_INACCESSIBLE == parsed_way.backward_travel_mode) ? ExtractionWay::oneway : ExtractionWay::bidirectional), parsed_way.forward_speed, @@ -157,7 +156,6 @@ void ExtractorCallbacks::ProcessWay(ExtractionWay &parsed_way) external_memory.all_edges_list.push_back( InternalExtractorEdge(parsed_way.path[n], parsed_way.path[n + 1], - parsed_way.type, ExtractionWay::oneway, parsed_way.backward_speed, parsed_way.nameID, diff --git a/Extractor/InternalExtractorEdge.h b/Extractor/InternalExtractorEdge.h index 5c03efd4d..b1dde2508 100644 --- a/Extractor/InternalExtractorEdge.h +++ b/Extractor/InternalExtractorEdge.h @@ -37,7 +37,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. struct InternalExtractorEdge { InternalExtractorEdge() - : start(0), target(0), type(0), direction(0), speed(0), name_id(0), is_roundabout(false), + : start(0), target(0), direction(0), speed(0), name_id(0), is_roundabout(false), is_in_tiny_cc(false), is_duration_set(false), is_access_restricted(false), travel_mode(TRAVEL_MODE_INACCESSIBLE), is_split(false) { @@ -45,7 +45,6 @@ struct InternalExtractorEdge explicit InternalExtractorEdge(NodeID start, NodeID target, - short type, short direction, double speed, unsigned name_id, @@ -55,7 +54,7 @@ struct InternalExtractorEdge bool is_access_restricted, TravelMode travel_mode, bool is_split) - : start(start), target(target), type(type), direction(direction), speed(speed), + : start(start), target(target), direction(direction), speed(speed), name_id(name_id), is_roundabout(is_roundabout), is_in_tiny_cc(is_in_tiny_cc), is_duration_set(is_duration_set), is_access_restricted(is_access_restricted), travel_mode(travel_mode), is_split(is_split) @@ -66,17 +65,16 @@ struct InternalExtractorEdge // necessary static util functions for stxxl's sorting static InternalExtractorEdge min_value() { - return InternalExtractorEdge(0, 0, 0, 0, 0, 0, false, false, false, false, TRAVEL_MODE_INACCESSIBLE, false); + return InternalExtractorEdge(0, 0, 0, 0, 0, false, false, false, false, TRAVEL_MODE_INACCESSIBLE, false); } static InternalExtractorEdge max_value() { return InternalExtractorEdge( - SPECIAL_NODEID, SPECIAL_NODEID, 0, 0, 0, 0, false, false, false, false, TRAVEL_MODE_INACCESSIBLE, false); + SPECIAL_NODEID, SPECIAL_NODEID, 0, 0, 0, false, false, false, false, TRAVEL_MODE_INACCESSIBLE, false); } NodeID start; NodeID target; - short type; short direction; double speed; unsigned name_id; diff --git a/Extractor/ScriptingEnvironment.cpp b/Extractor/ScriptingEnvironment.cpp index ed2075f98..b9fd608e1 100644 --- a/Extractor/ScriptingEnvironment.cpp +++ b/Extractor/ScriptingEnvironment.cpp @@ -79,7 +79,6 @@ void ScriptingEnvironment::initLuaState(lua_State* lua_state) .def_readwrite("forward_speed", &ExtractionWay::forward_speed) .def_readwrite("backward_speed", &ExtractionWay::backward_speed) .def_readwrite("duration", &ExtractionWay::duration) - .def_readwrite("type", &ExtractionWay::type) .def_readwrite("access", &ExtractionWay::access) .def_readwrite("roundabout", &ExtractionWay::roundabout) .def_readwrite("is_access_restricted", &ExtractionWay::isAccessRestricted) diff --git a/Util/GraphLoader.h b/Util/GraphLoader.h index 6a61676cb..bea08c0ea 100644 --- a/Util/GraphLoader.h +++ b/Util/GraphLoader.h @@ -138,7 +138,6 @@ NodeID readBinaryOSRMGraphFromStream(std::istream &input_stream, input_stream.read((char *)&length, sizeof(int)); input_stream.read((char *)&dir, sizeof(short)); input_stream.read((char *)&weight, sizeof(int)); - input_stream.read((char *)&type, sizeof(short)); input_stream.read((char *)&nameID, sizeof(unsigned)); input_stream.read((char *)&is_roundabout, sizeof(bool)); input_stream.read((char *)&ignore_in_grid, sizeof(bool)); @@ -316,7 +315,6 @@ NodeID readBinaryOSRMGraphFromStream(std::istream &input_stream, input_stream.read((char *)&length, sizeof(int)); input_stream.read((char *)&dir, sizeof(short)); input_stream.read((char *)&weight, sizeof(int)); - input_stream.read((char *)&type, sizeof(short)); input_stream.read((char *)&nameID, sizeof(unsigned)); input_stream.read((char *)&is_roundabout, sizeof(bool)); input_stream.read((char *)&ignore_in_grid, sizeof(bool)); diff --git a/profiles/bicycle.lua b/profiles/bicycle.lua index 09a234b5c..89513b033 100644 --- a/profiles/bicycle.lua +++ b/profiles/bicycle.lua @@ -373,8 +373,7 @@ function way_function (way) -- maxspeed MaxSpeed.limit( way, maxspeed, maxspeed_forward, maxspeed_backward ) - way.type = 1 - return 1 + return true end function turn_function (angle) diff --git a/profiles/car.lua b/profiles/car.lua index 990c38049..eead81b89 100755 --- a/profiles/car.lua +++ b/profiles/car.lua @@ -274,14 +274,13 @@ function way_function (way) if ignore_in_grid[highway] then way.ignore_in_grid = true end - way.type = 1 -- scale speeds to get better avg driving times way.forward_speed = way.forward_speed * speed_reduction if maxspeed_backward > 0 then way.backward_speed = way.backward_speed*speed_reduction end - return + return true end -- These are wrappers to parse vectors of nodes and ways and thus to speed up any tracing JIT diff --git a/profiles/foot.lua b/profiles/foot.lua index effd54e99..130d297a6 100644 --- a/profiles/foot.lua +++ b/profiles/foot.lua @@ -203,6 +203,5 @@ function way_function (way) end end - way.type = 1 - return 1 + return true end diff --git a/profiles/testbot.lua b/profiles/testbot.lua index 640c81651..a03ea41e3 100644 --- a/profiles/testbot.lua +++ b/profiles/testbot.lua @@ -119,6 +119,5 @@ function way_function (way) way.roundabout = true end - way.type = 1 - return 1 + return true end From 9c23fd4a31b55a8413fecbb70876e44bd584d92d Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Tue, 19 Aug 2014 16:29:28 +0200 Subject: [PATCH 38/49] remove accidentially added file --- Util/UUID.cpp | 109 -------------------------------------------------- 1 file changed, 109 deletions(-) delete mode 100644 Util/UUID.cpp diff --git a/Util/UUID.cpp b/Util/UUID.cpp deleted file mode 100644 index 3bdc0b096..000000000 --- a/Util/UUID.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* - -Copyright (c) 2013, Project OSRM, Dennis Luxen, others -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list -of conditions and the following disclaimer. -Redistributions in binary form must reproduce the above copyright notice, this -list of conditions and the following disclaimer in the documentation and/or -other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -#include "UUID.h" - -#include "OSRMException.h" -#include "../typedefs.h" - -#include // generators -#include // streaming operators etc. - -#include - -#include -#include -#include - -#define HAS64BITS 0 -#define MD5PREPARE "0942f9ef6f5912b4fbeae8249dd4df4b" -#define MD5RTREE "40c04fc573a4cea3832d0587908807c9" -#define MD5GRAPH "9f3a0e84509ff908655bbe2464d852b7" -#define MD5OBJECTS "7135d52fa59aa3f2babbb8f307d8dde3" - -UUID::UUID() : magic_number(1297240911) -{ - md5_prepare[32] = md5_tree[32] = md5_graph[32] = md5_objects[32] = '\0'; - - boost::uuids::name_generator gen(named_uuid); - std::string temp_string(__DATE__); - temp_string += __TIME__; - - std::copy(MD5PREPARE, MD5PREPARE + strlen(MD5PREPARE), md5_prepare); - temp_string += md5_prepare; - std::copy(MD5RTREE, MD5RTREE + 32, md5_tree); - temp_string += md5_tree; - std::copy(MD5GRAPH, MD5GRAPH + 32, md5_graph); - temp_string += md5_graph; - std::copy(MD5OBJECTS, MD5OBJECTS + 32, md5_objects); - temp_string += md5_objects; - - named_uuid = gen(temp_string); - has_64_bits = HAS64BITS; -} - -UUID::~UUID() {} - -const boost::uuids::uuid &UUID::GetUUID() const { return named_uuid; } - -bool UUID::IsMagicNumberOK() const { return 1297240911 == magic_number; } - -bool UUID::TestGraphUtil(const UUID &other) const -{ - if (!other.IsMagicNumberOK()) - { - throw OSRMException("hsgr input file misses magic number. Check or reprocess the file"); - } - return std::equal(md5_graph, md5_graph + 32, other.md5_graph); -} - -bool UUID::TestPrepare(const UUID &other) const -{ - if (!other.IsMagicNumberOK()) - { - throw OSRMException("osrm input file misses magic number. Check or reprocess the file"); - } - return std::equal(md5_prepare, md5_prepare + 32, other.md5_prepare); -} - -bool UUID::TestRTree(const UUID &other) const -{ - if (!other.IsMagicNumberOK()) - { - throw OSRMException("r-tree input file misses magic number. Check or reprocess the file"); - } - return std::equal(md5_tree, md5_tree + 32, other.md5_tree); -} - -bool UUID::TestQueryObjects(const UUID &other) const -{ - if (!other.IsMagicNumberOK()) - { - throw OSRMException("missing magic number. Check or reprocess the file"); - } - return std::equal(md5_objects, md5_objects + 32, other.md5_objects); -} From 60d80cf261827d357ff16639db593ac07322b7fe Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Tue, 19 Aug 2014 16:38:53 +0200 Subject: [PATCH 39/49] code style fixes --- Extractor/ExtractionWay.h | 12 ++++++------ Server/DataStructures/SharedDataFacade.h | 2 +- profiles/bicycle.lua | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Extractor/ExtractionWay.h b/Extractor/ExtractionWay.h index 43ba17503..6a3acc697 100644 --- a/Extractor/ExtractionWay.h +++ b/Extractor/ExtractionWay.h @@ -64,17 +64,17 @@ struct ExtractionWay inline void set_direction(const Directions m) { - if (Directions::oneway == m ) + if (Directions::oneway == m) { forward_travel_mode = TRAVEL_MODE_DEFAULT; backward_travel_mode = TRAVEL_MODE_INACCESSIBLE; } - else if (Directions::opposite == m ) + else if (Directions::opposite == m) { forward_travel_mode = TRAVEL_MODE_INACCESSIBLE; backward_travel_mode = TRAVEL_MODE_DEFAULT; } - else if (Directions::bidirectional == m ) + else if (Directions::bidirectional == m) { forward_travel_mode = TRAVEL_MODE_DEFAULT; backward_travel_mode = TRAVEL_MODE_DEFAULT; @@ -83,15 +83,15 @@ struct ExtractionWay inline const Directions get_direction() { - if (TRAVEL_MODE_INACCESSIBLE != forward_travel_mode && TRAVEL_MODE_INACCESSIBLE != backward_travel_mode ) + if (TRAVEL_MODE_INACCESSIBLE != forward_travel_mode && TRAVEL_MODE_INACCESSIBLE != backward_travel_mode) { return Directions::bidirectional; } - else if (TRAVEL_MODE_INACCESSIBLE != forward_travel_mode ) + else if (TRAVEL_MODE_INACCESSIBLE != forward_travel_mode) { return Directions::oneway; } - else if (TRAVEL_MODE_INACCESSIBLE != backward_travel_mode ) + else if (TRAVEL_MODE_INACCESSIBLE != backward_travel_mode) { return Directions::opposite; } diff --git a/Server/DataStructures/SharedDataFacade.h b/Server/DataStructures/SharedDataFacade.h index 7ce36f7ce..0688656d5 100644 --- a/Server/DataStructures/SharedDataFacade.h +++ b/Server/DataStructures/SharedDataFacade.h @@ -151,7 +151,7 @@ template class SharedDataFacade : public BaseDataFacadenum_entries[SharedDataLayout::TURN_INSTRUCTION]); m_turn_instruction_list.swap(turn_instruction_list); - + unsigned *name_id_list_ptr = data_layout->GetBlockPtr(shared_memory, SharedDataLayout::NAME_ID_LIST); typename ShM::vector name_id_list( diff --git a/profiles/bicycle.lua b/profiles/bicycle.lua index 89513b033..4c0c581c4 100644 --- a/profiles/bicycle.lua +++ b/profiles/bicycle.lua @@ -200,7 +200,7 @@ function way_function (way) local area = way.tags:Find("area") local foot = way.tags:Find("foot") local surface = way.tags:Find("surface") - local bicycle = way.tags:Find("bicycle") + local bicycle = way.tags:Find("bicycle") -- name if "" ~= ref and "" ~= name then From 6e2608b2f292cc6214892b8709748f0133a80681 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Tue, 19 Aug 2014 16:39:10 +0200 Subject: [PATCH 40/49] fix cuke support file --- features/step_definitions/routability.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/step_definitions/routability.rb b/features/step_definitions/routability.rb index 1881a5c19..48f7f24de 100644 --- a/features/step_definitions/routability.rb +++ b/features/step_definitions/routability.rb @@ -54,7 +54,7 @@ Then /^routability should be$/ do |table| want = shortcuts_hash[row[direction]] || row[direction] #expand shortcuts case want when '', 'x' - output_row[direction] = result[direction][:time] ? result[direction][:status].to_s : '' + output_row[direction] = result[direction][:status] ? result[direction][:status].to_s : '' when /^\d+s/ output_row[direction] = result[direction][:time] ? "#{result[direction][:time]}s" : '' when /^\d+ km\/h/ From 1e40cd6f0bc67f36752fe9e053c1ad716746e0e1 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Tue, 19 Aug 2014 16:41:41 +0200 Subject: [PATCH 41/49] remove type assertion --- Extractor/InternalExtractorEdge.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Extractor/InternalExtractorEdge.h b/Extractor/InternalExtractorEdge.h index b1dde2508..848b24fb3 100644 --- a/Extractor/InternalExtractorEdge.h +++ b/Extractor/InternalExtractorEdge.h @@ -59,7 +59,6 @@ struct InternalExtractorEdge is_duration_set(is_duration_set), is_access_restricted(is_access_restricted), travel_mode(travel_mode), is_split(is_split) { - BOOST_ASSERT(0 <= type); } // necessary static util functions for stxxl's sorting From 2e3d33dfcd7dae130591acbaf35eda0c34c6e3df Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Wed, 20 Aug 2014 07:54:39 +0200 Subject: [PATCH 42/49] remove type from more structs, remove asserts --- Contractor/EdgeBasedGraphFactory.cpp | 1 - DataStructures/ImportEdge.cpp | 4 +--- DataStructures/ImportEdge.h | 2 -- DataStructures/NodeBasedGraph.h | 4 +--- Extractor/ExtractionContainers.cpp | 1 - Util/GraphLoader.h | 7 ------- 6 files changed, 2 insertions(+), 17 deletions(-) diff --git a/Contractor/EdgeBasedGraphFactory.cpp b/Contractor/EdgeBasedGraphFactory.cpp index e54d10a52..6ac7ccd97 100644 --- a/Contractor/EdgeBasedGraphFactory.cpp +++ b/Contractor/EdgeBasedGraphFactory.cpp @@ -504,7 +504,6 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedNodes() } BOOST_ASSERT(u < v); - BOOST_ASSERT(edge_data.type != SHRT_MAX); // Note: edges that end on barrier nodes or on a turn restriction // may actually be in two distinct components. We choose the smallest diff --git a/DataStructures/ImportEdge.cpp b/DataStructures/ImportEdge.cpp index 8d4c9df07..b59d6149c 100644 --- a/DataStructures/ImportEdge.cpp +++ b/DataStructures/ImportEdge.cpp @@ -52,17 +52,15 @@ NodeBasedEdge::NodeBasedEdge(NodeID source, EdgeWeight weight, bool forward, bool backward, - short type, bool roundabout, bool in_tiny_cc, bool access_restricted, TravelMode travel_mode, bool is_split) - : source(source), target(target), name_id(name_id), weight(weight), type(type), + : source(source), target(target), name_id(name_id), weight(weight), forward(forward), backward(backward), roundabout(roundabout), in_tiny_cc(in_tiny_cc), access_restricted(access_restricted), is_split(is_split), travel_mode(travel_mode) { - BOOST_ASSERT_MSG(type > 0, "negative edge type"); } bool EdgeBasedEdge::operator<(const EdgeBasedEdge &other) const diff --git a/DataStructures/ImportEdge.h b/DataStructures/ImportEdge.h index a6945f237..4ccbee6d9 100644 --- a/DataStructures/ImportEdge.h +++ b/DataStructures/ImportEdge.h @@ -41,7 +41,6 @@ struct NodeBasedEdge EdgeWeight weight, bool forward, bool backward, - short type, bool roundabout, bool in_tiny_cc, bool access_restricted, @@ -52,7 +51,6 @@ struct NodeBasedEdge NodeID target; NodeID name_id; EdgeWeight weight; - short type; bool forward : 1; bool backward : 1; bool roundabout : 1; diff --git a/DataStructures/NodeBasedGraph.h b/DataStructures/NodeBasedGraph.h index a4d521411..14b5432d9 100644 --- a/DataStructures/NodeBasedGraph.h +++ b/DataStructures/NodeBasedGraph.h @@ -13,7 +13,7 @@ struct NodeBasedEdgeData { NodeBasedEdgeData() : distance(INVALID_EDGE_WEIGHT), edgeBasedNodeID(SPECIAL_NODEID), - nameID(std::numeric_limits::max()), type(std::numeric_limits::max()), + nameID(std::numeric_limits::max()), isAccessRestricted(false), shortcut(false), forward(false), backward(false), roundabout(false), ignore_in_grid(false), travel_mode(TRAVEL_MODE_INACCESSIBLE) { @@ -22,7 +22,6 @@ struct NodeBasedEdgeData int distance; unsigned edgeBasedNodeID; unsigned nameID; - short type; bool isAccessRestricted : 1; bool shortcut : 1; bool forward : 1; @@ -91,7 +90,6 @@ NodeBasedDynamicGraphFromImportEdges(int number_of_nodes, std::vectorsource_coordinate.lon != std::numeric_limits::min()) { BOOST_ASSERT(edge_iterator->speed != -1); - BOOST_ASSERT(edge_iterator->type >= 0); edge_iterator->target_coordinate.lat = node_iterator->lat; edge_iterator->target_coordinate.lon = node_iterator->lon; diff --git a/Util/GraphLoader.h b/Util/GraphLoader.h index bea08c0ea..c211a5bce 100644 --- a/Util/GraphLoader.h +++ b/Util/GraphLoader.h @@ -126,7 +126,6 @@ NodeID readBinaryOSRMGraphFromStream(std::istream &input_stream, edge_list.reserve(m); EdgeWeight weight; - short type; NodeID nameID; int length; bool is_roundabout, ignore_in_grid, is_access_restricted, is_split; @@ -160,8 +159,6 @@ NodeID readBinaryOSRMGraphFromStream(std::istream &input_stream, forward = false; } - BOOST_ASSERT(type >= 0); - // translate the external NodeIDs to internal IDs auto internal_id_iter = ext_to_int_id_map.find(source); if (ext_to_int_id_map.find(source) == ext_to_int_id_map.end()) @@ -195,7 +192,6 @@ NodeID readBinaryOSRMGraphFromStream(std::istream &input_stream, weight, forward, backward, - type, is_roundabout, ignore_in_grid, is_access_restricted, @@ -302,7 +298,6 @@ NodeID readBinaryOSRMGraphFromStream(std::istream &input_stream, edge_list.reserve(m); EdgeWeight weight; - short type; NodeID nameID; int length; bool is_roundabout, ignore_in_grid, is_access_restricted, is_split; @@ -326,8 +321,6 @@ NodeID readBinaryOSRMGraphFromStream(std::istream &input_stream, BOOST_ASSERT_MSG(weight > 0, "loaded null weight"); BOOST_ASSERT_MSG(0 <= dir && dir <= 2, "loaded bogus direction"); - BOOST_ASSERT(type >= 0); - // translate the external NodeIDs to internal IDs auto internal_id_iter = ext_to_int_id_map.find(source); if (ext_to_int_id_map.find(source) == ext_to_int_id_map.end()) From bcd55626efca835d3b2aa038daf1ec5d9eb29f64 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Wed, 20 Aug 2014 11:37:47 +0200 Subject: [PATCH 43/49] make accessors const, add comments --- DataStructures/TravelMode.h | 2 +- Extractor/ExtractionWay.h | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/DataStructures/TravelMode.h b/DataStructures/TravelMode.h index 0cead0d65..7ccc24d21 100644 --- a/DataStructures/TravelMode.h +++ b/DataStructures/TravelMode.h @@ -28,7 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef TRAVEL_MODE_H #define TRAVEL_MODE_H -typedef unsigned char TravelMode; +using TravelMode = unsigned char; static const TravelMode TRAVEL_MODE_INACCESSIBLE = 0; static const TravelMode TRAVEL_MODE_DEFAULT = 1; diff --git a/Extractor/ExtractionWay.h b/Extractor/ExtractionWay.h index 6a3acc697..36c138f89 100644 --- a/Extractor/ExtractionWay.h +++ b/Extractor/ExtractionWay.h @@ -62,6 +62,9 @@ struct ExtractionWay bidirectional, opposite }; + // These accessor methods exists to support the depreciated "way.direction" access + // in LUA. Since the direction attribute was removed from ExtractionWay, the + // accessors translate to/from the mode attributes. inline void set_direction(const Directions m) { if (Directions::oneway == m) @@ -81,7 +84,7 @@ struct ExtractionWay } } - inline const Directions get_direction() + inline const Directions get_direction() const { if (TRAVEL_MODE_INACCESSIBLE != forward_travel_mode && TRAVEL_MODE_INACCESSIBLE != backward_travel_mode) { @@ -101,10 +104,12 @@ struct ExtractionWay } } + // These accessors exists because it's not possible to take the address of a bitfield, + // and LUA therefore cannot read/write the mode attributes directly. inline void set_forward_mode(const TravelMode m) { forward_travel_mode = m; } - inline const TravelMode get_forward_mode() { return forward_travel_mode; } + inline const TravelMode get_forward_mode() const { return forward_travel_mode; } inline void set_backward_mode(const TravelMode m) { backward_travel_mode = m; } - inline const TravelMode get_backward_mode() { return backward_travel_mode; } + inline const TravelMode get_backward_mode() const { return backward_travel_mode; } unsigned id; unsigned nameID; From 00dd2463fd24f3a7b0de01ad063b251d5d3b91c8 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Wed, 20 Aug 2014 11:48:47 +0200 Subject: [PATCH 44/49] use lambda to decide turn value --- Descriptors/DescriptionFactory.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Descriptors/DescriptionFactory.cpp b/Descriptors/DescriptionFactory.cpp index 36e94c6a9..1c5f8628e 100644 --- a/Descriptors/DescriptionFactory.cpp +++ b/Descriptors/DescriptionFactory.cpp @@ -89,11 +89,19 @@ void DescriptionFactory::AppendSegment(const FixedPointCoordinate &coordinate, } // make sure mode changes are announced, even when there otherwise is no turn - const TurnInstruction turn = - (TurnInstruction::NoTurn == path_point.turn_instruction && - path_description.front().travel_mode != path_point.travel_mode && - path_point.segment_duration>0) ? TurnInstruction::GoStraight - : path_point.turn_instruction; + const TurnInstruction turn = [] -> TurnInstruction () + { + if (TurnInstruction::NoTurn == path_point.turn_instruction && + path_description.front().travel_mode != path_point.travel_mode && + path_point.segment_duration>0) + { + return TurnInstruction::GoStraight; + } + else + { + return path_point.turn_instruction + } + } path_description.emplace_back(coordinate, path_point.name_id, From 39d96a45aaa8b11fe5bb8b0776ac767968d8a102 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Wed, 20 Aug 2014 12:14:31 +0200 Subject: [PATCH 45/49] fix lambda syntax --- Descriptors/DescriptionFactory.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Descriptors/DescriptionFactory.cpp b/Descriptors/DescriptionFactory.cpp index 1c5f8628e..fa306eda1 100644 --- a/Descriptors/DescriptionFactory.cpp +++ b/Descriptors/DescriptionFactory.cpp @@ -89,7 +89,7 @@ void DescriptionFactory::AppendSegment(const FixedPointCoordinate &coordinate, } // make sure mode changes are announced, even when there otherwise is no turn - const TurnInstruction turn = [] -> TurnInstruction () + const TurnInstruction turn = [&]() -> TurnInstruction { if (TurnInstruction::NoTurn == path_point.turn_instruction && path_description.front().travel_mode != path_point.travel_mode && @@ -99,9 +99,9 @@ void DescriptionFactory::AppendSegment(const FixedPointCoordinate &coordinate, } else { - return path_point.turn_instruction - } - } + return path_point.turn_instruction; + } + }(); path_description.emplace_back(coordinate, path_point.name_id, From bb3cbf2dda5a5e490833bb1964b248adbd40f4e0 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Wed, 20 Aug 2014 14:01:40 +0200 Subject: [PATCH 46/49] fix indentation, remove superflous else clause --- Descriptors/DescriptionFactory.cpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/Descriptors/DescriptionFactory.cpp b/Descriptors/DescriptionFactory.cpp index fa306eda1..e8346fdcf 100644 --- a/Descriptors/DescriptionFactory.cpp +++ b/Descriptors/DescriptionFactory.cpp @@ -46,9 +46,10 @@ void DescriptionFactory::SetStartSegment(const PhantomNode &source, const bool t const EdgeWeight segment_duration = (traversed_in_reverse ? source.reverse_weight : source.forward_weight); const TravelMode travel_mode = - (traversed_in_reverse ? source.backward_travel_mode : source.forward_travel_mode); - AppendSegment(source.location, - PathData(0, source.name_id, TurnInstruction::HeadOn, segment_duration, travel_mode)); + (traversed_in_reverse ? source.backward_travel_mode : source.forward_travel_mode); + AppendSegment( + source.location, + PathData(0, source.name_id, TurnInstruction::HeadOn, segment_duration, travel_mode)); BOOST_ASSERT(path_description.back().duration == segment_duration); } @@ -60,7 +61,7 @@ void DescriptionFactory::SetEndSegment(const PhantomNode &target, const EdgeWeight segment_duration = (traversed_in_reverse ? target.reverse_weight : target.forward_weight); const TravelMode travel_mode = - (traversed_in_reverse ? target.backward_travel_mode : target.forward_travel_mode); + (traversed_in_reverse ? target.backward_travel_mode : target.forward_travel_mode); path_description.emplace_back(target.location, target.name_id, segment_duration, @@ -76,11 +77,11 @@ void DescriptionFactory::SetEndSegment(const PhantomNode &target, void DescriptionFactory::AppendSegment(const FixedPointCoordinate &coordinate, const PathData &path_point) { - //if the start location is on top of a node, the first movement might be zero-length, - //in which case we dont' add a new description, but instead update the existing one + // if the start location is on top of a node, the first movement might be zero-length, + // in which case we dont' add a new description, but instead update the existing one if ((1 == path_description.size()) && (path_description.front().location == coordinate)) { - if (path_point.segment_duration>0) + if (path_point.segment_duration > 0) { path_description.front().name_id = path_point.name_id; path_description.front().travel_mode = path_point.travel_mode; @@ -93,14 +94,11 @@ void DescriptionFactory::AppendSegment(const FixedPointCoordinate &coordinate, { if (TurnInstruction::NoTurn == path_point.turn_instruction && path_description.front().travel_mode != path_point.travel_mode && - path_point.segment_duration>0) + path_point.segment_duration > 0) { - return TurnInstruction::GoStraight; - } - else - { - return path_point.turn_instruction; + return TurnInstruction::GoStraight; } + return path_point.turn_instruction; }(); path_description.emplace_back(coordinate, From 774e6346e7dd1711de832a55b8fc74a764f9449f Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Wed, 20 Aug 2014 17:05:39 +0200 Subject: [PATCH 47/49] more robust check for parsed ways --- Extractor/ExtractorCallbacks.cpp | 6 +++++- profiles/bicycle.lua | 14 +++++++++----- profiles/car.lua | 7 +++++-- profiles/foot.lua | 26 +++++++++++++++----------- profiles/testbot.lua | 2 -- 5 files changed, 34 insertions(+), 21 deletions(-) diff --git a/Extractor/ExtractorCallbacks.cpp b/Extractor/ExtractorCallbacks.cpp index 33268a346..c2cc693c3 100644 --- a/Extractor/ExtractorCallbacks.cpp +++ b/Extractor/ExtractorCallbacks.cpp @@ -63,7 +63,11 @@ bool ExtractorCallbacks::ProcessRestriction(const InputRestrictionContainer &res /** warning: caller needs to take care of synchronization! */ void ExtractorCallbacks::ProcessWay(ExtractionWay &parsed_way) { - if ((0 >= parsed_way.forward_speed) && (0 >= parsed_way.duration)) + if (((0 >= parsed_way.forward_speed) || + (TRAVEL_MODE_INACCESSIBLE == parsed_way.forward_travel_mode)) && + ((0 >= parsed_way.backward_speed) || + (TRAVEL_MODE_INACCESSIBLE == parsed_way.backward_travel_mode)) && + (0 >= parsed_way.duration)) { // Only true if the way is specified by the speed profile return; } diff --git a/profiles/bicycle.lua b/profiles/bicycle.lua index 4c0c581c4..4f567edc9 100644 --- a/profiles/bicycle.lua +++ b/profiles/bicycle.lua @@ -168,18 +168,18 @@ function way_function (way) (not man_made or man_made=='') and (not public_transport or public_transport=='') then - return 0 + return end -- don't route on ways or railways that are still under construction if highway=='construction' or railway=='construction' then - return 0 + return end -- access local access = Access.find_access_tag(way, access_tags_hierachy) if access_tag_blacklist[access] then - return 0 + return end -- other tags @@ -267,15 +267,18 @@ function way_function (way) if pedestrian_speeds[highway] then -- pedestrian-only ways and areas way.forward_speed = pedestrian_speeds[highway] + way.backward_speed = pedestrian_speeds[highway] way.forward_mode = mode_pushing way.backward_mode = mode_pushing elseif man_made and man_made_speeds[man_made] then -- man made structures way.forward_speed = man_made_speeds[man_made] + way.backward_speed = man_made_speeds[man_made] way.forward_mode = mode_pushing way.backward_mode = mode_pushing elseif foot == 'yes' then way.forward_speed = walking_speed + way.backward_speed = walking_speed way.forward_mode = mode_pushing way.backward_mode = mode_pushing elseif foot_forward == 'yes' then @@ -308,6 +311,7 @@ function way_function (way) if impliedOneway then way.forward_mode = 0 way.backward_mode = mode_normal + way.backward_speed = bicycle_speeds["cycleway"] end elseif cycleway_left and cycleway_tags[cycleway_left] and cycleway_right and cycleway_tags[cycleway_right] then -- prevent implied @@ -315,10 +319,12 @@ function way_function (way) if impliedOneway then way.forward_mode = 0 way.backward_mode = mode_normal + way.backward_speed = bicycle_speeds["cycleway"] end elseif cycleway_right and cycleway_tags[cycleway_right] then if impliedOneway then way.forward_mode = mode_normal + way.backward_speed = bicycle_speeds["cycleway"] way.backward_mode = 0 end elseif oneway == "-1" then @@ -372,8 +378,6 @@ function way_function (way) -- maxspeed MaxSpeed.limit( way, maxspeed, maxspeed_forward, maxspeed_backward ) - - return true end function turn_function (angle) diff --git a/profiles/car.lua b/profiles/car.lua index eead81b89..0252b921c 100755 --- a/profiles/car.lua +++ b/profiles/car.lua @@ -192,23 +192,27 @@ function way_function (way) if highway_speed then if max_speed > highway_speed then way.forward_speed = max_speed + way.backward_speed = max_speed -- max_speed = math.huge else way.forward_speed = highway_speed + way.backward_speed = highway_speed end else -- Set the avg speed on ways that are marked accessible if access_tag_whitelist[access] then way.forward_speed = speed_profile["default"] + way.backward_speed = speed_profile["default"] end end if 0 == max_speed then max_speed = math.huge end way.forward_speed = min(way.forward_speed, max_speed) + way.backward_speed = min(way.backward_speed, max_speed) end - if -1 == way.forward_speed then + if -1 == way.forward_speed and -1 == way.backward_speed then return end @@ -280,7 +284,6 @@ function way_function (way) if maxspeed_backward > 0 then way.backward_speed = way.backward_speed*speed_reduction end - return true end -- These are wrappers to parse vectors of nodes and ways and thus to speed up any tracing JIT diff --git a/profiles/foot.lua b/profiles/foot.lua index 130d297a6..1e7cd4ba0 100644 --- a/profiles/foot.lua +++ b/profiles/foot.lua @@ -102,32 +102,32 @@ function node_function (node) end function way_function (way) - -- initial routability check, filters out buildings, boundaries, etc + -- initial routability check, filters out buildings, boundaries, etc local highway = way.tags:Find("highway") local route = way.tags:Find("route") local man_made = way.tags:Find("man_made") local railway = way.tags:Find("railway") local amenity = way.tags:Find("amenity") local public_transport = way.tags:Find("public_transport") - if (not highway or highway == '') and + if (not highway or highway == '') and (not route or route == '') and (not railway or railway=='') and (not amenity or amenity=='') and (not man_made or man_made=='') and - (not public_transport or public_transport=='') - then - return 0 + (not public_transport or public_transport=='') + then + return end -- don't route on ways that are still under construction if highway=='construction' then - return 0 + return end -- access local access = Access.find_access_tag(way, access_tags_hierachy) if access_tag_blacklist[access] then - return 0 + return end local name = way.tags:Find("name") @@ -164,25 +164,31 @@ function way_function (way) if durationIsValid(duration) then way.duration = math.max( 1, parseDuration(duration) ) else - way.forward_speed = route_speeds[route] + way.forward_speed = route_speeds[route] + way.backward_speed = route_speeds[route] end way.forward_mode = mode_ferry way.backward_mode = mode_ferry elseif railway and platform_speeds[railway] then -- railway platforms (old tagging scheme) way.forward_speed = platform_speeds[railway] + way.backward_speed = platform_speeds[railway] elseif platform_speeds[public_transport] then -- public_transport platforms (new tagging platform) way.forward_speed = platform_speeds[public_transport] + way.backward_speed = platform_speeds[public_transport] elseif amenity and amenity_speeds[amenity] then -- parking areas way.forward_speed = amenity_speeds[amenity] + way.backward_speed = amenity_speeds[amenity] elseif speeds[highway] then -- regular ways - way.forward_speed = speeds[highway] + way.forward_speed = speeds[highway] + way.backward_speed = speeds[highway] elseif access and access_tag_whitelist[access] then -- unknown way, but valid access tag way.forward_speed = walking_speed + way.backward_speed = walking_speed end -- oneway @@ -202,6 +208,4 @@ function way_function (way) way.backward_speed = math.min(way.backward_speed, surface_speed) end end - - return true end diff --git a/profiles/testbot.lua b/profiles/testbot.lua index a03ea41e3..a0b06f56d 100644 --- a/profiles/testbot.lua +++ b/profiles/testbot.lua @@ -118,6 +118,4 @@ function way_function (way) if junction == 'roundabout' then way.roundabout = true end - - return true end From 6a09ce1613179da9bec3c5c25782d5a74b216823 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Thu, 21 Aug 2014 12:17:03 +0200 Subject: [PATCH 48/49] fix comparison in car speed profile --- profiles/car.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/profiles/car.lua b/profiles/car.lua index 0252b921c..371740fe4 100755 --- a/profiles/car.lua +++ b/profiles/car.lua @@ -281,7 +281,7 @@ function way_function (way) -- scale speeds to get better avg driving times way.forward_speed = way.forward_speed * speed_reduction - if maxspeed_backward > 0 then + if way.backward_speed > 0 then way.backward_speed = way.backward_speed*speed_reduction end end From d7fbd416ba07efe3dd7643beb4ecf5c4c67e9a66 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Thu, 21 Aug 2014 12:18:19 +0200 Subject: [PATCH 49/49] fix expected values of backward speed in test --- features/car/maxspeed.feature | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/features/car/maxspeed.feature b/features/car/maxspeed.feature index 9e77cde74..7bb45809d 100644 --- a/features/car/maxspeed.feature +++ b/features/car/maxspeed.feature @@ -38,14 +38,14 @@ OSRM will use 4/5 of the projected free-flow speed. Given a grid size of 100 meters Then routability should be - | highway | maxspeed | maxspeed:forward | maxspeed:backward | forw | backw | - | primary | | | | 51 km/h | 51 km/h | - | primary | 60 | | | 48 km/h | 48 km/h | - | primary | | 60 | | 48 km/h | 65 km/h | - | primary | | | 60 | 51 km/h | 48 km/h | - | primary | 15 | 60 | | 48 km/h | 15 km/h +- 1 | - | primary | 15 | | 60 | 12 km/h +- 1| 48 km/h | - | primary | 15 | 30 | 60 | 24 km/h | 48 km/h | + | highway | maxspeed | maxspeed:forward | maxspeed:backward | forw | backw | + | primary | | | | 51 km/h | 51 km/h | + | primary | 60 | | | 48 km/h | 48 km/h | + | primary | | 60 | | 48 km/h | 51 km/h | + | primary | | | 60 | 51 km/h | 48 km/h | + | primary | 15 | 60 | | 48 km/h | 12 km/h | + | primary | 15 | | 60 | 12 km/h | 48 km/h | + | primary | 15 | 30 | 60 | 24 km/h | 48 km/h | Scenario: Car - Maxspeed should not allow routing on unroutable ways Then routability should be