Port .names file to tar
This commit is contained in:
@@ -69,7 +69,7 @@ EdgeBasedGraphFactory::EdgeBasedGraphFactory(
|
||||
const std::unordered_set<NodeID> &barrier_nodes,
|
||||
const std::unordered_set<NodeID> &traffic_lights,
|
||||
const std::vector<util::Coordinate> &coordinates,
|
||||
const util::NameTable &name_table,
|
||||
const NameTable &name_table,
|
||||
const std::unordered_set<EdgeID> &segregated_edges,
|
||||
const extractor::LaneDescriptionMap &lane_description_map)
|
||||
: m_edge_based_node_container(node_data_container), m_connectivity_checksum(0),
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include "extractor/extraction_way.hpp"
|
||||
#include "extractor/restriction.hpp"
|
||||
#include "extractor/serialization.hpp"
|
||||
#include "extractor/name_table.hpp"
|
||||
#include "extractor/files.hpp"
|
||||
|
||||
#include "util/coordinate_calculation.hpp"
|
||||
|
||||
@@ -10,7 +12,6 @@
|
||||
#include "util/exception_utils.hpp"
|
||||
#include "util/fingerprint.hpp"
|
||||
#include "util/log.hpp"
|
||||
#include "util/name_table.hpp"
|
||||
#include "util/timing_util.hpp"
|
||||
|
||||
#include "storage/io.hpp"
|
||||
@@ -163,10 +164,8 @@ void ExtractionContainers::WriteCharData(const std::string &file_name)
|
||||
util::UnbufferedLog log;
|
||||
log << "writing street name index ... ";
|
||||
TIMER_START(write_index);
|
||||
storage::io::FileWriter file(file_name, storage::io::FileWriter::GenerateFingerprint);
|
||||
|
||||
const util::NameTable::IndexedData indexed_data;
|
||||
indexed_data.write(file, name_offsets.begin(), name_offsets.end(), name_char_data.begin());
|
||||
files::writeNames(file_name, NameTable {NameTable::IndexedData (name_offsets.begin(), name_offsets.end(), name_char_data.begin())});
|
||||
|
||||
TIMER_STOP(write_index);
|
||||
log << "ok, after " << TIMER_SEC(write_index) << "s";
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "extractor/restriction_filter.hpp"
|
||||
#include "extractor/restriction_parser.hpp"
|
||||
#include "extractor/scripting_environment.hpp"
|
||||
#include "extractor/name_table.hpp"
|
||||
|
||||
#include "guidance/files.hpp"
|
||||
#include "guidance/guidance_processing.hpp"
|
||||
@@ -25,7 +26,6 @@
|
||||
#include "util/exception_utils.hpp"
|
||||
#include "util/integer_range.hpp"
|
||||
#include "util/log.hpp"
|
||||
#include "util/name_table.hpp"
|
||||
#include "util/range_table.hpp"
|
||||
#include "util/timing_util.hpp"
|
||||
|
||||
@@ -230,11 +230,13 @@ int Extractor::run(ScriptingEnvironment &scripting_environment)
|
||||
conditional_turn_restrictions,
|
||||
unresolved_maneuver_overrides);
|
||||
|
||||
NameTable name_table;
|
||||
files::readNames(config.GetPath(".osrm.names"), name_table);
|
||||
|
||||
util::Log() << "Find segregated edges in node-based graph ..." << std::flush;
|
||||
TIMER_START(segregated);
|
||||
|
||||
util::NameTable names(config.GetPath(".osrm.names").string());
|
||||
auto segregated_edges = guidance::findSegregatedNodes(node_based_graph_factory, names);
|
||||
auto segregated_edges = guidance::findSegregatedNodes(node_based_graph_factory, name_table);
|
||||
|
||||
TIMER_STOP(segregated);
|
||||
util::Log() << "ok, after " << TIMER_SEC(segregated) << "s";
|
||||
@@ -283,8 +285,6 @@ int Extractor::run(ScriptingEnvironment &scripting_environment)
|
||||
|
||||
const auto number_of_node_based_nodes = node_based_graph.GetNumberOfNodes();
|
||||
|
||||
const util::NameTable name_table(config.GetPath(".osrm.names").string());
|
||||
|
||||
const auto number_of_edge_based_nodes =
|
||||
BuildEdgeExpandedGraph(node_based_graph,
|
||||
coordinates,
|
||||
@@ -713,7 +713,7 @@ EdgeID Extractor::BuildEdgeExpandedGraph(
|
||||
const std::vector<TurnRestriction> &turn_restrictions,
|
||||
const std::vector<ConditionalTurnRestriction> &conditional_turn_restrictions,
|
||||
const std::unordered_set<EdgeID> &segregated_edges,
|
||||
const util::NameTable &name_table,
|
||||
const NameTable &name_table,
|
||||
const std::vector<UnresolvedManeuverOverride> &maneuver_overrides,
|
||||
const LaneDescriptionMap &turn_lane_map,
|
||||
// for calculating turn penalties
|
||||
@@ -884,7 +884,7 @@ void Extractor::ProcessGuidanceTurns(
|
||||
const std::unordered_set<NodeID> &barrier_nodes,
|
||||
const std::vector<TurnRestriction> &turn_restrictions,
|
||||
const std::vector<ConditionalTurnRestriction> &conditional_turn_restrictions,
|
||||
const util::NameTable &name_table,
|
||||
const NameTable &name_table,
|
||||
LaneDescriptionMap lane_description_map,
|
||||
ScriptingEnvironment &scripting_environment)
|
||||
{
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#include "extractor/intersection/have_identical_names.hpp"
|
||||
|
||||
#include "util/guidance/name_announcements.hpp"
|
||||
|
||||
namespace osrm
|
||||
@@ -12,7 +14,7 @@ namespace intersection
|
||||
// rhs->lhs)
|
||||
bool HaveIdenticalNames(const NameID lhs,
|
||||
const NameID rhs,
|
||||
const util::NameTable &name_table,
|
||||
const NameTable &name_table,
|
||||
const extractor::SuffixTable &street_name_suffix_table)
|
||||
{
|
||||
const auto non_empty = (lhs != EMPTY_NAMEID) && (rhs != EMPTY_NAMEID);
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
#include "extractor/intersection/node_based_graph_walker.hpp"
|
||||
#include "extractor/query_node.hpp"
|
||||
#include "extractor/suffix_table.hpp"
|
||||
#include "extractor/name_table.hpp"
|
||||
#include "guidance/constants.hpp"
|
||||
|
||||
#include "util/bearing.hpp"
|
||||
#include "util/coordinate_calculation.hpp"
|
||||
#include "util/guidance/name_announcements.hpp"
|
||||
#include "util/name_table.hpp"
|
||||
|
||||
using osrm::util::angularDeviation;
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace
|
||||
inline auto makeCheckRoadForName(const NameID name_id,
|
||||
const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
const EdgeBasedNodeDataContainer &node_data_container,
|
||||
const util::NameTable &name_table,
|
||||
const NameTable &name_table,
|
||||
const SuffixTable &suffix_table)
|
||||
{
|
||||
return [name_id, &node_based_graph, &node_data_container, &name_table, &suffix_table](
|
||||
@@ -59,7 +59,7 @@ MergableRoadDetector::MergableRoadDetector(
|
||||
const RestrictionMap &node_restriction_map,
|
||||
const std::unordered_set<NodeID> &barrier_nodes,
|
||||
const extractor::TurnLanesIndexedArray &turn_lanes_data,
|
||||
const util::NameTable &name_table,
|
||||
const NameTable &name_table,
|
||||
const SuffixTable &street_name_suffix_table)
|
||||
: node_based_graph(node_based_graph), node_data_container(node_data_container),
|
||||
node_coordinates(node_coordinates), compressed_geometries(compressed_geometries),
|
||||
|
||||
@@ -17,7 +17,7 @@ DrivewayHandler::DrivewayHandler(const util::NodeBasedDynamicGraph &node_based_g
|
||||
const extractor::RestrictionMap &node_restriction_map,
|
||||
const std::unordered_set<NodeID> &barrier_nodes,
|
||||
const extractor::TurnLanesIndexedArray &turn_lanes_data,
|
||||
const util::NameTable &name_table,
|
||||
const extractor::NameTable &name_table,
|
||||
const extractor::SuffixTable &street_name_suffix_table)
|
||||
: IntersectionHandler(node_based_graph,
|
||||
node_data_container,
|
||||
|
||||
@@ -24,7 +24,7 @@ void annotateTurns(const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
const std::unordered_set<NodeID> &barrier_nodes,
|
||||
const extractor::RestrictionMap &node_restriction_map,
|
||||
const extractor::WayRestrictionMap &way_restriction_map,
|
||||
const util::NameTable &name_table,
|
||||
const extractor::NameTable &name_table,
|
||||
const extractor::SuffixTable &suffix_table,
|
||||
const extractor::TurnLanesIndexedArray &turn_lanes_data,
|
||||
extractor::LaneDescriptionMap &lane_description_map,
|
||||
|
||||
@@ -52,7 +52,7 @@ IntersectionHandler::IntersectionHandler(
|
||||
const extractor::RestrictionMap &node_restriction_map,
|
||||
const std::unordered_set<NodeID> &barrier_nodes,
|
||||
const extractor::TurnLanesIndexedArray &turn_lanes_data,
|
||||
const util::NameTable &name_table,
|
||||
const extractor::NameTable &name_table,
|
||||
const extractor::SuffixTable &street_name_suffix_table)
|
||||
: node_based_graph(node_based_graph), node_data_container(node_data_container),
|
||||
node_coordinates(node_coordinates), compressed_geometries(compressed_geometries),
|
||||
|
||||
@@ -49,7 +49,7 @@ MotorwayHandler::MotorwayHandler(const util::NodeBasedDynamicGraph &node_based_g
|
||||
const extractor::RestrictionMap &node_restriction_map,
|
||||
const std::unordered_set<NodeID> &barrier_nodes,
|
||||
const extractor::TurnLanesIndexedArray &turn_lanes_data,
|
||||
const util::NameTable &name_table,
|
||||
const extractor::NameTable &name_table,
|
||||
const extractor::SuffixTable &street_name_suffix_table)
|
||||
: IntersectionHandler(node_based_graph,
|
||||
node_data_container,
|
||||
|
||||
@@ -30,7 +30,7 @@ RoundaboutHandler::RoundaboutHandler(
|
||||
const extractor::RestrictionMap &node_restriction_map,
|
||||
const std::unordered_set<NodeID> &barrier_nodes,
|
||||
const extractor::TurnLanesIndexedArray &turn_lanes_data,
|
||||
const util::NameTable &name_table,
|
||||
const extractor::NameTable &name_table,
|
||||
const extractor::SuffixTable &street_name_suffix_table)
|
||||
: IntersectionHandler(node_based_graph,
|
||||
node_data_container,
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "guidance/turn_instruction.hpp"
|
||||
|
||||
#include "util/coordinate_calculation.hpp"
|
||||
#include "util/name_table.hpp"
|
||||
#include <set>
|
||||
|
||||
using osrm::guidance::getTurnDirection;
|
||||
@@ -42,7 +41,7 @@ struct EdgeInfo
|
||||
};
|
||||
|
||||
std::unordered_set<EdgeID> findSegregatedNodes(const extractor::NodeBasedGraphFactory &factory,
|
||||
const util::NameTable &names)
|
||||
const extractor::NameTable &names)
|
||||
{
|
||||
auto const &graph = factory.GetGraph();
|
||||
auto const &annotation = factory.GetAnnotationData();
|
||||
|
||||
@@ -27,7 +27,7 @@ SliproadHandler::SliproadHandler(const util::NodeBasedDynamicGraph &node_based_g
|
||||
const extractor::RestrictionMap &node_restriction_map,
|
||||
const std::unordered_set<NodeID> &barrier_nodes,
|
||||
const extractor::TurnLanesIndexedArray &turn_lanes_data,
|
||||
const util::NameTable &name_table,
|
||||
const extractor::NameTable &name_table,
|
||||
const extractor::SuffixTable &street_name_suffix_table)
|
||||
: IntersectionHandler(node_based_graph,
|
||||
node_data_container,
|
||||
|
||||
@@ -17,7 +17,7 @@ SuppressModeHandler::SuppressModeHandler(
|
||||
const extractor::RestrictionMap &node_restriction_map,
|
||||
const std::unordered_set<NodeID> &barrier_nodes,
|
||||
const extractor::TurnLanesIndexedArray &turn_lanes_data,
|
||||
const util::NameTable &name_table,
|
||||
const extractor::NameTable &name_table,
|
||||
const extractor::SuffixTable &street_name_suffix_table)
|
||||
: IntersectionHandler(node_based_graph,
|
||||
node_data_container,
|
||||
|
||||
@@ -26,7 +26,7 @@ TurnAnalysis::TurnAnalysis(const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
const extractor::RestrictionMap &restriction_map,
|
||||
const std::unordered_set<NodeID> &barrier_nodes,
|
||||
const extractor::TurnLanesIndexedArray &turn_lanes_data,
|
||||
const util::NameTable &name_table,
|
||||
const extractor::NameTable &name_table,
|
||||
const extractor::SuffixTable &street_name_suffix_table)
|
||||
: node_based_graph(node_based_graph), roundabout_handler(node_based_graph,
|
||||
node_data_container,
|
||||
|
||||
@@ -115,7 +115,7 @@ TurnHandler::TurnHandler(const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
const extractor::RestrictionMap &node_restriction_map,
|
||||
const std::unordered_set<NodeID> &barrier_nodes,
|
||||
const extractor::TurnLanesIndexedArray &turn_lanes_data,
|
||||
const util::NameTable &name_table,
|
||||
const extractor::NameTable &name_table,
|
||||
const extractor::SuffixTable &street_name_suffix_table)
|
||||
: IntersectionHandler(node_based_graph,
|
||||
node_data_container,
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ OSRM::OSRM(engine::EngineConfig &config)
|
||||
|
||||
auto mem = storage::makeSharedMemory(barrier.data().region);
|
||||
auto layout = reinterpret_cast<storage::DataLayout *>(mem->Ptr());
|
||||
if (layout->GetBlockSize(storage::DataLayout::NAME_CHAR_DATA) == 0)
|
||||
if (layout->GetBlockSize(storage::DataLayout::NAME_VALUES) == 0)
|
||||
throw util::exception(
|
||||
"No name data loaded, cannot continue. Have you run osrm-datastore to load data?");
|
||||
}
|
||||
|
||||
+18
-14
@@ -18,6 +18,7 @@
|
||||
#include "extractor/edge_based_node.hpp"
|
||||
#include "extractor/files.hpp"
|
||||
#include "extractor/maneuver_override.hpp"
|
||||
#include "extractor/name_table.hpp"
|
||||
#include "extractor/packed_osm_ids.hpp"
|
||||
#include "extractor/profile_properties.hpp"
|
||||
#include "extractor/query_node.hpp"
|
||||
@@ -243,13 +244,6 @@ void Storage::PopulateLayout(DataLayout &layout)
|
||||
make_block<char>(absolute_file_index_path.string().length() + 1));
|
||||
}
|
||||
|
||||
{
|
||||
util::Log() << "load names from: " << config.GetPath(".osrm.names");
|
||||
// number of entries in name index
|
||||
io::FileReader name_file(config.GetPath(".osrm.names"), io::FileReader::VerifyFingerprint);
|
||||
layout.SetBlock(DataLayout::NAME_CHAR_DATA, make_block<char>(name_file.GetSize()));
|
||||
}
|
||||
|
||||
// load rsearch tree size
|
||||
{
|
||||
io::FileReader tree_node_file(config.GetPath(".osrm.ramIndex"),
|
||||
@@ -345,6 +339,8 @@ void Storage::PopulateLayout(DataLayout &layout)
|
||||
{"/common/turn_data/lane_data_ids", DataLayout::LANE_DATA_ID},
|
||||
{"/common/turn_data/entry_class_ids", DataLayout::ENTRY_CLASSID},
|
||||
{"/common/turn_data/connectivity_checksum", DataLayout::IGNORE_BLOCK},
|
||||
{"/common/names/blocks", DataLayout::NAME_BLOCKS},
|
||||
{"/common/names/values", DataLayout::NAME_VALUES},
|
||||
};
|
||||
std::vector<NamedBlock> blocks;
|
||||
|
||||
@@ -368,6 +364,7 @@ void Storage::PopulateLayout(DataLayout &layout)
|
||||
{REQUIRED, config.GetPath(".osrm.turn_weight_penalties")},
|
||||
{REQUIRED, config.GetPath(".osrm.turn_duration_penalties")},
|
||||
{REQUIRED, config.GetPath(".osrm.edges")},
|
||||
{REQUIRED, config.GetPath(".osrm.names")},
|
||||
};
|
||||
|
||||
for (const auto &file : tar_files)
|
||||
@@ -425,14 +422,21 @@ void Storage::PopulateData(const DataLayout &layout, char *memory_ptr)
|
||||
|
||||
// Name data
|
||||
{
|
||||
io::FileReader name_file(config.GetPath(".osrm.names"), io::FileReader::VerifyFingerprint);
|
||||
std::size_t name_file_size = name_file.GetSize();
|
||||
const auto name_blocks_ptr =
|
||||
layout.GetBlockPtr<extractor::NameTableView::IndexedData::BlockReference, true>(
|
||||
memory_ptr, DataLayout::NAME_BLOCKS);
|
||||
const auto name_values_ptr =
|
||||
layout.GetBlockPtr<extractor::NameTableView::IndexedData::ValueType, true>(
|
||||
memory_ptr, DataLayout::NAME_VALUES);
|
||||
|
||||
BOOST_ASSERT(name_file_size == layout.GetBlockSize(DataLayout::NAME_CHAR_DATA));
|
||||
const auto name_char_ptr =
|
||||
layout.GetBlockPtr<char, true>(memory_ptr, DataLayout::NAME_CHAR_DATA);
|
||||
util::vector_view<extractor::NameTableView::IndexedData::BlockReference> blocks(
|
||||
name_blocks_ptr, layout.GetBlockEntries(storage::DataLayout::NAME_BLOCKS));
|
||||
util::vector_view<extractor::NameTableView::IndexedData::ValueType> values(
|
||||
name_values_ptr, layout.GetBlockEntries(storage::DataLayout::NAME_VALUES));
|
||||
|
||||
name_file.ReadInto<char>(name_char_ptr, name_file_size);
|
||||
extractor::NameTableView::IndexedData index_data_view{std::move(blocks), std::move(values)};
|
||||
extractor::NameTableView name_table{index_data_view};
|
||||
extractor::files::readNames(config.GetPath(".osrm.names"), name_table);
|
||||
}
|
||||
|
||||
// Turn lane data
|
||||
@@ -624,7 +628,7 @@ void Storage::PopulateData(const DataLayout &layout, char *memory_ptr)
|
||||
turn_duration_penalties_ptr,
|
||||
layout.GetBlockEntries(storage::DataLayout::TURN_WEIGHT_PENALTIES));
|
||||
extractor::files::readTurnWeightPenalty(config.GetPath(".osrm.turn_weight_penalties"),
|
||||
turn_duration_penalties);
|
||||
turn_duration_penalties);
|
||||
}
|
||||
|
||||
// load turn duration penalties
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
#include "util/name_table.hpp"
|
||||
#include "storage/io.hpp"
|
||||
#include "util/log.hpp"
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
NameTable::NameTable(const std::string &file_name)
|
||||
{
|
||||
using FileReader = storage::io::FileReader;
|
||||
|
||||
FileReader name_stream_file_reader(file_name, FileReader::VerifyFingerprint);
|
||||
const auto file_size = name_stream_file_reader.GetSize();
|
||||
|
||||
m_buffer = BufferType(static_cast<ValueType *>(::operator new(file_size)),
|
||||
[](void *ptr) { ::operator delete(ptr); });
|
||||
name_stream_file_reader.ReadInto<char>(m_buffer.get(), file_size);
|
||||
m_name_table.reset(m_buffer.get(), m_buffer.get() + file_size);
|
||||
|
||||
if (m_name_table.empty())
|
||||
{
|
||||
util::Log() << "list of street names is empty in construction of name table from: \""
|
||||
<< file_name << "\"";
|
||||
}
|
||||
}
|
||||
|
||||
void NameTable::reset(ValueType *begin, ValueType *end)
|
||||
{
|
||||
m_buffer.reset();
|
||||
m_name_table.reset(begin, end);
|
||||
}
|
||||
|
||||
StringView NameTable::GetNameForID(const NameID id) const
|
||||
{
|
||||
if (id == INVALID_NAMEID)
|
||||
return {};
|
||||
|
||||
return m_name_table.at(id + 0);
|
||||
}
|
||||
|
||||
StringView NameTable::GetDestinationsForID(const NameID id) const
|
||||
{
|
||||
if (id == INVALID_NAMEID)
|
||||
return {};
|
||||
|
||||
return m_name_table.at(id + 1);
|
||||
}
|
||||
|
||||
StringView NameTable::GetExitsForID(const NameID id) const
|
||||
{
|
||||
if (id == INVALID_NAMEID)
|
||||
return {};
|
||||
|
||||
return m_name_table.at(id + 4);
|
||||
}
|
||||
|
||||
StringView NameTable::GetRefForID(const NameID id) const
|
||||
{
|
||||
if (id == INVALID_NAMEID)
|
||||
return {};
|
||||
|
||||
// Way string data is stored in blocks based on `id` as follows:
|
||||
//
|
||||
// | name | destination | pronunciation | ref | exits
|
||||
// ^ ^
|
||||
// [range)
|
||||
// ^ id + 3
|
||||
//
|
||||
// `id + offset` gives us the range of chars.
|
||||
//
|
||||
// Offset 0 is name, 1 is destination, 2 is pronunciation, 3 is ref, 4 is exits
|
||||
// See datafacades and extractor callbacks for details.
|
||||
const constexpr auto OFFSET_REF = 3u;
|
||||
return m_name_table.at(id + OFFSET_REF);
|
||||
}
|
||||
|
||||
StringView NameTable::GetPronunciationForID(const NameID id) const
|
||||
{
|
||||
if (id == INVALID_NAMEID)
|
||||
return {};
|
||||
|
||||
// Way string data is stored in blocks based on `id` as follows:
|
||||
//
|
||||
// | name | destination | pronunciation | ref | exits
|
||||
// ^ ^
|
||||
// [range)
|
||||
// ^ id + 2
|
||||
//
|
||||
// `id + offset` gives us the range of chars.
|
||||
//
|
||||
// Offset 0 is name, 1 is destination, 2 is pronunciation, 3 is ref, 4 is exits
|
||||
// See datafacades and extractor callbacks for details.
|
||||
const constexpr auto OFFSET_PRONUNCIATION = 2u;
|
||||
return m_name_table.at(id + OFFSET_PRONUNCIATION);
|
||||
}
|
||||
|
||||
} // namespace util
|
||||
} // namespace osrm
|
||||
Reference in New Issue
Block a user