From 6fd615b9cd8d2f46e305915a2de9a4946884c673 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Sat, 9 Aug 2014 15:13:04 +0200 Subject: [PATCH] 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