Skip to content

Commit

Permalink
Move guidance turn generation out of EBGF
Browse files Browse the repository at this point in the history
  • Loading branch information
oxidase committed Feb 2, 2018
1 parent 4747a7e commit 3d4b694
Show file tree
Hide file tree
Showing 29 changed files with 630 additions and 628 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ configure_file(
)
file(GLOB UtilGlob src/util/*.cpp src/util/*/*.cpp)
file(GLOB ExtractorGlob src/extractor/*.cpp src/extractor/*/*.cpp)
file(GLOB GuidanceGlob src/guidance/*.cpp)
file(GLOB GuidanceGlob src/guidance/*.cpp src/extractor/intersection/*.cpp)
file(GLOB PartitionerGlob src/partitioner/*.cpp)
file(GLOB CustomizerGlob src/customize/*.cpp)
file(GLOB ContractorGlob src/contractor/*.cpp)
Expand Down
5 changes: 3 additions & 2 deletions features/support/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ module.exports = function() {
// shorten uri to be realtive to 'features/'
let featurePath = path.relative(path.resolve('./features'), uri);
// bicycle/bollards/{HASH}/
let featureID = path.join(featurePath, hash);
let featureID = path.join(featurePath, hash);

let featureCacheDirectory = this.getFeatureCacheDirectory(featureID);
let featureProcessedCacheDirectory = this.getFeatureProcessedCacheDirectory(featureCacheDirectory, this.osrmHash);
this.featureIDs[uri] = featureID;
Expand Down Expand Up @@ -115,6 +115,7 @@ module.exports = function() {
this.OSRM_EXTRACT_PATH,
this.OSRM_CONTRACT_PATH,
this.LIB_OSRM_EXTRACT_PATH,
this.LIB_OSRM_GUIDANCE_PATH,
this.LIB_OSRM_CONTRACT_PATH
];

Expand Down
3 changes: 2 additions & 1 deletion features/support/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module.exports = function () {

this.OSRM_PORT = process.env.OSRM_PORT && parseInt(process.env.OSRM_PORT) || 5000;
this.HOST = 'http://127.0.0.1:' + this.OSRM_PORT;

this.OSRM_PROFILE = process.env.OSRM_PROFILE;

if (this.PLATFORM_WINDOWS) {
Expand Down Expand Up @@ -72,6 +72,7 @@ module.exports = function () {
this.OSRM_CONTRACT_PATH = path.resolve(util.format('%s/%s%s', this.BIN_PATH, 'osrm-contract', this.EXE));
this.OSRM_ROUTED_PATH = path.resolve(util.format('%s/%s%s', this.BIN_PATH, 'osrm-routed', this.EXE));
this.LIB_OSRM_EXTRACT_PATH = util.format('%s/' + this.LIB, this.BIN_PATH, 'osrm_extract'),
this.LIB_OSRM_GUIDANCE_PATH = util.format('%s/' + this.LIB, this.BIN_PATH, 'osrm_guidance'),
this.LIB_OSRM_CONTRACT_PATH = util.format('%s/' + this.LIB, this.BIN_PATH, 'osrm_contract'),
this.LIB_OSRM_PATH = util.format('%s/' + this.LIB, this.BIN_PATH, 'osrm');

Expand Down
15 changes: 8 additions & 7 deletions include/engine/datafacade/contiguous_internalmem_datafacade.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include "extractor/profile_properties.hpp"
#include "extractor/segment_data_container.hpp"
#include "extractor/turn_lane_types.hpp"

#include "guidance/turn_bearing.hpp"
#include "guidance/turn_data_container.hpp"
#include "guidance/turn_instruction.hpp"

Expand All @@ -35,7 +37,6 @@
#include "util/filtered_graph.hpp"
#include "util/guidance/bearing_class.hpp"
#include "util/guidance/entry_class.hpp"
#include "util/guidance/turn_bearing.hpp"
#include "util/guidance/turn_lanes.hpp"
#include "util/log.hpp"
#include "util/name_table.hpp"
Expand Down Expand Up @@ -328,14 +329,14 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
util::vector_view<EntryClassID> entry_class_ids(
entry_class_id_list_ptr, layout.num_entries[storage::DataLayout::ENTRY_CLASSID]);

const auto pre_turn_bearing_ptr = layout.GetBlockPtr<util::guidance::TurnBearing>(
const auto pre_turn_bearing_ptr = layout.GetBlockPtr<guidance::TurnBearing>(
memory_ptr, storage::DataLayout::PRE_TURN_BEARING);
util::vector_view<util::guidance::TurnBearing> pre_turn_bearings(
util::vector_view<guidance::TurnBearing> pre_turn_bearings(
pre_turn_bearing_ptr, layout.num_entries[storage::DataLayout::PRE_TURN_BEARING]);

const auto post_turn_bearing_ptr = layout.GetBlockPtr<util::guidance::TurnBearing>(
const auto post_turn_bearing_ptr = layout.GetBlockPtr<guidance::TurnBearing>(
memory_ptr, storage::DataLayout::POST_TURN_BEARING);
util::vector_view<util::guidance::TurnBearing> post_turn_bearings(
util::vector_view<guidance::TurnBearing> post_turn_bearings(
post_turn_bearing_ptr, layout.num_entries[storage::DataLayout::POST_TURN_BEARING]);

turn_data = guidance::TurnDataView(std::move(turn_instructions),
Expand Down Expand Up @@ -844,11 +845,11 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
return intersection_bearings_view.GetBearingClass(node);
}

util::guidance::TurnBearing PreTurnBearing(const EdgeID eid) const override final
guidance::TurnBearing PreTurnBearing(const EdgeID eid) const override final
{
return turn_data.GetPreTurnBearing(eid);
}
util::guidance::TurnBearing PostTurnBearing(const EdgeID eid) const override final
guidance::TurnBearing PostTurnBearing(const EdgeID eid) const override final
{
return turn_data.GetPostTurnBearing(eid);
}
Expand Down
7 changes: 4 additions & 3 deletions include/engine/datafacade/datafacade_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
#include "extractor/query_node.hpp"
#include "extractor/travel_mode.hpp"
#include "extractor/turn_lane_types.hpp"

#include "guidance/turn_bearing.hpp"
#include "guidance/turn_instruction.hpp"

#include "util/exception.hpp"
#include "util/guidance/bearing_class.hpp"
#include "util/guidance/entry_class.hpp"
#include "util/guidance/turn_bearing.hpp"
#include "util/guidance/turn_lanes.hpp"
#include "util/integer_range.hpp"
#include "util/string_util.hpp"
Expand Down Expand Up @@ -181,8 +182,8 @@ class BaseDataFacade

virtual double GetWeightMultiplier() const = 0;

virtual util::guidance::TurnBearing PreTurnBearing(const EdgeID eid) const = 0;
virtual util::guidance::TurnBearing PostTurnBearing(const EdgeID eid) const = 0;
virtual osrm::guidance::TurnBearing PreTurnBearing(const EdgeID eid) const = 0;
virtual osrm::guidance::TurnBearing PostTurnBearing(const EdgeID eid) const = 0;

virtual util::guidance::BearingClass GetBearingClass(const NodeID node) const = 0;

Expand Down
7 changes: 4 additions & 3 deletions include/engine/internal_route_result.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@

#include "extractor/class_data.hpp"
#include "extractor/travel_mode.hpp"

#include "guidance/turn_bearing.hpp"
#include "guidance/turn_instruction.hpp"

#include "engine/phantom_node.hpp"

#include "util/coordinate.hpp"
#include "util/guidance/entry_class.hpp"
#include "util/guidance/turn_bearing.hpp"
#include "util/guidance/turn_lanes.hpp"
#include "util/integer_range.hpp"
#include "util/typedefs.hpp"
Expand Down Expand Up @@ -56,9 +57,9 @@ struct PathData
DatasourceID datasource_id;

// bearing (as seen from the intersection) pre-turn
util::guidance::TurnBearing pre_turn_bearing;
osrm::guidance::TurnBearing pre_turn_bearing;
// bearing (as seen from the intersection) post-turn
util::guidance::TurnBearing post_turn_bearing;
osrm::guidance::TurnBearing post_turn_bearing;

// Driving side of the turn
bool is_left_hand_driving;
Expand Down
10 changes: 5 additions & 5 deletions include/engine/routing_algorithms/routing_base.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef OSRM_ENGINE_ROUTING_BASE_HPP
#define OSRM_ENGINE_ROUTING_BASE_HPP

#include "guidance/turn_bearing.hpp"
#include "guidance/turn_instruction.hpp"

#include "engine/algorithm.hpp"
Expand All @@ -10,7 +11,6 @@
#include "engine/search_engine_data.hpp"

#include "util/coordinate_calculation.hpp"
#include "util/guidance/turn_bearing.hpp"
#include "util/typedefs.hpp"

#include <boost/assert.hpp>
Expand Down Expand Up @@ -205,8 +205,8 @@ void annotatePath(const FacadeT &facade,
classes,
EMPTY_ENTRY_CLASS,
datasource_vector[segment_idx],
util::guidance::TurnBearing(0),
util::guidance::TurnBearing(0),
osrm::guidance::TurnBearing(0),
osrm::guidance::TurnBearing(0),
is_left_hand_driving});
}
BOOST_ASSERT(unpacked_path.size() > 0);
Expand Down Expand Up @@ -279,8 +279,8 @@ void annotatePath(const FacadeT &facade,
facade.GetClassData(target_node_id),
EMPTY_ENTRY_CLASS,
datasource_vector[segment_idx],
util::guidance::TurnBearing(0),
util::guidance::TurnBearing(0),
guidance::TurnBearing(0),
guidance::TurnBearing(0),
is_target_left_hand_driving});
}

Expand Down
21 changes: 2 additions & 19 deletions include/extractor/edge_based_graph_factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,9 @@ class EdgeBasedGraphFactory
const std::vector<util::Coordinate> &coordinates,
const util::NameTable &name_table,
const std::unordered_set<EdgeID> &segregated_edges,
LaneDescriptionMap &lane_description_map);
const LaneDescriptionMap &lane_description_map);

void Run(ScriptingEnvironment &scripting_environment,
const std::string &turn_data_filename,
const std::string &turn_lane_data_filename,
const std::string &turn_weight_penalties_filename,
const std::string &turn_duration_penalties_filename,
const std::string &turn_penalties_index_filename,
Expand All @@ -95,12 +93,6 @@ class EdgeBasedGraphFactory
void GetStartPointMarkers(std::vector<bool> &node_is_startpoint);
void GetEdgeBasedNodeWeights(std::vector<EdgeWeight> &output_node_weights);

// These access functions don't destroy the content
const std::vector<BearingClassID> &GetBearingClassIds() const;
std::vector<BearingClassID> &GetBearingClassIds();
std::vector<util::guidance::BearingClass> GetBearingClasses() const;
std::vector<util::guidance::EntryClass> GetEntryClasses() const;

std::uint64_t GetNumberOfEdgeBasedNodes() const;

// Basic analysis of a turn (u --(e1)-- v --(e2)-- w)
Expand Down Expand Up @@ -158,7 +150,7 @@ class EdgeBasedGraphFactory

const util::NameTable &name_table;
const std::unordered_set<EdgeID> &segregated_edges;
LaneDescriptionMap &lane_description_map;
const LaneDescriptionMap &lane_description_map;

// In the edge based graph, any traversable (non reversed) edge of the node-based graph forms a
// node of the edge-based graph. To be able to name these nodes, we loop over the node-based
Expand All @@ -175,8 +167,6 @@ class EdgeBasedGraphFactory
// Edge-expanded edges are generate for all valid turns. The validity can be checked via the
// restriction maps
void GenerateEdgeExpandedEdges(ScriptingEnvironment &scripting_environment,
const std::string &original_edge_data_filename,
const std::string &turn_lane_data_filename,
const std::string &turn_weight_penalties_filename,
const std::string &turn_duration_penalties_filename,
const std::string &turn_penalties_index_filename,
Expand All @@ -187,15 +177,8 @@ class EdgeBasedGraphFactory

NBGToEBG InsertEdgeBasedNode(const NodeID u, const NodeID v);

std::size_t restricted_turns_counter;
std::size_t skipped_uturns_counter;
std::size_t skipped_barrier_turns_counter;

// mapping of node-based edges to edge-based nodes
std::vector<NodeID> nbe_to_ebn_mapping;
util::ConcurrentIDMap<util::guidance::BearingClass, BearingClassID> bearing_class_hash;
std::vector<BearingClassID> bearing_class_by_node_based_node;
util::ConcurrentIDMap<util::guidance::EntryClass, EntryClassID> entry_class_hash;
};
} // namespace extractor
} // namespace osrm
Expand Down
22 changes: 18 additions & 4 deletions include/extractor/extractor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "extractor/graph_compressor.hpp"
#include "extractor/packed_osm_ids.hpp"

#include "guidance/guidance_processing.hpp"
#include "guidance/turn_data_container.hpp"

#include "util/guidance/bearing_class.hpp"
#include "util/guidance/entry_class.hpp"
#include "util/guidance/turn_lanes.hpp"
Expand Down Expand Up @@ -72,17 +75,16 @@ class Extractor
const std::vector<TurnRestriction> &turn_restrictions,
const std::vector<ConditionalTurnRestriction> &conditional_turn_restrictions,
const std::unordered_set<EdgeID> &segregated_edges,
// might have to be updated to add new lane combinations
LaneDescriptionMap &turn_lane_map,
const util::NameTable &name_table,
const LaneDescriptionMap &turn_lane_map,
// for calculating turn penalties
ScriptingEnvironment &scripting_environment,
// output data
EdgeBasedNodeDataContainer &edge_based_nodes_container,
std::vector<EdgeBasedNodeSegment> &edge_based_node_segments,
std::vector<bool> &node_is_startpoint,
std::vector<EdgeWeight> &edge_based_node_weights,
util::DeallocatingVector<EdgeBasedEdge> &edge_based_edge_list,
const std::string &intersection_class_output_file);
util::DeallocatingVector<EdgeBasedEdge> &edge_based_edge_list);

void FindComponents(unsigned max_edge_id,
const util::DeallocatingVector<EdgeBasedEdge> &input_edge_list,
Expand All @@ -101,6 +103,18 @@ class Extractor
void WriteConditionalRestrictions(
const std::string &path,
std::vector<ConditionalTurnRestriction> &conditional_turn_restrictions);

void ProcessGuidanceTurns(
const util::NodeBasedDynamicGraph &node_based_graph,
const EdgeBasedNodeDataContainer &edge_based_node_container,
const std::vector<util::Coordinate> &node_coordinates,
const CompressedEdgeContainer &compressed_edge_container,
const std::unordered_set<NodeID> &barrier_nodes,
const std::vector<TurnRestriction> &turn_restrictions,
const std::vector<ConditionalTurnRestriction> &conditional_turn_restrictions,
const util::NameTable &name_table,
LaneDescriptionMap lane_description_map,
ScriptingEnvironment &scripting_environment);
};
}
}
Expand Down
2 changes: 1 addition & 1 deletion include/extractor/intersection/mergable_road_detector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class MergableRoadDetector
const static double constexpr distance_to_extract = 120;
};

} // namespace guidance
} // namespace intersection
} // namespace extractor
} // namespace osrm

Expand Down
2 changes: 1 addition & 1 deletion include/extractor/intersection/node_based_graph_walker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ struct DistanceToNextIntersectionAccumulator
double distance = 0.;
};

} // namespace guidance
} // namespace intersection
} // namespace extractor
} // namespace osrm

Expand Down
Loading

0 comments on commit 3d4b694

Please sign in to comment.