initial version of intersection classification
This commit is contained in:
committed by
Patrick Niklaus
parent
6aa97048df
commit
ba074b0116
+82
-37
@@ -1,24 +1,25 @@
|
||||
#include "extractor/original_edge_data.hpp"
|
||||
#include "util/range_table.hpp"
|
||||
#include "contractor/query_edge.hpp"
|
||||
#include "extractor/query_node.hpp"
|
||||
#include "extractor/profile_properties.hpp"
|
||||
#include "engine/datafacade/datafacade_base.hpp"
|
||||
#include "extractor/compressed_edge_container.hpp"
|
||||
#include "extractor/guidance/turn_instruction.hpp"
|
||||
#include "extractor/original_edge_data.hpp"
|
||||
#include "extractor/profile_properties.hpp"
|
||||
#include "extractor/query_node.hpp"
|
||||
#include "extractor/travel_mode.hpp"
|
||||
#include "storage/shared_barriers.hpp"
|
||||
#include "storage/shared_datatype.hpp"
|
||||
#include "storage/shared_memory.hpp"
|
||||
#include "storage/storage.hpp"
|
||||
#include "util/coordinate.hpp"
|
||||
#include "util/exception.hpp"
|
||||
#include "util/fingerprint.hpp"
|
||||
#include "util/io.hpp"
|
||||
#include "util/range_table.hpp"
|
||||
#include "util/shared_memory_vector_wrapper.hpp"
|
||||
#include "util/simple_logger.hpp"
|
||||
#include "util/static_graph.hpp"
|
||||
#include "util/static_rtree.hpp"
|
||||
#include "engine/datafacade/datafacade_base.hpp"
|
||||
#include "extractor/travel_mode.hpp"
|
||||
#include "extractor/guidance/turn_instruction.hpp"
|
||||
#include "storage/storage.hpp"
|
||||
#include "storage/shared_datatype.hpp"
|
||||
#include "storage/shared_barriers.hpp"
|
||||
#include "storage/shared_memory.hpp"
|
||||
#include "util/fingerprint.hpp"
|
||||
#include "util/exception.hpp"
|
||||
#include "util/simple_logger.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
#include "util/coordinate.hpp"
|
||||
|
||||
#ifdef __linux__
|
||||
#include <sys/mman.h>
|
||||
@@ -49,8 +50,7 @@ void deleteRegion(const SharedDataType region)
|
||||
{
|
||||
if (SharedMemory::RegionExists(region) && !SharedMemory::Remove(region))
|
||||
{
|
||||
const std::string name = [&]
|
||||
{
|
||||
const std::string name = [&] {
|
||||
switch (region)
|
||||
{
|
||||
case CURRENT_REGIONS:
|
||||
@@ -105,20 +105,14 @@ int Storage::Run()
|
||||
|
||||
// determine segment to use
|
||||
bool segment2_in_use = SharedMemory::RegionExists(LAYOUT_2);
|
||||
const storage::SharedDataType layout_region = [&]
|
||||
{
|
||||
const storage::SharedDataType layout_region = [&] {
|
||||
return segment2_in_use ? LAYOUT_1 : LAYOUT_2;
|
||||
}();
|
||||
const storage::SharedDataType data_region = [&]
|
||||
{
|
||||
return segment2_in_use ? DATA_1 : DATA_2;
|
||||
}();
|
||||
const storage::SharedDataType previous_layout_region = [&]
|
||||
{
|
||||
const storage::SharedDataType data_region = [&] { return segment2_in_use ? DATA_1 : DATA_2; }();
|
||||
const storage::SharedDataType previous_layout_region = [&] {
|
||||
return segment2_in_use ? LAYOUT_2 : LAYOUT_1;
|
||||
}();
|
||||
const storage::SharedDataType previous_data_region = [&]
|
||||
{
|
||||
const storage::SharedDataType previous_data_region = [&] {
|
||||
return segment2_in_use ? DATA_2 : DATA_1;
|
||||
}();
|
||||
|
||||
@@ -136,7 +130,8 @@ int Storage::Run()
|
||||
boost::filesystem::ifstream name_stream(config.names_data_path, std::ios::binary);
|
||||
if (!name_stream)
|
||||
{
|
||||
throw util::exception("Could not open " + config.names_data_path.string() + " for reading.");
|
||||
throw util::exception("Could not open " + config.names_data_path.string() +
|
||||
" for reading.");
|
||||
}
|
||||
unsigned name_blocks = 0;
|
||||
name_stream.read((char *)&name_blocks, sizeof(unsigned));
|
||||
@@ -154,7 +149,8 @@ int Storage::Run()
|
||||
boost::filesystem::ifstream edges_input_stream(config.edges_data_path, std::ios::binary);
|
||||
if (!edges_input_stream)
|
||||
{
|
||||
throw util::exception("Could not open " + config.edges_data_path.string() + " for reading.");
|
||||
throw util::exception("Could not open " + config.edges_data_path.string() +
|
||||
" for reading.");
|
||||
}
|
||||
unsigned number_of_original_edges = 0;
|
||||
edges_input_stream.read((char *)&number_of_original_edges, sizeof(unsigned));
|
||||
@@ -168,6 +164,8 @@ int Storage::Run()
|
||||
number_of_original_edges);
|
||||
shared_layout_ptr->SetBlockSize<extractor::guidance::TurnInstruction>(
|
||||
SharedDataLayout::TURN_INSTRUCTION, number_of_original_edges);
|
||||
shared_layout_ptr->SetBlockSize<EntryClassID>(SharedDataLayout::ENTRY_CLASSID,
|
||||
number_of_original_edges);
|
||||
|
||||
boost::filesystem::ifstream hsgr_input_stream(config.hsgr_data_path, std::ios::binary);
|
||||
if (!hsgr_input_stream)
|
||||
@@ -250,7 +248,8 @@ int Storage::Run()
|
||||
boost::filesystem::ifstream geometry_input_stream(config.geometries_path, std::ios::binary);
|
||||
if (!geometry_input_stream)
|
||||
{
|
||||
throw util::exception("Could not open " + config.geometries_path.string() + " for reading.");
|
||||
throw util::exception("Could not open " + config.geometries_path.string() +
|
||||
" for reading.");
|
||||
}
|
||||
unsigned number_of_geometries_indices = 0;
|
||||
unsigned number_of_compressed_geometries = 0;
|
||||
@@ -270,7 +269,8 @@ int Storage::Run()
|
||||
std::ios::binary);
|
||||
if (!geometry_datasource_input_stream)
|
||||
{
|
||||
throw util::exception("Could not open " + config.datasource_indexes_path.string() + " for reading.");
|
||||
throw util::exception("Could not open " + config.datasource_indexes_path.string() +
|
||||
" for reading.");
|
||||
}
|
||||
std::size_t number_of_compressed_datasources = 0;
|
||||
if (geometry_datasource_input_stream)
|
||||
@@ -287,7 +287,8 @@ int Storage::Run()
|
||||
std::ios::binary);
|
||||
if (!datasource_names_input_stream)
|
||||
{
|
||||
throw util::exception("Could not open " + config.datasource_names_path.string() + " for reading.");
|
||||
throw util::exception("Could not open " + config.datasource_names_path.string() +
|
||||
" for reading.");
|
||||
}
|
||||
std::vector<char> m_datasource_name_data;
|
||||
std::vector<std::size_t> m_datasource_name_offsets;
|
||||
@@ -331,7 +332,8 @@ int Storage::Run()
|
||||
file_index_path_ptr +
|
||||
shared_layout_ptr->GetBlockSize(SharedDataLayout::FILE_INDEX_PATH),
|
||||
0);
|
||||
std::copy(absolute_file_index_path.string().begin(), absolute_file_index_path.string().end(), file_index_path_ptr);
|
||||
std::copy(absolute_file_index_path.string().begin(), absolute_file_index_path.string().end(),
|
||||
file_index_path_ptr);
|
||||
|
||||
// Loading street names
|
||||
unsigned *name_offsets_ptr = shared_layout_ptr->GetBlockPtr<unsigned, true>(
|
||||
@@ -382,6 +384,9 @@ int Storage::Run()
|
||||
shared_layout_ptr->GetBlockPtr<extractor::guidance::TurnInstruction, true>(
|
||||
shared_memory_ptr, SharedDataLayout::TURN_INSTRUCTION);
|
||||
|
||||
EntryClassID *entry_class_id_ptr = shared_layout_ptr->GetBlockPtr<EntryClassID, true>(
|
||||
shared_memory_ptr, SharedDataLayout::ENTRY_CLASSID);
|
||||
|
||||
extractor::OriginalEdgeData current_edge_data;
|
||||
for (unsigned i = 0; i < number_of_original_edges; ++i)
|
||||
{
|
||||
@@ -390,6 +395,7 @@ int Storage::Run()
|
||||
name_id_ptr[i] = current_edge_data.name_id;
|
||||
travel_mode_ptr[i] = current_edge_data.travel_mode;
|
||||
turn_instructions_ptr[i] = current_edge_data.turn_instruction;
|
||||
entry_class_id_ptr[i] = current_edge_data.entry_classid;
|
||||
}
|
||||
edges_input_stream.close();
|
||||
|
||||
@@ -503,8 +509,7 @@ int Storage::Run()
|
||||
{
|
||||
const unsigned bucket = i / 32;
|
||||
const unsigned offset = i % 32;
|
||||
const unsigned value = [&]
|
||||
{
|
||||
const unsigned value = [&] {
|
||||
unsigned return_value = 0;
|
||||
if (0 != offset)
|
||||
{
|
||||
@@ -539,13 +544,16 @@ int Storage::Run()
|
||||
hsgr_input_stream.close();
|
||||
|
||||
// load profile properties
|
||||
auto profile_properties_ptr = shared_layout_ptr->GetBlockPtr<extractor::ProfileProperties, true>(shared_memory_ptr, SharedDataLayout::PROPERTIES);
|
||||
auto profile_properties_ptr =
|
||||
shared_layout_ptr->GetBlockPtr<extractor::ProfileProperties, true>(
|
||||
shared_memory_ptr, SharedDataLayout::PROPERTIES);
|
||||
boost::filesystem::ifstream profile_properties_stream(config.properties_path);
|
||||
if (!profile_properties_stream)
|
||||
{
|
||||
util::exception("Could not open " + config.properties_path.string() + " for reading!");
|
||||
}
|
||||
profile_properties_stream.read(reinterpret_cast<char*>(profile_properties_ptr), sizeof(extractor::ProfileProperties));
|
||||
profile_properties_stream.read(reinterpret_cast<char *>(profile_properties_ptr),
|
||||
sizeof(extractor::ProfileProperties));
|
||||
|
||||
// acquire lock
|
||||
SharedMemory *data_type_memory =
|
||||
@@ -562,6 +570,43 @@ int Storage::Run()
|
||||
barrier.no_running_queries_condition.wait(query_lock);
|
||||
}
|
||||
|
||||
// load intersection classes
|
||||
{
|
||||
boost::filesystem::ifstream intersection_stream(config.intersection_class_path,
|
||||
std::ios::binary);
|
||||
if (!util::readAndCheckFingerprint(intersection_stream))
|
||||
{
|
||||
util::SimpleLogger().Write(logWARNING)
|
||||
<< "Fingerprint does not match or reading failed";
|
||||
}
|
||||
|
||||
std::vector<BearingClassID> bearing_class_id_table;
|
||||
util::deserializeVector(intersection_stream, bearing_class_id_table);
|
||||
shared_layout_ptr->SetBlockSize<BearingClassID>(SharedDataLayout::BEARING_CLASSID,
|
||||
bearing_class_id_table.size());
|
||||
auto bearing_id_ptr = shared_layout_ptr->GetBlockPtr<BearingClassID, true>(
|
||||
shared_memory_ptr, SharedDataLayout::BEARING_CLASSID);
|
||||
std::copy(bearing_class_id_table.begin(), bearing_class_id_table.end(), bearing_id_ptr);
|
||||
|
||||
auto bearing_class_ptr =
|
||||
shared_layout_ptr->GetBlockPtr<util::guidance::BearingClass, true>(
|
||||
shared_memory_ptr, SharedDataLayout::BEARING_CLASS);
|
||||
std::vector<util::guidance::BearingClass> bearing_class_table;
|
||||
util::deserializeVector(intersection_stream, bearing_class_table);
|
||||
shared_layout_ptr->SetBlockSize<util::guidance::BearingClass>(
|
||||
SharedDataLayout::BEARING_CLASS, bearing_class_table.size());
|
||||
std::copy(bearing_class_table.begin(), bearing_class_table.end(), bearing_class_ptr);
|
||||
|
||||
auto entry_class_ptr =
|
||||
shared_layout_ptr->GetBlockPtr<util::guidance::EntryClass, true>(
|
||||
shared_memory_ptr, SharedDataLayout::ENTRY_CLASS);
|
||||
std::vector<util::guidance::EntryClass> entry_class_table;
|
||||
util::deserializeVector(intersection_stream, entry_class_table);
|
||||
shared_layout_ptr->SetBlockSize<util::guidance::EntryClass>(
|
||||
SharedDataLayout::ENTRY_CLASS, entry_class_table.size());
|
||||
std::copy(entry_class_table.begin(), entry_class_table.end(), entry_class_ptr);
|
||||
}
|
||||
|
||||
data_timestamp_ptr->layout = layout_region;
|
||||
data_timestamp_ptr->data = data_region;
|
||||
data_timestamp_ptr->timestamp += 1;
|
||||
|
||||
@@ -14,8 +14,8 @@ StorageConfig::StorageConfig(const boost::filesystem::path &base)
|
||||
geometries_path{base.string() + ".geometry"}, timestamp_path{base.string() + ".timestamp"},
|
||||
datasource_names_path{base.string() + ".datasource_names"},
|
||||
datasource_indexes_path{base.string() + ".datasource_indexes"},
|
||||
names_data_path{base.string() + ".names"},
|
||||
properties_path{base.string() + ".properties"}
|
||||
names_data_path{base.string() + ".names"}, properties_path{base.string() + ".properties"},
|
||||
intersection_class_path{base.string() + ".icd"}
|
||||
{
|
||||
}
|
||||
|
||||
@@ -32,7 +32,8 @@ bool StorageConfig::IsValid() const
|
||||
boost::filesystem::is_regular_file(datasource_names_path) &&
|
||||
boost::filesystem::is_regular_file(datasource_indexes_path) &&
|
||||
boost::filesystem::is_regular_file(names_data_path) &&
|
||||
boost::filesystem::is_regular_file(properties_path);
|
||||
boost::filesystem::is_regular_file(properties_path) &&
|
||||
boost::filesystem::is_regular_file(intersection_class_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user