Enables the use of multiple segment-speed-files on the osrm-contract
command line, and exposes the file name used for each edge in the debug tiles.
This commit is contained in:
committed by
Patrick Niklaus
parent
80f008684d
commit
11b356e55f
@@ -131,6 +131,14 @@ int Storage::Run()
|
||||
{
|
||||
throw util::exception("no core file found");
|
||||
}
|
||||
if (paths.find("datasource_indexes") == paths.end())
|
||||
{
|
||||
throw util::exception("no datasource_indexes file found");
|
||||
}
|
||||
if (paths.find("datasource_names") == paths.end())
|
||||
{
|
||||
throw util::exception("no datasource_names file found");
|
||||
}
|
||||
|
||||
auto paths_iterator = paths.find("hsgrdata");
|
||||
BOOST_ASSERT(paths.end() != paths_iterator);
|
||||
@@ -170,6 +178,14 @@ int Storage::Run()
|
||||
BOOST_ASSERT(paths.end() != paths_iterator);
|
||||
BOOST_ASSERT(!paths_iterator->second.empty());
|
||||
const boost::filesystem::path &core_marker_path = paths_iterator->second;
|
||||
paths_iterator = paths.find("datasource_indexes");
|
||||
BOOST_ASSERT(paths.end() != paths_iterator);
|
||||
BOOST_ASSERT(!paths_iterator->second.empty());
|
||||
const boost::filesystem::path &datasource_indexes_path = paths_iterator->second;
|
||||
paths_iterator = paths.find("datasource_names");
|
||||
BOOST_ASSERT(paths.end() != paths_iterator);
|
||||
BOOST_ASSERT(!paths_iterator->second.empty());
|
||||
const boost::filesystem::path &datasource_names_path = paths_iterator->second;
|
||||
|
||||
// determine segment to use
|
||||
bool segment2_in_use = SharedMemory::RegionExists(LAYOUT_2);
|
||||
@@ -322,6 +338,45 @@ int Storage::Run()
|
||||
geometry_input_stream.read((char *)&number_of_compressed_geometries, sizeof(unsigned));
|
||||
shared_layout_ptr->SetBlockSize<extractor::CompressedEdgeContainer::CompressedEdge>(
|
||||
SharedDataLayout::GEOMETRIES_LIST, number_of_compressed_geometries);
|
||||
|
||||
// load datasource sizes. This file is optional, and it's non-fatal if it doesn't
|
||||
// exist.
|
||||
std::ifstream geometry_datasource_input_stream(datasource_indexes_path.c_str(),
|
||||
std::ios::binary);
|
||||
if (geometry_datasource_input_stream)
|
||||
{
|
||||
std::size_t number_of_compressed_datasources = 0;
|
||||
geometry_datasource_input_stream.read(
|
||||
reinterpret_cast<char *>(&number_of_compressed_datasources), sizeof(std::size_t));
|
||||
shared_layout_ptr->SetBlockSize<uint8_t>(SharedDataLayout::DATASOURCES_LIST,
|
||||
number_of_compressed_datasources);
|
||||
}
|
||||
|
||||
// Load datasource name sizes. This file is optional, and it's non-fatal if it doesn't
|
||||
// exist
|
||||
std::ifstream datasource_names_input_stream(datasource_names_path.c_str(), std::ios::binary);
|
||||
std::vector<char> m_datasource_name_data;
|
||||
std::vector<std::size_t> m_datasource_name_offsets;
|
||||
std::vector<std::size_t> m_datasource_name_lengths;
|
||||
if (datasource_names_input_stream)
|
||||
{
|
||||
std::string name;
|
||||
while (std::getline(datasource_names_input_stream, name))
|
||||
{
|
||||
m_datasource_name_offsets.push_back(m_datasource_name_data.size());
|
||||
std::copy(name.c_str(), name.c_str() + name.size(),
|
||||
std::back_inserter(m_datasource_name_data));
|
||||
m_datasource_name_lengths.push_back(name.size());
|
||||
}
|
||||
|
||||
shared_layout_ptr->SetBlockSize<char>(SharedDataLayout::DATASOURCE_NAME_DATA,
|
||||
m_datasource_name_data.size());
|
||||
shared_layout_ptr->SetBlockSize<std::size_t>(SharedDataLayout::DATASOURCE_NAME_OFFSETS,
|
||||
m_datasource_name_offsets.size());
|
||||
shared_layout_ptr->SetBlockSize<std::size_t>(SharedDataLayout::DATASOURCE_NAME_LENGTHS,
|
||||
m_datasource_name_lengths.size());
|
||||
}
|
||||
|
||||
// allocate shared memory block
|
||||
util::SimpleLogger().Write() << "allocating shared memory of "
|
||||
<< shared_layout_ptr->GetSizeOfLayout() << " bytes";
|
||||
@@ -435,6 +490,50 @@ int Storage::Run()
|
||||
shared_layout_ptr->GetBlockSize(SharedDataLayout::GEOMETRIES_LIST));
|
||||
}
|
||||
|
||||
// load datasource information (if it exists)
|
||||
if (geometry_datasource_input_stream)
|
||||
{
|
||||
uint8_t *datasources_list_ptr = shared_layout_ptr->GetBlockPtr<uint8_t, true>(
|
||||
shared_memory_ptr, SharedDataLayout::DATASOURCES_LIST);
|
||||
if (shared_layout_ptr->GetBlockSize(SharedDataLayout::DATASOURCES_LIST) > 0)
|
||||
{
|
||||
geometry_datasource_input_stream.read(
|
||||
reinterpret_cast<char *>(datasources_list_ptr),
|
||||
shared_layout_ptr->GetBlockSize(SharedDataLayout::DATASOURCES_LIST));
|
||||
}
|
||||
}
|
||||
|
||||
// load datasource name information (if it exists)
|
||||
if (!m_datasource_name_data.empty())
|
||||
{
|
||||
char *datasource_name_data_ptr = shared_layout_ptr->GetBlockPtr<char, true>(
|
||||
shared_memory_ptr, SharedDataLayout::DATASOURCE_NAME_DATA);
|
||||
if (shared_layout_ptr->GetBlockSize(SharedDataLayout::DATASOURCE_NAME_DATA) > 0)
|
||||
{
|
||||
std::cout << "Copying "
|
||||
<< (m_datasource_name_data.end() - m_datasource_name_data.begin())
|
||||
<< " chars into name data ptr\n";
|
||||
std::copy(m_datasource_name_data.begin(), m_datasource_name_data.end(),
|
||||
datasource_name_data_ptr);
|
||||
}
|
||||
|
||||
auto datasource_name_offsets_ptr = shared_layout_ptr->GetBlockPtr<std::size_t, true>(
|
||||
shared_memory_ptr, SharedDataLayout::DATASOURCE_NAME_OFFSETS);
|
||||
if (shared_layout_ptr->GetBlockSize(SharedDataLayout::DATASOURCE_NAME_OFFSETS) > 0)
|
||||
{
|
||||
std::copy(m_datasource_name_offsets.begin(), m_datasource_name_offsets.end(),
|
||||
datasource_name_offsets_ptr);
|
||||
}
|
||||
|
||||
auto datasource_name_lengths_ptr = shared_layout_ptr->GetBlockPtr<std::size_t, true>(
|
||||
shared_memory_ptr, SharedDataLayout::DATASOURCE_NAME_LENGTHS);
|
||||
if (shared_layout_ptr->GetBlockSize(SharedDataLayout::DATASOURCE_NAME_LENGTHS) > 0)
|
||||
{
|
||||
std::copy(m_datasource_name_lengths.begin(), m_datasource_name_lengths.end(),
|
||||
datasource_name_lengths_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
// Loading list of coordinates
|
||||
util::Coordinate *coordinates_ptr = shared_layout_ptr->GetBlockPtr<util::Coordinate, true>(
|
||||
shared_memory_ptr, SharedDataLayout::COORDINATE_LIST);
|
||||
|
||||
Reference in New Issue
Block a user