From 2cd4ba9a0abb677c68feee3f55e2399f5eefe9e0 Mon Sep 17 00:00:00 2001 From: Michael Krasnyk Date: Wed, 29 Mar 2017 23:48:57 +0200 Subject: [PATCH] move split_edges to global properties --- CHANGELOG.md | 2 +- docs/profiles.md | 2 +- include/extractor/extraction_way.hpp | 2 -- include/extractor/extractor_callbacks.hpp | 1 + include/extractor/profile_properties.hpp | 1 + profiles/rasterbot.lua | 3 ++- src/extractor/extractor_callbacks.cpp | 6 ++++-- src/extractor/scripting_environment_lua.cpp | 9 ++++----- 8 files changed, 14 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ce0436781..7f88c5222 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ - .osrm.edge_lookup was removed. The option `--generate-edge-lookup` does nothing now. - `osrm-contract` does not depend on the `.osrm.fileIndex` file anymore - Profiles - - Added `split_edges` flag in extracted ways. True value guarantees that segment_function will be called for all segments, but also could double memory consumption + - Added `force_split_edges` flag to global properties. True value guarantees that segment_function will be called for all segments, but also could double memory consumption # 5.6.3 - Changes from 5.6.0 diff --git a/docs/profiles.md b/docs/profiles.md index 6ad343fa6..9f884af17 100644 --- a/docs/profiles.md +++ b/docs/profiles.md @@ -36,6 +36,7 @@ use_turn_restrictions | Boolean | Are turn instructions followed? continue_straight_at_waypoint | Boolean | Must the route continue straight on at a via point, or are U-turns allowed? max_speed_for_map_matching | Float | Maximum vehicle speed to be assumed in matching (in m/s) max_turn_weight | Float | Maximum turn penalty weight +force_split_edges | Boolean | True value forces a split of forward and backward edges of extracted ways and guarantees that segment_function will be called for all segments ## way_function @@ -64,7 +65,6 @@ backward_restricted | Boolean | " " is_startpoint | Boolean | Can a journey start on this way? (e.g. ferry; if false, prevents snapping the start point to this way) roundabout | Boolean | Is this part of a roundabout? circular | Boolean | Is this part of a non-roundabout circular junction? -split_edges | Boolean | True value forces a split of forward and backward edges of the way and guarantees that segment_function will be called for all segments name | String | Name of the way ref | String | Road number pronunciation | String | Name pronunciation diff --git a/include/extractor/extraction_way.hpp b/include/extractor/extraction_way.hpp index 68e2078bf..1783f539b 100644 --- a/include/extractor/extraction_way.hpp +++ b/include/extractor/extraction_way.hpp @@ -60,7 +60,6 @@ struct ExtractionWay road_classification = guidance::RoadClassification(); backward_restricted = false; forward_restricted = false; - split_edges = false; } // wrappers to allow assigning nil (nullptr) to string values @@ -107,7 +106,6 @@ struct ExtractionWay bool is_startpoint : 1; bool forward_restricted : 1; bool backward_restricted : 1; - bool split_edges : 1; }; } } diff --git a/include/extractor/extractor_callbacks.hpp b/include/extractor/extractor_callbacks.hpp index 7577ca8e3..73c09c398 100644 --- a/include/extractor/extractor_callbacks.hpp +++ b/include/extractor/extractor_callbacks.hpp @@ -63,6 +63,7 @@ class ExtractorCallbacks guidance::LaneDescriptionMap lane_description_map; ExtractionContainers &external_memory; bool fallback_to_duration; + bool force_split_edges; public: explicit ExtractorCallbacks(ExtractionContainers &extraction_containers, diff --git a/include/extractor/profile_properties.hpp b/include/extractor/profile_properties.hpp index 61d3db0b2..43871c53e 100644 --- a/include/extractor/profile_properties.hpp +++ b/include/extractor/profile_properties.hpp @@ -87,6 +87,7 @@ struct ProfileProperties //! stores the name of the weight (e.g. 'duration', 'distance', 'safety') char weight_name[MAX_WEIGHT_NAME_LENGTH + 1]; unsigned weight_precision = 1; + bool force_split_edges = false; }; } } diff --git a/profiles/rasterbot.lua b/profiles/rasterbot.lua index fce144637..bf8c2369e 100644 --- a/profiles/rasterbot.lua +++ b/profiles/rasterbot.lua @@ -1,6 +1,8 @@ api_version = 1 -- Rasterbot profile +properties.force_split_edges = true + -- Minimalist node_ and way_functions in order to test source_ and segment_functions function node_function (node, result) @@ -19,7 +21,6 @@ function way_function (way, result) result.forward_speed = 15 result.backward_speed = 15 - result.split_edges = true end function source_function () diff --git a/src/extractor/extractor_callbacks.cpp b/src/extractor/extractor_callbacks.cpp index c2e9257f8..93f0bac7e 100644 --- a/src/extractor/extractor_callbacks.cpp +++ b/src/extractor/extractor_callbacks.cpp @@ -35,7 +35,9 @@ namespace TurnLaneType = guidance::TurnLaneType; ExtractorCallbacks::ExtractorCallbacks(ExtractionContainers &extraction_containers_, const ProfileProperties &properties) - : external_memory(extraction_containers_), fallback_to_duration(properties.fallback_to_duration) + : external_memory(extraction_containers_), + fallback_to_duration(properties.fallback_to_duration), + force_split_edges(properties.force_split_edges) { // we reserved 0, 1, 2, 3 for the empty case string_map[MapKey("", "", "", "")] = 0; @@ -325,7 +327,7 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti // split an edge into two edges if forwards/backwards behavior differ const bool split_edge = in_forward_direction && in_backward_direction && - (parsed_way.split_edges || (parsed_way.forward_rate != parsed_way.backward_rate) || + (force_split_edges || (parsed_way.forward_rate != parsed_way.backward_rate) || (parsed_way.forward_speed != parsed_way.backward_speed) || (parsed_way.forward_travel_mode != parsed_way.backward_travel_mode) || (turn_lane_id_forward != turn_lane_id_backward)); diff --git a/src/extractor/scripting_environment_lua.cpp b/src/extractor/scripting_environment_lua.cpp index 4473eddbf..73ee74a11 100644 --- a/src/extractor/scripting_environment_lua.cpp +++ b/src/extractor/scripting_environment_lua.cpp @@ -247,7 +247,9 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context) "weight_name", sol::property(&ProfileProperties::SetWeightName, &ProfileProperties::GetWeightName), "max_turn_weight", - sol::property(&ProfileProperties::GetMaxTurnWeight)); + sol::property(&ProfileProperties::GetMaxTurnWeight), + "force_split_edges", + &ProfileProperties::force_split_edges); context.state.new_usertype>( "vector", @@ -356,10 +358,7 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context) [](ExtractionWay &way, bool flag) { way.forward_restricted = flag; }), "backward_restricted", sol::property([](const ExtractionWay &way) { return way.backward_restricted; }, - [](ExtractionWay &way, bool flag) { way.backward_restricted = flag; }), - "split_edges", - sol::property([](const ExtractionWay &way) { return way.split_edges; }, - [](ExtractionWay &way, bool flag) { way.split_edges = flag; })); + [](ExtractionWay &way, bool flag) { way.backward_restricted = flag; })); context.state.new_usertype("ExtractionSegment", "source",