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 Jan 23, 2018
1 parent e244072 commit dc23c1a
Show file tree
Hide file tree
Showing 7 changed files with 509 additions and 370 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/partition/*.cpp)
file(GLOB CustomizerGlob src/customize/*.cpp)
file(GLOB ContractorGlob src/contractor/*.cpp)
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
49 changes: 49 additions & 0 deletions include/guidance/guidance_processing.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#ifndef OSRM_GUIDANCE_GUIDANCE_RUNNER_HPP
#define OSRM_GUIDANCE_GUIDANCE_RUNNER_HPP

#include "guidance/turn_data_container.hpp"

#include "extractor/compressed_edge_container.hpp"
#include "extractor/node_data_container.hpp"
#include "extractor/suffix_table.hpp"
#include "extractor/turn_lane_types.hpp"
#include "extractor/way_restriction_map.hpp"

#include "util/coordinate.hpp"
#include "util/guidance/bearing_class.hpp"
#include "util/guidance/entry_class.hpp"
#include "util/guidance/turn_lanes.hpp"
#include "util/name_table.hpp"
#include "util/node_based_graph.hpp"

#include <unordered_set>

namespace osrm
{
namespace guidance
{
using BearingClassesVector = std::vector<BearingClassID>;
using BearingClassesMap = util::ConcurrentIDMap<util::guidance::BearingClass, BearingClassID>;
using EntryClassesMap = util::ConcurrentIDMap<util::guidance::EntryClass, EntryClassID>;

void processGuidanceTurns(const util::NodeBasedDynamicGraph &node_based_graph,
const extractor::EdgeBasedNodeDataContainer &edge_based_node_container,
const std::vector<util::Coordinate> &node_coordinates,
const extractor::CompressedEdgeContainer &compressed_edge_container,
const std::unordered_set<NodeID> &barrier_nodes,
const extractor::RestrictionMap &node_restriction_map,
const extractor::WayRestrictionMap &way_restriction_map,
const util::NameTable &name_table,
const extractor::SuffixTable &suffix_table,
const extractor::TurnLanesIndexedArray &turn_lanes_data,
extractor::LaneDescriptionMap &lane_description_map,
util::guidance::LaneDataIdMap &lane_data_map,
guidance::TurnDataExternalContainer &turn_data_container,
BearingClassesVector &bearing_class_by_node_based_node,
BearingClassesMap &bearing_class_hash,
EntryClassesMap &entry_class_hash);

} // namespace customizer
} // namespace osrm

#endif
Loading

0 comments on commit dc23c1a

Please sign in to comment.