superclass extractor_config with io_config

This commit is contained in:
Pepijn Schoen 2017-04-29 13:34:33 +02:00 committed by Daniel J. H
parent 897518a297
commit 1b31099f73
7 changed files with 41 additions and 69 deletions

View File

@ -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)

View File

@ -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 <boost/filesystem/path.hpp>

View File

@ -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);
};
}
}

View File

@ -33,14 +33,17 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <array>
#include <string>
#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;

View File

@ -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;
};

View File

@ -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();

View File

@ -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<std::string> restrictions = scripting_environment.GetRestrictions();
// setup restriction parser
@ -411,7 +414,7 @@ Extractor::LoadNodeBasedGraph(std::unordered_set<NodeID> &barriers,
std::vector<util::Coordinate> &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<NodeID> &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<EdgeBasedNodeSegment> edge_based_node_seg
edge_based_node_segments.resize(new_size);
TIMER_START(construction);
util::StaticRTree<EdgeBasedNodeSegment> rtree(edge_based_node_segments,
config.rtree_nodes_output_path,
config.rtree_leafs_output_path,
coordinates);
util::StaticRTree<EdgeBasedNode> 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";