Port .tld and .tls data
This commit is contained in:
parent
b1dfbce675
commit
5d7d5fceba
@ -10,6 +10,7 @@
|
||||
#include "util/coordinate.hpp"
|
||||
#include "util/guidance/bearing_class.hpp"
|
||||
#include "util/guidance/entry_class.hpp"
|
||||
#include "util/guidance/turn_lanes.hpp"
|
||||
#include "util/packed_vector.hpp"
|
||||
#include "util/range_table.hpp"
|
||||
#include "util/serialization.hpp"
|
||||
@ -240,11 +241,11 @@ inline void readTurnLaneDescriptions(const boost::filesystem::path &path,
|
||||
"");
|
||||
static_assert(std::is_same<typename OffsetsT::value_type, std::uint32_t>::value, "");
|
||||
|
||||
const auto fingerprint = storage::io::FileReader::VerifyFingerprint;
|
||||
storage::io::FileReader reader{path, fingerprint};
|
||||
const auto fingerprint = storage::tar::FileReader::VerifyFingerprint;
|
||||
storage::tar::FileReader reader{path, fingerprint};
|
||||
|
||||
storage::serialization::read(reader, turn_offsets);
|
||||
storage::serialization::read(reader, turn_masks);
|
||||
storage::serialization::read(reader, "/common/turn_lanes/offsets", turn_offsets);
|
||||
storage::serialization::read(reader, "/common/turn_lanes/masks", turn_masks);
|
||||
}
|
||||
|
||||
// writes .osrm.tls
|
||||
@ -257,13 +258,41 @@ inline void writeTurnLaneDescriptions(const boost::filesystem::path &path,
|
||||
"");
|
||||
static_assert(std::is_same<typename OffsetsT::value_type, std::uint32_t>::value, "");
|
||||
|
||||
const auto fingerprint = storage::io::FileWriter::GenerateFingerprint;
|
||||
storage::io::FileWriter writer{path, fingerprint};
|
||||
const auto fingerprint = storage::tar::FileWriter::GenerateFingerprint;
|
||||
storage::tar::FileWriter writer{path, fingerprint};
|
||||
|
||||
storage::serialization::write(writer, turn_offsets);
|
||||
storage::serialization::write(writer, turn_masks);
|
||||
storage::serialization::write(writer, "/common/turn_lanes/offsets", turn_offsets);
|
||||
storage::serialization::write(writer, "/common/turn_lanes/masks", turn_masks);
|
||||
}
|
||||
|
||||
// reads .osrm.tld
|
||||
template <typename TurnLaneDataT>
|
||||
inline void readTurnLaneData(const boost::filesystem::path &path, TurnLaneDataT &turn_lane_data)
|
||||
{
|
||||
static_assert(std::is_same<typename TurnLaneDataT::value_type, util::guidance::LaneTupleIdPair>::value,
|
||||
"");
|
||||
|
||||
const auto fingerprint = storage::tar::FileReader::VerifyFingerprint;
|
||||
storage::tar::FileReader reader{path, fingerprint};
|
||||
|
||||
storage::serialization::read(reader, "/common/turn_lanes/data", turn_lane_data);
|
||||
}
|
||||
|
||||
// writes .osrm.tld
|
||||
template <typename TurnLaneDataT>
|
||||
inline void writeTurnLaneData(const boost::filesystem::path &path,
|
||||
const TurnLaneDataT &turn_lane_data)
|
||||
{
|
||||
static_assert(std::is_same<typename TurnLaneDataT::value_type, util::guidance::LaneTupleIdPair>::value,
|
||||
"");
|
||||
|
||||
const auto fingerprint = storage::tar::FileWriter::GenerateFingerprint;
|
||||
storage::tar::FileWriter writer{path, fingerprint};
|
||||
|
||||
storage::serialization::write(writer, "/common/turn_lanes/data", turn_lane_data);
|
||||
}
|
||||
|
||||
|
||||
// reads .osrm.maneuver_overrides
|
||||
template <typename StorageManeuverOverrideT, typename NodeSequencesT>
|
||||
inline void readManeuverOverrides(const boost::filesystem::path &path,
|
||||
|
@ -550,9 +550,9 @@ Extractor::ParseOSMData(ScriptingEnvironment &scripting_environment,
|
||||
const auto &rel = static_cast<const osmium::Relation &>(*entity);
|
||||
|
||||
const char *rel_type = rel.get_value_by_key("type");
|
||||
if (!rel_type ||
|
||||
!std::binary_search(
|
||||
relation_types.begin(), relation_types.end(), std::string(rel_type)))
|
||||
if (!rel_type || !std::binary_search(relation_types.begin(),
|
||||
relation_types.end(),
|
||||
std::string(rel_type)))
|
||||
continue;
|
||||
|
||||
ExtractionRelation extracted_rel({rel.id(), osmium::item_type::relation});
|
||||
@ -945,9 +945,11 @@ void Extractor::ProcessGuidanceTurns(
|
||||
|
||||
util::Log() << "Writing Turns and Lane Data...";
|
||||
TIMER_START(write_guidance_data);
|
||||
storage::io::FileWriter writer(config.GetPath(".osrm.tld").string(),
|
||||
storage::io::FileWriter::GenerateFingerprint);
|
||||
storage::serialization::write(writer, convertIDMapToVector(lane_data_map.data));
|
||||
|
||||
{
|
||||
auto turn_lane_data = convertIDMapToVector(lane_data_map.data);
|
||||
files::writeTurnLaneData(config.GetPath(".osrm.tld"), turn_lane_data);
|
||||
}
|
||||
|
||||
{ // Turn lanes handler modifies lane_description_map, so another transformation is needed
|
||||
std::vector<std::uint32_t> turn_lane_offsets;
|
||||
|
@ -250,16 +250,6 @@ void Storage::PopulateLayout(DataLayout &layout)
|
||||
layout.SetBlock(DataLayout::NAME_CHAR_DATA, make_block<char>(name_file.GetSize()));
|
||||
}
|
||||
|
||||
{
|
||||
io::FileReader reader(config.GetPath(".osrm.tls"), io::FileReader::VerifyFingerprint);
|
||||
auto num_offsets = reader.ReadVectorSize<std::uint32_t>();
|
||||
auto num_masks = reader.ReadVectorSize<extractor::TurnLaneType::Mask>();
|
||||
|
||||
layout.SetBlock(DataLayout::LANE_DESCRIPTION_OFFSETS,
|
||||
make_block<std::uint32_t>(num_offsets));
|
||||
layout.SetBlock(DataLayout::LANE_DESCRIPTION_MASKS,
|
||||
make_block<extractor::TurnLaneType::Mask>(num_masks));
|
||||
}
|
||||
|
||||
// Loading information for original edges
|
||||
{
|
||||
@ -317,15 +307,6 @@ void Storage::PopulateLayout(DataLayout &layout)
|
||||
make_block<TurnPenalty>(number_of_penalties));
|
||||
}
|
||||
|
||||
{
|
||||
// Loading turn lane data
|
||||
io::FileReader lane_data_file(config.GetPath(".osrm.tld"),
|
||||
io::FileReader::VerifyFingerprint);
|
||||
const auto lane_tuple_count = lane_data_file.ReadElementCount64();
|
||||
layout.SetBlock(DataLayout::TURN_LANE_DATA,
|
||||
make_block<util::guidance::LaneTupleIdPair>(lane_tuple_count));
|
||||
}
|
||||
|
||||
// load maneuver overrides
|
||||
{
|
||||
io::FileReader maneuver_overrides_file(config.GetPath(".osrm.maneuver_overrides"),
|
||||
@ -398,6 +379,9 @@ void Storage::PopulateLayout(DataLayout &layout)
|
||||
{"/common/segment_data/reverse_data_sources", DataLayout::GEOMETRIES_REV_DATASOURCES_LIST},
|
||||
{"/common/ebg_node_data/nodes", DataLayout::EDGE_BASED_NODE_DATA_LIST},
|
||||
{"/common/ebg_node_data/annotations", DataLayout::ANNOTATION_DATA_LIST},
|
||||
{"/common/turn_lanes/offsets", DataLayout::LANE_DESCRIPTION_OFFSETS},
|
||||
{"/common/turn_lanes/masks", DataLayout::LANE_DESCRIPTION_MASKS},
|
||||
{"/common/turn_lanes/data", DataLayout::TURN_LANE_DATA},
|
||||
};
|
||||
std::vector<NamedBlock> blocks;
|
||||
|
||||
@ -415,6 +399,8 @@ void Storage::PopulateLayout(DataLayout &layout)
|
||||
{REQUIRED, config.GetPath(".osrm.datasource_names")},
|
||||
{REQUIRED, config.GetPath(".osrm.geometry")},
|
||||
{REQUIRED, config.GetPath(".osrm.ebg_nodes")},
|
||||
{REQUIRED, config.GetPath(".osrm.tls")},
|
||||
{REQUIRED, config.GetPath(".osrm.tld")},
|
||||
};
|
||||
|
||||
for (const auto &file : tar_files)
|
||||
@ -483,18 +469,12 @@ void Storage::PopulateData(const DataLayout &layout, char *memory_ptr)
|
||||
|
||||
// Turn lane data
|
||||
{
|
||||
io::FileReader lane_data_file(config.GetPath(".osrm.tld"),
|
||||
io::FileReader::VerifyFingerprint);
|
||||
|
||||
const auto lane_tuple_count = lane_data_file.ReadElementCount64();
|
||||
|
||||
// Need to call GetBlockPtr -> it write the memory canary, even if no data needs to be
|
||||
// loaded.
|
||||
const auto turn_lane_data_ptr = layout.GetBlockPtr<util::guidance::LaneTupleIdPair, true>(
|
||||
memory_ptr, DataLayout::TURN_LANE_DATA);
|
||||
BOOST_ASSERT(lane_tuple_count * sizeof(util::guidance::LaneTupleIdPair) ==
|
||||
layout.GetBlockSize(DataLayout::TURN_LANE_DATA));
|
||||
lane_data_file.ReadInto(turn_lane_data_ptr, lane_tuple_count);
|
||||
util::vector_view<util::guidance::LaneTupleIdPair> turn_lane_data(
|
||||
turn_lane_data_ptr, layout.GetBlockEntries(storage::DataLayout::TURN_LANE_DATA));
|
||||
|
||||
extractor::files::readTurnLaneData(config.GetPath(".osrm.tld"), turn_lane_data);
|
||||
}
|
||||
|
||||
// Turn lane descriptions
|
||||
|
Loading…
Reference in New Issue
Block a user