Skip to content

Commit

Permalink
refactor restriction parsing / extraction to actual types
Browse files Browse the repository at this point in the history
Makes turn restrictions into dedicated structures and diferentiates between them via a variant.
Ensures that we do not accidentally mess up ID types within our application.
In addition this improves the restriction performance by only parsing all edges
once at the cost of (at the time of writing) 22MB in terms of main memory usage.
  • Loading branch information
Moritz Kobitzsch committed Jul 7, 2017
1 parent 71a34a3 commit 9dc3c15
Show file tree
Hide file tree
Showing 15 changed files with 666 additions and 408 deletions.
12 changes: 7 additions & 5 deletions include/extractor/extraction_containers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#include "extractor/external_memory_node.hpp"
#include "extractor/first_and_last_segment_of_way.hpp"
#include "extractor/guidance/turn_lane_types.hpp"
#include "extractor/internal_extractor_edge.hpp"
#include "extractor/restriction.hpp"
#include "extractor/scripting_environment.hpp"
Expand Down Expand Up @@ -40,15 +39,14 @@ class ExtractionContainers
void PrepareEdges(ScriptingEnvironment &scripting_environment);

void WriteNodes(storage::io::FileWriter &file_out) const;
void WriteRestrictions(const std::string &restrictions_file_name);
void WriteConditionalRestrictions(const std::string &restrictions_file_name);
void WriteEdges(storage::io::FileWriter &file_out) const;
void WriteCharData(const std::string &file_name);

public:
using STXXLNodeIDVector = stxxl::vector<OSMNodeID>;
using STXXLNodeVector = stxxl::vector<ExternalMemoryNode>;
using STXXLEdgeVector = stxxl::vector<InternalExtractorEdge>;
using RestrictionsVector = std::vector<InputRestrictionContainer>;
using STXXLWayIDStartEndVector = stxxl::vector<FirstAndLastSegmentOfWay>;
using STXXLNameCharData = stxxl::vector<unsigned char>;
using STXXLNameOffsets = stxxl::vector<unsigned>;
Expand All @@ -58,11 +56,15 @@ class ExtractionContainers
STXXLEdgeVector all_edges_list;
STXXLNameCharData name_char_data;
STXXLNameOffsets name_offsets;
// an adjacency array containing all turn lane masks
RestrictionsVector restrictions_list;
STXXLWayIDStartEndVector way_start_end_id_list;
std::unordered_map<OSMNodeID, NodeID> external_to_internal_node_id_map;
unsigned max_internal_node_id;

// list of restrictions before we transform them into the output types
std::vector<InputConditionalTurnRestriction> restrictions_list;

// turn restrictions split into conditional and unconditional turn restrictions
std::vector<ConditionalTurnRestriction> conditional_turn_restrictions;
std::vector<TurnRestriction> unconditional_turn_restrictions;

ExtractionContainers();
Expand Down
4 changes: 2 additions & 2 deletions include/extractor/extractor_callbacks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ namespace extractor
{

class ExtractionContainers;
struct InputRestrictionContainer;
struct ExtractionNode;
struct ExtractionWay;
struct ProfileProperties;
struct InputConditionalTurnRestriction;

/**
* This class is used by the extractor with the results of the
Expand Down Expand Up @@ -77,7 +77,7 @@ class ExtractorCallbacks
void ProcessNode(const osmium::Node &current_node, const ExtractionNode &result_node);

// warning: caller needs to take care of synchronization!
void ProcessRestriction(const boost::optional<InputRestrictionContainer> &restriction);
void ProcessRestriction(const InputConditionalTurnRestriction &restriction);

// warning: caller needs to take care of synchronization!
void ProcessWay(const osmium::Way &current_way, const ExtractionWay &result_way);
Expand Down
Loading

0 comments on commit 9dc3c15

Please sign in to comment.