Port .names file to tar
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include "extractor/edge_based_node_segment.hpp"
|
||||
#include "extractor/extraction_turn.hpp"
|
||||
#include "extractor/maneuver_override.hpp"
|
||||
#include "extractor/name_table.hpp"
|
||||
#include "extractor/nbg_to_ebg.hpp"
|
||||
#include "extractor/node_data_container.hpp"
|
||||
#include "extractor/query_node.hpp"
|
||||
@@ -18,7 +19,6 @@
|
||||
|
||||
#include "util/concurrent_id_map.hpp"
|
||||
#include "util/deallocating_vector.hpp"
|
||||
#include "util/name_table.hpp"
|
||||
#include "util/node_based_graph.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
@@ -70,7 +70,7 @@ class 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 LaneDescriptionMap &lane_description_map);
|
||||
|
||||
@@ -138,7 +138,7 @@ class EdgeBasedGraphFactory
|
||||
const std::unordered_set<NodeID> &m_traffic_lights;
|
||||
const CompressedEdgeContainer &m_compressed_edge_container;
|
||||
|
||||
const util::NameTable &name_table;
|
||||
const NameTable &name_table;
|
||||
const std::unordered_set<EdgeID> &segregated_edges;
|
||||
const LaneDescriptionMap &lane_description_map;
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ class Extractor
|
||||
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
|
||||
@@ -116,7 +116,7 @@ class Extractor
|
||||
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);
|
||||
};
|
||||
|
||||
@@ -411,7 +411,8 @@ void readRawNBGraph(const boost::filesystem::path &path,
|
||||
osm_node_ids.push_back(current_node.node_id);
|
||||
index++;
|
||||
};
|
||||
reader.ReadStreaming<extractor::QueryNode>("/extractor/nodes", boost::make_function_output_iterator(decode));
|
||||
reader.ReadStreaming<extractor::QueryNode>("/extractor/nodes",
|
||||
boost::make_function_output_iterator(decode));
|
||||
|
||||
reader.ReadStreaming<NodeID>("/extractor/barriers", barriers);
|
||||
|
||||
@@ -420,6 +421,24 @@ void readRawNBGraph(const boost::filesystem::path &path,
|
||||
storage::serialization::read(reader, "/extractor/edges", edge_list);
|
||||
storage::serialization::read(reader, "/extractor/annotations", annotations);
|
||||
}
|
||||
|
||||
template <typename NameTableT>
|
||||
void readNames(const boost::filesystem::path &path, NameTableT &table)
|
||||
{
|
||||
const auto fingerprint = storage::tar::FileReader::VerifyFingerprint;
|
||||
storage::tar::FileReader reader{path, fingerprint};
|
||||
|
||||
serialization::read(reader, "/common/names", table);
|
||||
}
|
||||
|
||||
template <typename NameTableT>
|
||||
void writeNames(const boost::filesystem::path &path, const NameTableT &table)
|
||||
{
|
||||
const auto fingerprint = storage::tar::FileWriter::GenerateFingerprint;
|
||||
storage::tar::FileWriter writer{path, fingerprint};
|
||||
|
||||
serialization::write(writer, "/common/names", table);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#ifndef OSRM_EXTRACTOR_INTERSECTION_HAVE_IDENTICAL_NAMES_HPP_
|
||||
#define OSRM_EXTRACTOR_INTERSECTION_HAVE_IDENTICAL_NAMES_HPP_
|
||||
|
||||
#include "extractor/name_table.hpp"
|
||||
#include "extractor/suffix_table.hpp"
|
||||
#include "guidance/constants.hpp"
|
||||
#include "util/name_table.hpp"
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
@@ -17,7 +17,7 @@ namespace intersection
|
||||
// rhs->lhs)
|
||||
bool HaveIdenticalNames(const NameID lhs,
|
||||
const NameID rhs,
|
||||
const util::NameTable &name_table,
|
||||
const NameTable &name_table,
|
||||
const SuffixTable &street_name_suffix_table);
|
||||
|
||||
} // namespace intersection
|
||||
|
||||
@@ -6,7 +6,10 @@
|
||||
#include "extractor/intersection/have_identical_names.hpp"
|
||||
#include "extractor/restriction_index.hpp"
|
||||
#include "extractor/turn_lane_types.hpp"
|
||||
#include "extractor/name_table.hpp"
|
||||
|
||||
#include "guidance/intersection.hpp"
|
||||
|
||||
#include "util/coordinate.hpp"
|
||||
#include "util/node_based_graph.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
@@ -49,7 +52,7 @@ class MergableRoadDetector
|
||||
const RestrictionMap &node_restriction_map,
|
||||
const std::unordered_set<NodeID> &barrier_nodes,
|
||||
const TurnLanesIndexedArray &turn_lanes_data,
|
||||
const util::NameTable &name_table,
|
||||
const extractor::NameTable &name_table,
|
||||
const SuffixTable &street_name_suffix_table);
|
||||
|
||||
// OSM ways tend to be modelled as separate ways for different directions. This is often due to
|
||||
@@ -168,7 +171,7 @@ class MergableRoadDetector
|
||||
const TurnLanesIndexedArray &turn_lanes_data;
|
||||
|
||||
// name detection
|
||||
const util::NameTable &name_table;
|
||||
const extractor::NameTable &name_table;
|
||||
const SuffixTable &street_name_suffix_table;
|
||||
|
||||
const CoordinateExtractor coordinate_extractor;
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
#ifndef OSRM_EXTRACTOR_NAME_TABLE_HPP
|
||||
#define OSRM_EXTRACTOR_NAME_TABLE_HPP
|
||||
|
||||
#include "util/indexed_data.hpp"
|
||||
#include "util/string_view.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace extractor
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <storage::Ownership Ownership> class NameTableImpl;
|
||||
}
|
||||
|
||||
namespace serialization
|
||||
{
|
||||
template <storage::Ownership Ownership>
|
||||
inline void read(storage::tar::FileReader &reader,
|
||||
const std::string &name,
|
||||
detail::NameTableImpl<Ownership> &index_data);
|
||||
|
||||
template <storage::Ownership Ownership>
|
||||
inline void write(storage::tar::FileWriter &writer,
|
||||
const std::string &name,
|
||||
const detail::NameTableImpl<Ownership> &index_data);
|
||||
}
|
||||
|
||||
namespace detail
|
||||
{
|
||||
// This class provides a limited view over all the string data we serialize out.
|
||||
// The following functions are a subset of what is available.
|
||||
// See the data facades for they provide full access to this serialized string data.
|
||||
// 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.
|
||||
template <storage::Ownership Ownership> class NameTableImpl
|
||||
{
|
||||
public:
|
||||
using IndexedData =
|
||||
util::detail::IndexedDataImpl<util::VariableGroupBlock<16, util::StringView>, Ownership>;
|
||||
using ResultType = typename IndexedData::ResultType;
|
||||
using ValueType = typename IndexedData::ValueType;
|
||||
|
||||
NameTableImpl() {}
|
||||
|
||||
NameTableImpl(IndexedData indexed_data_) : indexed_data{std::move(indexed_data_)} {}
|
||||
|
||||
util::StringView GetNameForID(const NameID id) const
|
||||
{
|
||||
if (id == INVALID_NAMEID)
|
||||
return {};
|
||||
|
||||
return indexed_data.at(id + 0);
|
||||
}
|
||||
|
||||
util::StringView GetDestinationsForID(const NameID id) const
|
||||
{
|
||||
if (id == INVALID_NAMEID)
|
||||
return {};
|
||||
|
||||
return indexed_data.at(id + 1);
|
||||
}
|
||||
|
||||
util::StringView GetExitsForID(const NameID id) const
|
||||
{
|
||||
if (id == INVALID_NAMEID)
|
||||
return {};
|
||||
|
||||
return indexed_data.at(id + 4);
|
||||
}
|
||||
|
||||
util::StringView GetRefForID(const NameID id) const
|
||||
{
|
||||
if (id == INVALID_NAMEID)
|
||||
return {};
|
||||
|
||||
const constexpr auto OFFSET_REF = 3u;
|
||||
return indexed_data.at(id + OFFSET_REF);
|
||||
}
|
||||
|
||||
util::StringView GetPronunciationForID(const NameID id) const
|
||||
{
|
||||
if (id == INVALID_NAMEID)
|
||||
return {};
|
||||
|
||||
const constexpr auto OFFSET_PRONUNCIATION = 2u;
|
||||
return indexed_data.at(id + OFFSET_PRONUNCIATION);
|
||||
}
|
||||
|
||||
friend void serialization::read<Ownership>(storage::tar::FileReader &reader,
|
||||
const std::string &name,
|
||||
NameTableImpl &index_data);
|
||||
|
||||
friend void serialization::write<Ownership>(storage::tar::FileWriter &writer,
|
||||
const std::string &name,
|
||||
const NameTableImpl &index_data);
|
||||
private:
|
||||
IndexedData indexed_data;
|
||||
};
|
||||
}
|
||||
|
||||
using NameTable = detail::NameTableImpl<storage::Ownership::Container>;
|
||||
using NameTableView = detail::NameTableImpl<storage::Ownership::View>;
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif // OSRM_EXTRACTOR_NAME_TABLE_HPP
|
||||
@@ -1,10 +1,11 @@
|
||||
#ifndef OSRM_EXTRACTOR_IO_HPP
|
||||
#define OSRM_EXTRACTOR_IO_HPP
|
||||
|
||||
#include "conditional_turn_penalty.hpp"
|
||||
#include "extractor/conditional_turn_penalty.hpp"
|
||||
#include "extractor/datasources.hpp"
|
||||
#include "extractor/intersection_bearings_container.hpp"
|
||||
#include "extractor/maneuver_override.hpp"
|
||||
#include "extractor/name_table.hpp"
|
||||
#include "extractor/nbg_to_ebg.hpp"
|
||||
#include "extractor/node_data_container.hpp"
|
||||
#include "extractor/profile_properties.hpp"
|
||||
@@ -117,16 +118,18 @@ inline void read(storage::tar::FileReader &reader,
|
||||
{
|
||||
// read actual data
|
||||
storage::serialization::read(reader, name + "/nodes", node_data_container.nodes);
|
||||
storage::serialization::read(reader, name + "/annotations", node_data_container.annotation_data);
|
||||
storage::serialization::read(
|
||||
reader, name + "/annotations", node_data_container.annotation_data);
|
||||
}
|
||||
|
||||
template <storage::Ownership Ownership>
|
||||
inline void write(storage::tar::FileWriter &writer,
|
||||
const std::string& name,
|
||||
const std::string &name,
|
||||
const detail::EdgeBasedNodeDataContainerImpl<Ownership> &node_data_container)
|
||||
{
|
||||
storage::serialization::write(writer, name + "/nodes", node_data_container.nodes);
|
||||
storage::serialization::write(writer, name + "/annotations", node_data_container.annotation_data);
|
||||
storage::serialization::write(
|
||||
writer, name + "/annotations", node_data_container.annotation_data);
|
||||
}
|
||||
|
||||
inline void read(storage::io::FileReader &reader, NodeRestriction &restriction)
|
||||
@@ -307,7 +310,8 @@ inline void write(storage::io::BufferWriter &writer,
|
||||
}
|
||||
}
|
||||
|
||||
inline void read(storage::io::BufferReader &reader, std::vector<ConditionalTurnPenalty> &conditional_penalties)
|
||||
inline void read(storage::io::BufferReader &reader,
|
||||
std::vector<ConditionalTurnPenalty> &conditional_penalties)
|
||||
{
|
||||
auto num_elements = reader.ReadElementCount64();
|
||||
conditional_penalties.resize(num_elements);
|
||||
@@ -318,8 +322,8 @@ inline void read(storage::io::BufferReader &reader, std::vector<ConditionalTurnP
|
||||
}
|
||||
|
||||
inline void write(storage::tar::FileWriter &writer,
|
||||
const std::string& name,
|
||||
const std::vector<ConditionalTurnPenalty> &conditional_penalties)
|
||||
const std::string &name,
|
||||
const std::vector<ConditionalTurnPenalty> &conditional_penalties)
|
||||
{
|
||||
storage::io::BufferWriter buffer_writer;
|
||||
write(buffer_writer, conditional_penalties);
|
||||
@@ -328,7 +332,7 @@ inline void write(storage::tar::FileWriter &writer,
|
||||
}
|
||||
|
||||
inline void read(storage::tar::FileReader &reader,
|
||||
const std::string& name,
|
||||
const std::string &name,
|
||||
std::vector<ConditionalTurnPenalty> &conditional_penalties)
|
||||
{
|
||||
std::string buffer;
|
||||
@@ -336,9 +340,25 @@ inline void read(storage::tar::FileReader &reader,
|
||||
|
||||
storage::io::BufferReader buffer_reader{buffer};
|
||||
read(buffer_reader, conditional_penalties);
|
||||
|
||||
}
|
||||
|
||||
template <storage::Ownership Ownership>
|
||||
inline void write(storage::tar::FileWriter &writer,
|
||||
const std::string &name,
|
||||
const detail::NameTableImpl<Ownership> &name_table)
|
||||
{
|
||||
storage::io::BufferWriter buffer_writer;
|
||||
util::serialization::write(writer, name, name_table.indexed_data);
|
||||
}
|
||||
|
||||
template <storage::Ownership Ownership>
|
||||
inline void read(storage::tar::FileReader &reader,
|
||||
const std::string &name,
|
||||
detail::NameTableImpl<Ownership> &name_table)
|
||||
{
|
||||
std::string buffer;
|
||||
util::serialization::read(reader, name, name_table.indexed_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user