From 1b31099f73077f2bff05137a4f5e130de45b9a44 Mon Sep 17 00:00:00 2001 From: Pepijn Schoen Date: Sat, 29 Apr 2017 13:34:33 +0200 Subject: [PATCH] superclass extractor_config with io_config --- CMakeLists.txt | 2 +- include/contractor/contractor_config.hpp | 2 +- include/extractor/extraction_containers.hpp | 4 +- include/extractor/extractor_config.hpp | 51 +++------------------ include/storage/io_config.hpp | 6 +++ src/extractor/extraction_containers.cpp | 4 +- src/extractor/extractor.cpp | 41 +++++++++-------- 7 files changed, 41 insertions(+), 69 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b11eb6737..6356f6057 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -738,7 +738,7 @@ file(GLOB LibraryGlob include/osrm/*.hpp) file(GLOB ParametersGlob include/engine/api/*_parameters.hpp) set(EngineHeader include/engine/status.hpp include/engine/engine_config.hpp include/engine/hint.hpp include/engine/bearing.hpp include/engine/approach.hpp include/engine/phantom_node.hpp) set(UtilHeader include/util/coordinate.hpp include/util/json_container.hpp include/util/typedefs.hpp include/util/alias.hpp include/util/exception.hpp) -set(ExtractorHeader include/extractor/extractor.hpp include/extractor/extractor_config.hpp include/extractor/travel_mode.hpp) +set(ExtractorHeader include/extractor/extractor.hpp include/storage/io_config.hpp include/extractor/extractor_config.hpp include/extractor/travel_mode.hpp) set(PartitionerHeader include/partition/partitioner.hpp include/partition/partition_config.hpp) set(ContractorHeader include/contractor/contractor.hpp include/contractor/contractor_config.hpp) set(StorageHeader include/storage/storage.hpp include/storage/io_config.hpp include/storage/storage_config.hpp) diff --git a/include/contractor/contractor_config.hpp b/include/contractor/contractor_config.hpp index a5bf5f657..6def873c9 100644 --- a/include/contractor/contractor_config.hpp +++ b/include/contractor/contractor_config.hpp @@ -28,7 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef CONTRACTOR_OPTIONS_HPP #define CONTRACTOR_OPTIONS_HPP -#include "storage/storage_config.hpp" +#include "storage/io_config.hpp" #include "updater/updater_config.hpp" #include diff --git a/include/extractor/extraction_containers.hpp b/include/extractor/extraction_containers.hpp index ec3682c72..38e06a179 100644 --- a/include/extractor/extraction_containers.hpp +++ b/include/extractor/extraction_containers.hpp @@ -57,9 +57,9 @@ class ExtractionContainers ExtractionContainers(); void PrepareData(ScriptingEnvironment &scripting_environment, - const std::string &output_file_name, + const std::string &osrm_input_path, const std::string &restrictions_file_name, - const std::string &names_file_name); + const std::string &names_data_path); }; } } diff --git a/include/extractor/extractor_config.hpp b/include/extractor/extractor_config.hpp index 793a5f33d..1581befe3 100644 --- a/include/extractor/extractor_config.hpp +++ b/include/extractor/extractor_config.hpp @@ -33,14 +33,17 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#include "storage/io_config.hpp" + namespace osrm { namespace extractor { -struct ExtractorConfig +struct ExtractorConfig final : storage::IOConfig { ExtractorConfig() noexcept : requested_num_threads(0) {} + void UseDefaultOutputNames() { std::string basepath = input_path.string(); @@ -58,58 +61,18 @@ struct ExtractorConfig } } - output_file_name = basepath + ".osrm"; - restriction_file_name = basepath + ".osrm.restrictions"; - names_file_name = basepath + ".osrm.names"; - turn_lane_descriptions_file_name = basepath + ".osrm.tls"; - turn_lane_data_file_name = basepath + ".osrm.tld"; - timestamp_file_name = basepath + ".osrm.timestamp"; - geometry_output_path = basepath + ".osrm.geometry"; - node_based_nodes_data_path = basepath + ".osrm.nbg_nodes"; - edge_based_nodes_data_path = basepath + ".osrm.ebg_nodes"; - edge_output_path = basepath + ".osrm.edges"; - edge_graph_output_path = basepath + ".osrm.ebg"; - rtree_nodes_output_path = basepath + ".osrm.ramIndex"; - rtree_leafs_output_path = basepath + ".osrm.fileIndex"; - turn_duration_penalties_path = basepath + ".osrm.turn_duration_penalties"; - turn_weight_penalties_path = basepath + ".osrm.turn_weight_penalties"; - turn_penalties_index_path = basepath + ".osrm.turn_penalties_index"; - edge_based_node_weights_output_path = basepath + ".osrm.enw"; - profile_properties_output_path = basepath + ".osrm.properties"; - intersection_class_data_output_path = basepath + ".osrm.icd"; - compressed_node_based_graph_output_path = basepath + ".osrm.cnbg"; - cnbg_ebg_graph_mapping_output_path = basepath + ".osrm.cnbg_to_ebg"; + osrm_input_path = basepath + ".osrm"; + + IOConfig::UseDefaultOutputNames(); } boost::filesystem::path input_path; boost::filesystem::path profile_path; - std::string output_file_name; - std::string restriction_file_name; - std::string names_file_name; - std::string turn_lane_data_file_name; - std::string turn_lane_descriptions_file_name; - std::string timestamp_file_name; - std::string geometry_output_path; - std::string edge_output_path; - std::string edge_graph_output_path; - std::string node_based_nodes_data_path; - std::string edge_based_nodes_data_path; - std::string edge_based_node_weights_output_path; - std::string rtree_nodes_output_path; - std::string rtree_leafs_output_path; - std::string profile_properties_output_path; - std::string intersection_class_data_output_path; - std::string turn_weight_penalties_path; - std::string turn_duration_penalties_path; - std::string compressed_node_based_graph_output_path; - std::string cnbg_ebg_graph_mapping_output_path; - unsigned requested_num_threads; unsigned small_component_size; bool generate_edge_lookup; - std::string turn_penalties_index_path; bool use_metadata; bool parse_conditionals; diff --git a/include/storage/io_config.hpp b/include/storage/io_config.hpp index db26df541..e83e98576 100644 --- a/include/storage/io_config.hpp +++ b/include/storage/io_config.hpp @@ -41,9 +41,12 @@ struct IOConfig mld_graph_path = {osrm_input_path.string() + ".mldgr"}; level_path = {osrm_input_path.string() + ".level"}; node_path = {osrm_input_path.string() + ".enw"}; + edge_based_nodes_data_path = {osrm_input_path.string() + ".nodes_data"}; edge_based_graph_path = {osrm_input_path.string() + ".ebg"}; compressed_node_based_graph_path = {osrm_input_path.string() + ".cnbg"}; cnbg_ebg_mapping_path = {osrm_input_path.string() + ".cnbg_to_ebg"}; + restriction_path = {osrm_input_path.string() + ".restrictions"}; + intersection_class_data_path = {osrm_input_path.string() + ".icd"}; } boost::filesystem::path osrm_input_path; @@ -71,9 +74,12 @@ struct IOConfig boost::filesystem::path mld_graph_path; boost::filesystem::path level_path; boost::filesystem::path node_path; + boost::filesystem::path edge_based_nodes_data_path; boost::filesystem::path edge_based_graph_path; boost::filesystem::path compressed_node_based_graph_path; boost::filesystem::path cnbg_ebg_mapping_path; + boost::filesystem::path restriction_path; + boost::filesystem::path intersection_class_data_path; }; diff --git a/src/extractor/extraction_containers.cpp b/src/extractor/extraction_containers.cpp index 7c35824ad..83cf58fde 100644 --- a/src/extractor/extraction_containers.cpp +++ b/src/extractor/extraction_containers.cpp @@ -125,11 +125,11 @@ ExtractionContainers::ExtractionContainers() * */ void ExtractionContainers::PrepareData(ScriptingEnvironment &scripting_environment, - const std::string &output_file_name, + const std::string &osrm_input_path, const std::string &restrictions_file_name, const std::string &name_file_name) { - storage::io::FileWriter file_out(output_file_name, + storage::io::FileWriter file_out(osrm_input_path, storage::io::FileWriter::GenerateFingerprint); PrepareNodes(); diff --git a/src/extractor/extractor.cpp b/src/extractor/extractor.cpp index 80a01fb9b..86db43d58 100644 --- a/src/extractor/extractor.cpp +++ b/src/extractor/extractor.cpp @@ -239,10 +239,13 @@ Extractor::ParseOSMData(ScriptingEnvironment &scripting_environment, } util::Log() << "timestamp: " << timestamp; - storage::io::FileWriter timestamp_file(config.timestamp_file_name, - storage::io::FileWriter::GenerateFingerprint); + extraction_containers.PrepareData(scripting_environment, + config.osrm_input_path.string(), + config.restriction_path.string(), + config.names_data_path.string()); - timestamp_file.WriteFrom(timestamp.c_str(), timestamp.length()); + WriteProfileProperties(config.properties_path.string(), + scripting_environment.GetProfileProperties()); std::vector restrictions = scripting_environment.GetRestrictions(); // setup restriction parser @@ -411,7 +414,7 @@ Extractor::LoadNodeBasedGraph(std::unordered_set &barriers, std::vector &coordiantes, extractor::PackedOSMIDs &osm_node_ids) { - storage::io::FileReader file_reader(config.output_file_name, + storage::io::FileReader file_reader(config.osrm_input_path, storage::io::FileReader::VerifyFingerprint); auto barriers_iter = inserter(barriers, end(barriers)); @@ -428,7 +431,7 @@ Extractor::LoadNodeBasedGraph(std::unordered_set &barriers, if (edge_list.empty()) { - throw util::exception("Node-based-graph (" + config.output_file_name + + throw util::exception("Node-based-graph (" + config.osrm_input_path.string() + ") contains no edges." + SOURCE_REF); } @@ -466,7 +469,7 @@ Extractor::BuildEdgeExpandedGraph(ScriptingEnvironment &scripting_environment, *node_based_graph, compressed_edge_container); - util::NameTable name_table(config.names_file_name); + util::NameTable name_table(config.names_data_path.string()); EdgeBasedGraphFactory edge_based_graph_factory( node_based_graph, @@ -481,12 +484,12 @@ Extractor::BuildEdgeExpandedGraph(ScriptingEnvironment &scripting_environment, turn_lane_map); edge_based_graph_factory.Run(scripting_environment, - config.edge_output_path, - config.turn_lane_data_file_name, - config.turn_weight_penalties_path, - config.turn_duration_penalties_path, - config.turn_penalties_index_path, - config.cnbg_ebg_graph_mapping_output_path); + config.edges_data_path.string(), + config.turn_lane_data_path.string(), + config.turn_weight_penalties_path.string(), + config.turn_duration_penalties_path.string(), + config.turn_penalties_index_path.string(), + config.cnbg_ebg_mapping_path.string()); compressed_edge_container.PrintStatistics(); @@ -509,7 +512,7 @@ Extractor::BuildEdgeExpandedGraph(ScriptingEnvironment &scripting_environment, compressed_node_based_graph_writing = std::async(std::launch::async, [&] { WriteCompressedNodeBasedGraph( - config.compressed_node_based_graph_output_path, *node_based_graph, coordinates); + config.compressed_node_based_graph_path.string(), *node_based_graph, coordinates); }); { @@ -518,9 +521,9 @@ Extractor::BuildEdgeExpandedGraph(ScriptingEnvironment &scripting_environment, std::tie(turn_lane_offsets, turn_lane_masks) = guidance::transformTurnLaneMapIntoArrays(turn_lane_map); files::writeTurnLaneDescriptions( - config.turn_lane_descriptions_file_name, turn_lane_offsets, turn_lane_masks); + config.turn_lane_description_path, turn_lane_offsets, turn_lane_masks); } - files::writeSegmentData(config.geometry_output_path, + files::writeSegmentData(config.geometries_path, *compressed_edge_container.ToSegmentData()); edge_based_graph_factory.GetEdgeBasedEdges(edge_based_edge_list); @@ -582,10 +585,10 @@ void Extractor::BuildRTree(std::vector edge_based_node_seg edge_based_node_segments.resize(new_size); TIMER_START(construction); - util::StaticRTree rtree(edge_based_node_segments, - config.rtree_nodes_output_path, - config.rtree_leafs_output_path, - coordinates); + util::StaticRTree rtree(edge_based_node_segments, + config.ram_index_path.string(), + config.file_index_path.string(), + coordinates); TIMER_STOP(construction); util::Log() << "finished r-tree construction in " << TIMER_SEC(construction) << " seconds";