Refactor turn data into own class
This commit is contained in:
parent
865111bca9
commit
d7e1c9c09c
@ -841,14 +841,14 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
||||
return m_entry_class_table.at(entry_class_id);
|
||||
}
|
||||
|
||||
bool hasLaneData(const EdgeID id) const override final
|
||||
bool HasLaneData(const EdgeID id) const override final
|
||||
{
|
||||
return INVALID_LANE_DATAID != m_lane_data_id.at(id);
|
||||
}
|
||||
|
||||
util::guidance::LaneTupleIdPair GetLaneData(const EdgeID id) const override final
|
||||
{
|
||||
BOOST_ASSERT(hasLaneData(id));
|
||||
BOOST_ASSERT(HasLaneData(id));
|
||||
return m_lane_tupel_id_pairs.at(m_lane_data_id.at(id));
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ class BaseDataFacade
|
||||
const int bearing,
|
||||
const int bearing_range) const = 0;
|
||||
|
||||
virtual bool hasLaneData(const EdgeID id) const = 0;
|
||||
virtual bool HasLaneData(const EdgeID id) const = 0;
|
||||
virtual util::guidance::LaneTupleIdPair GetLaneData(const EdgeID id) const = 0;
|
||||
virtual extractor::guidance::TurnLaneDescription
|
||||
GetTurnDescription(const LaneDescriptionID lane_description_id) const = 0;
|
||||
|
@ -174,7 +174,7 @@ void annotatePath(const FacadeT &facade,
|
||||
util::guidance::TurnBearing(0)});
|
||||
}
|
||||
BOOST_ASSERT(unpacked_path.size() > 0);
|
||||
if (facade.hasLaneData(turn_id))
|
||||
if (facade.HasLaneData(turn_id))
|
||||
unpacked_path.back().lane_data = facade.GetLaneData(turn_id);
|
||||
|
||||
unpacked_path.back().entry_classid = facade.GetEntryClassID(turn_id);
|
||||
|
@ -65,6 +65,27 @@ inline void writeSegmentData(const boost::filesystem::path &path, const SegmentD
|
||||
|
||||
serialization::write(writer, segment_data);
|
||||
}
|
||||
|
||||
// reads .osrm.edges
|
||||
template<storage::Ownership Ownership>
|
||||
inline void readTurnData(const boost::filesystem::path &path, detail::TurnDataContainerImpl<Ownership> &turn_data)
|
||||
{
|
||||
const auto fingerprint = storage::io::FileReader::HasNoFingerprint;
|
||||
storage::io::FileReader reader{path, fingerprint};
|
||||
|
||||
serialization::read(reader, turn_data);
|
||||
}
|
||||
|
||||
// writes .osrm.edges
|
||||
template<storage::Ownership Ownership>
|
||||
inline void writeTurnData(const boost::filesystem::path &path, const detail::TurnDataContainerImpl<Ownership> &turn_data)
|
||||
{
|
||||
const auto fingerprint = storage::io::FileWriter::HasNoFingerprint;
|
||||
storage::io::FileWriter writer{path, fingerprint};
|
||||
|
||||
serialization::write(writer, turn_data);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -201,10 +201,10 @@ template <storage::Ownership Ownership> class SegmentDataContainerImpl
|
||||
|
||||
friend void
|
||||
serialization::read<Ownership>(storage::io::FileReader &reader,
|
||||
detail::SegmentDataContainerImpl<Ownership> &segment_data);
|
||||
friend void
|
||||
serialization::write<Ownership>(storage::io::FileWriter &writer,
|
||||
const detail::SegmentDataContainerImpl<Ownership> &segment_data);
|
||||
detail::SegmentDataContainerImpl<Ownership> &segment_data);
|
||||
friend void serialization::write<Ownership>(
|
||||
storage::io::FileWriter &writer,
|
||||
const detail::SegmentDataContainerImpl<Ownership> &segment_data);
|
||||
|
||||
private:
|
||||
Vector<std::uint32_t> index;
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "extractor/datasources.hpp"
|
||||
#include "extractor/nbg_to_ebg.hpp"
|
||||
#include "extractor/segment_data_container.hpp"
|
||||
#include "extractor/turn_data_container.hpp"
|
||||
|
||||
#include "storage/io.hpp"
|
||||
|
||||
@ -36,8 +37,9 @@ inline void write(storage::io::FileWriter &writer, Datasources &sources)
|
||||
writer.WriteFrom(sources);
|
||||
}
|
||||
|
||||
template <>
|
||||
inline void read(storage::io::FileReader &reader, SegmentDataContainer &segment_data)
|
||||
template <storage::Ownership Ownership>
|
||||
inline void read(storage::io::FileReader &reader,
|
||||
detail::SegmentDataContainerImpl<Ownership> &segment_data)
|
||||
{
|
||||
auto num_indices = reader.ReadElementCount32();
|
||||
segment_data.index.resize(num_indices);
|
||||
@ -59,8 +61,9 @@ inline void read(storage::io::FileReader &reader, SegmentDataContainer &segment_
|
||||
reader.ReadInto(segment_data.datasources);
|
||||
}
|
||||
|
||||
template <>
|
||||
inline void write(storage::io::FileWriter &writer, const SegmentDataContainer &segment_data)
|
||||
template <storage::Ownership Ownership>
|
||||
inline void write(storage::io::FileWriter &writer,
|
||||
const detail::SegmentDataContainerImpl<Ownership> &segment_data)
|
||||
{
|
||||
writer.WriteElementCount32(segment_data.index.size());
|
||||
writer.WriteFrom(segment_data.index);
|
||||
@ -78,6 +81,34 @@ inline void write(storage::io::FileWriter &writer, const SegmentDataContainer &s
|
||||
writer.WriteFrom(segment_data.rev_durations);
|
||||
writer.WriteFrom(segment_data.datasources);
|
||||
}
|
||||
|
||||
template <storage::Ownership Ownership>
|
||||
inline void read(storage::io::FileReader &reader,
|
||||
detail::TurnDataContainerImpl<Ownership> &turn_data_container)
|
||||
{
|
||||
reader.DeserializeVector(turn_data_container.geometry_ids);
|
||||
reader.DeserializeVector(turn_data_container.name_ids);
|
||||
reader.DeserializeVector(turn_data_container.turn_instructions);
|
||||
reader.DeserializeVector(turn_data_container.lane_data_ids);
|
||||
reader.DeserializeVector(turn_data_container.travel_modes);
|
||||
reader.DeserializeVector(turn_data_container.entry_class_ids);
|
||||
reader.DeserializeVector(turn_data_container.pre_turn_bearings);
|
||||
reader.DeserializeVector(turn_data_container.post_turn_bearings);
|
||||
}
|
||||
|
||||
template <storage::Ownership Ownership>
|
||||
inline void write(storage::io::FileWriter &writer,
|
||||
const detail::TurnDataContainerImpl<Ownership> &turn_data_container)
|
||||
{
|
||||
writer.SerializeVector(turn_data_container.geometry_ids);
|
||||
writer.SerializeVector(turn_data_container.name_ids);
|
||||
writer.SerializeVector(turn_data_container.turn_instructions);
|
||||
writer.SerializeVector(turn_data_container.lane_data_ids);
|
||||
writer.SerializeVector(turn_data_container.travel_modes);
|
||||
writer.SerializeVector(turn_data_container.entry_class_ids);
|
||||
writer.SerializeVector(turn_data_container.pre_turn_bearings);
|
||||
writer.SerializeVector(turn_data_container.post_turn_bearings);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
134
include/extractor/turn_data_container.hpp
Normal file
134
include/extractor/turn_data_container.hpp
Normal file
@ -0,0 +1,134 @@
|
||||
#ifndef OSRM_EXTRACTOR_TURN_DATA_CONTAINER_HPP
|
||||
#define OSRM_EXTRACTOR_TURN_DATA_CONTAINER_HPP
|
||||
|
||||
#include "extractor/guidance/turn_instruction.hpp"
|
||||
#include "extractor/travel_mode.hpp"
|
||||
|
||||
#include "storage/shared_memory_ownership.hpp"
|
||||
#include "util/guidance/turn_bearing.hpp"
|
||||
#include "util/shared_memory_vector_wrapper.hpp"
|
||||
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
|
||||
namespace storage
|
||||
{
|
||||
namespace io
|
||||
{
|
||||
class FileReader;
|
||||
class FileWriter;
|
||||
}
|
||||
}
|
||||
|
||||
namespace extractor
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
template <storage::Ownership Ownership> class TurnDataContainerImpl;
|
||||
}
|
||||
|
||||
namespace serialization
|
||||
{
|
||||
template <storage::Ownership Ownership>
|
||||
void read(storage::io::FileReader &reader, detail::TurnDataContainerImpl<Ownership> &turn_data);
|
||||
|
||||
template <storage::Ownership Ownership>
|
||||
void write(storage::io::FileWriter &writer,
|
||||
const detail::TurnDataContainerImpl<Ownership> &turn_data);
|
||||
}
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <storage::Ownership Ownership> class TurnDataContainerImpl
|
||||
{
|
||||
template <typename T> using Vector = typename util::ShM<T, Ownership>::vector;
|
||||
|
||||
public:
|
||||
TurnDataContainerImpl() = default;
|
||||
|
||||
TurnDataContainerImpl(Vector<GeometryID> geometry_ids_,
|
||||
Vector<NameID> name_ids_,
|
||||
Vector<extractor::guidance::TurnInstruction> turn_instructions_,
|
||||
Vector<LaneDataID> lane_data_ids_,
|
||||
Vector<extractor::TravelMode> travel_modes_,
|
||||
Vector<EntryClassID> entry_class_ids_,
|
||||
Vector<util::guidance::TurnBearing> pre_turn_bearings_,
|
||||
Vector<util::guidance::TurnBearing> post_turn_bearings_)
|
||||
: geometry_ids(std::move(geometry_ids_)), name_ids(std::move(name_ids_)),
|
||||
turn_instructions(std::move(turn_instructions_)),
|
||||
lane_data_ids(std::move(lane_data_ids_)), travel_modes(std::move(travel_modes_)),
|
||||
entry_class_ids(std::move(entry_class_ids_)),
|
||||
pre_turn_bearings(std::move(pre_turn_bearings_)),
|
||||
post_turn_bearings(std::move(post_turn_bearings_))
|
||||
{
|
||||
}
|
||||
|
||||
GeometryID GetGeometryID(const EdgeID id) const { return geometry_ids[id]; }
|
||||
|
||||
EntryClassID GetEntryClassID(const EdgeID id) const { return entry_class_ids[id]; }
|
||||
|
||||
util::guidance::TurnBearing GetPreTurnBearing(const EdgeID id) const
|
||||
{
|
||||
return pre_turn_bearings[id];
|
||||
}
|
||||
|
||||
util::guidance::TurnBearing GetPostTurnBearing(const EdgeID id) const
|
||||
{
|
||||
return post_turn_bearings[id];
|
||||
}
|
||||
|
||||
bool HasLaneData(const EdgeID id) const { return INVALID_LANE_DATAID != lane_data_ids[id]; }
|
||||
|
||||
NameID GetNameID(const EdgeID id) const { return name_ids[id]; }
|
||||
|
||||
extractor::guidance::TurnInstruction GetTurnInstruction(const EdgeID id) const
|
||||
{
|
||||
return turn_instructions[id];
|
||||
}
|
||||
|
||||
// Used by EdgeBasedGraphFactory to fill data structure
|
||||
template <typename = std::enable_if<Ownership == storage::Ownership::Container>>
|
||||
void push_back(GeometryID geometry_id,
|
||||
NameID name_id,
|
||||
extractor::guidance::TurnInstruction turn_instruction,
|
||||
LaneDataID lane_data_id,
|
||||
EntryClassID entry_class_id,
|
||||
extractor::TravelMode travel_mode,
|
||||
util::guidance::TurnBearing pre_turn_bearing,
|
||||
util::guidance::TurnBearing post_turn_bearing)
|
||||
{
|
||||
geometry_ids.push_back(geometry_id);
|
||||
name_ids.push_back(name_id);
|
||||
turn_instructions.push_back(turn_instruction);
|
||||
lane_data_ids.push_back(lane_data_id);
|
||||
travel_modes.push_back(travel_mode);
|
||||
entry_class_ids.push_back(entry_class_id);
|
||||
pre_turn_bearings.push_back(pre_turn_bearing);
|
||||
post_turn_bearings.push_back(post_turn_bearing);
|
||||
}
|
||||
|
||||
friend void serialization::read<Ownership>(storage::io::FileReader &reader,
|
||||
TurnDataContainerImpl &turn_data_container);
|
||||
friend void serialization::write<Ownership>(storage::io::FileWriter &writer,
|
||||
const TurnDataContainerImpl &turn_data_container);
|
||||
|
||||
private:
|
||||
Vector<GeometryID> geometry_ids;
|
||||
Vector<NameID> name_ids;
|
||||
Vector<extractor::guidance::TurnInstruction> turn_instructions;
|
||||
Vector<LaneDataID> lane_data_ids;
|
||||
Vector<extractor::TravelMode> travel_modes;
|
||||
Vector<EntryClassID> entry_class_ids;
|
||||
Vector<util::guidance::TurnBearing> pre_turn_bearings;
|
||||
Vector<util::guidance::TurnBearing> post_turn_bearings;
|
||||
};
|
||||
}
|
||||
|
||||
using TurnDataContainer = detail::TurnDataContainerImpl<storage::Ownership::Container>;
|
||||
using TurnDataView = detail::TurnDataContainerImpl<storage::Ownership::View>;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -128,7 +128,7 @@ class FileReader
|
||||
std::uint32_t ReadElementCount32() { return ReadOne<std::uint32_t>(); }
|
||||
std::uint64_t ReadElementCount64() { return ReadOne<std::uint64_t>(); }
|
||||
|
||||
template <typename T> void DeserializeVector(std::vector<T> &data)
|
||||
template <typename VectorT> void DeserializeVector(VectorT &data)
|
||||
{
|
||||
const auto count = ReadElementCount64();
|
||||
data.resize(count);
|
||||
@ -296,7 +296,7 @@ class FileWriter
|
||||
void WriteElementCount32(const std::uint32_t count) { WriteOne<std::uint32_t>(count); }
|
||||
void WriteElementCount64(const std::uint64_t count) { WriteOne<std::uint64_t>(count); }
|
||||
|
||||
template <typename T> void SerializeVector(const std::vector<T> &data)
|
||||
template <typename VectorT> void SerializeVector(const VectorT &data)
|
||||
{
|
||||
const auto count = data.size();
|
||||
WriteElementCount64(count);
|
||||
|
@ -70,42 +70,6 @@ inline void readHSGR(io::FileReader &input_file,
|
||||
input_file.ReadInto(edge_buffer, number_of_edges);
|
||||
}
|
||||
|
||||
// Loads edge data from .edge files into memory which includes its
|
||||
// geometry, name ID, turn instruction, lane data ID, travel mode, entry class ID
|
||||
// Needs to be called after readElementCount() to get the correct offset in the stream
|
||||
inline void readEdges(io::FileReader &edges_input_file,
|
||||
GeometryID *geometry_list,
|
||||
NameID *name_id_list,
|
||||
extractor::guidance::TurnInstruction *turn_instruction_list,
|
||||
LaneDataID *lane_data_id_list,
|
||||
extractor::TravelMode *travel_mode_list,
|
||||
EntryClassID *entry_class_id_list,
|
||||
util::guidance::TurnBearing *pre_turn_bearing_list,
|
||||
util::guidance::TurnBearing *post_turn_bearing_list,
|
||||
const std::uint64_t number_of_edges)
|
||||
{
|
||||
BOOST_ASSERT(geometry_list);
|
||||
BOOST_ASSERT(name_id_list);
|
||||
BOOST_ASSERT(turn_instruction_list);
|
||||
BOOST_ASSERT(lane_data_id_list);
|
||||
BOOST_ASSERT(travel_mode_list);
|
||||
BOOST_ASSERT(entry_class_id_list);
|
||||
extractor::OriginalEdgeData current_edge_data;
|
||||
for (std::uint64_t i = 0; i < number_of_edges; ++i)
|
||||
{
|
||||
edges_input_file.ReadInto(current_edge_data);
|
||||
|
||||
geometry_list[i] = current_edge_data.via_geometry;
|
||||
name_id_list[i] = current_edge_data.name_id;
|
||||
turn_instruction_list[i] = current_edge_data.turn_instruction;
|
||||
lane_data_id_list[i] = current_edge_data.lane_data_id;
|
||||
travel_mode_list[i] = current_edge_data.travel_mode;
|
||||
entry_class_id_list[i] = current_edge_data.entry_classid;
|
||||
pre_turn_bearing_list[i] = current_edge_data.pre_turn_bearing;
|
||||
post_turn_bearing_list[i] = current_edge_data.post_turn_bearing;
|
||||
}
|
||||
}
|
||||
|
||||
// Loads coordinates and OSM node IDs from .nodes files into memory
|
||||
// Needs to be called after readElementCount() to get the correct offset in the stream
|
||||
template <typename OSMNodeIDVectorT>
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define SHARED_MEMORY_VECTOR_WRAPPER_HPP
|
||||
|
||||
#include "util/log.hpp"
|
||||
#include "util/exception.hpp"
|
||||
|
||||
#include "storage/shared_memory_ownership.hpp"
|
||||
|
||||
@ -82,6 +83,15 @@ template <typename DataT> class vector_view
|
||||
m_size = size;
|
||||
}
|
||||
|
||||
// for a vector-like interface
|
||||
void resize(std::size_t size) const
|
||||
{
|
||||
if(m_size != size)
|
||||
{
|
||||
throw util::exception("Invalid resize on immutable shared memory vector.");
|
||||
}
|
||||
}
|
||||
|
||||
DataT &at(const std::size_t index) { return m_ptr[index]; }
|
||||
|
||||
const DataT &at(const std::size_t index) const { return m_ptr[index]; }
|
||||
@ -128,7 +138,8 @@ template <typename DataT> class vector_view
|
||||
|
||||
auto data() const { return m_ptr; }
|
||||
|
||||
template <typename T> friend void swap(vector_view<T> &, vector_view<T> &) noexcept;
|
||||
template <typename T>
|
||||
friend void swap(vector_view<T> &, vector_view<T> &) noexcept;
|
||||
};
|
||||
|
||||
template <> class vector_view<bool>
|
||||
@ -138,6 +149,8 @@ template <> class vector_view<bool>
|
||||
std::size_t m_size;
|
||||
|
||||
public:
|
||||
using value_type = bool;
|
||||
|
||||
vector_view() : m_ptr(nullptr), m_size(0) {}
|
||||
|
||||
vector_view(unsigned *ptr, std::size_t size) : m_ptr(ptr), m_size(size) {}
|
||||
@ -150,12 +163,20 @@ template <> class vector_view<bool>
|
||||
return m_ptr[bucket] & (1u << offset);
|
||||
}
|
||||
|
||||
void reset(unsigned *ptr, std::size_t size)
|
||||
void reset(unsigned *, std::size_t size)
|
||||
{
|
||||
m_ptr = ptr;
|
||||
m_size = size;
|
||||
}
|
||||
|
||||
// for ensuring a vector compatible interface
|
||||
void resize(std::size_t size) const
|
||||
{
|
||||
if(m_size != size)
|
||||
{
|
||||
throw util::exception("Invalid resize on immutable shared memory vector.");
|
||||
}
|
||||
}
|
||||
|
||||
std::size_t size() const { return m_size; }
|
||||
|
||||
bool empty() const { return 0 == size(); }
|
||||
@ -178,6 +199,7 @@ template <typename DataT, storage::Ownership Ownership> struct ShM
|
||||
vector_view<DataT>,
|
||||
std::vector<DataT>>::type;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -175,22 +175,8 @@ NBGToEBG EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, const N
|
||||
return NBGToEBG{node_u, node_v, forward_data.edge_id, reverse_data.edge_id};
|
||||
}
|
||||
|
||||
void EdgeBasedGraphFactory::FlushVectorToStream(
|
||||
storage::io::FileWriter &edge_data_file,
|
||||
std::vector<OriginalEdgeData> &original_edge_data_vector) const
|
||||
{
|
||||
if (original_edge_data_vector.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
edge_data_file.WriteFrom(original_edge_data_vector.data(), original_edge_data_vector.size());
|
||||
|
||||
original_edge_data_vector.clear();
|
||||
}
|
||||
|
||||
void EdgeBasedGraphFactory::Run(ScriptingEnvironment &scripting_environment,
|
||||
const std::string &original_edge_data_filename,
|
||||
const std::string &turn_data_filename,
|
||||
const std::string &turn_lane_data_filename,
|
||||
const std::string &turn_weight_penalties_filename,
|
||||
const std::string &turn_duration_penalties_filename,
|
||||
@ -211,7 +197,7 @@ void EdgeBasedGraphFactory::Run(ScriptingEnvironment &scripting_environment,
|
||||
|
||||
TIMER_START(generate_edges);
|
||||
GenerateEdgeExpandedEdges(scripting_environment,
|
||||
original_edge_data_filename,
|
||||
turn_data_filename,
|
||||
turn_lane_data_filename,
|
||||
turn_weight_penalties_filename,
|
||||
turn_duration_penalties_filename,
|
||||
@ -312,10 +298,10 @@ std::vector<NBGToEBG> EdgeBasedGraphFactory::GenerateEdgeExpandedNodes()
|
||||
return mapping;
|
||||
}
|
||||
|
||||
/// Actually it also generates OriginalEdgeData and serializes them...
|
||||
/// Actually it also generates turn data and serializes them...
|
||||
void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
|
||||
ScriptingEnvironment &scripting_environment,
|
||||
const std::string &original_edge_data_filename,
|
||||
const std::string &turn_data_filename,
|
||||
const std::string &turn_lane_data_filename,
|
||||
const std::string &turn_weight_penalties_filename,
|
||||
const std::string &turn_duration_penalties_filename,
|
||||
@ -324,22 +310,15 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
|
||||
util::Log() << "Generating edge-expanded edges ";
|
||||
|
||||
std::size_t node_based_edge_counter = 0;
|
||||
std::size_t original_edges_counter = 0;
|
||||
restricted_turns_counter = 0;
|
||||
skipped_uturns_counter = 0;
|
||||
skipped_barrier_turns_counter = 0;
|
||||
|
||||
storage::io::FileWriter edge_data_file(original_edge_data_filename,
|
||||
storage::io::FileWriter::HasNoFingerprint);
|
||||
|
||||
storage::io::FileWriter turn_penalties_index_file(turn_penalties_index_filename,
|
||||
storage::io::FileWriter::HasNoFingerprint);
|
||||
|
||||
// Writes a dummy value at the front that is updated later with the total length
|
||||
edge_data_file.WriteElementCount64(0);
|
||||
|
||||
std::vector<OriginalEdgeData> original_edge_data_vector;
|
||||
original_edge_data_vector.reserve(1024 * 1024);
|
||||
// TODO investigate increased peak memory consumption by keeping this in memory now
|
||||
TurnDataContainer turn_data_container;
|
||||
|
||||
// Loop over all turns and generate new set of edges.
|
||||
// Three nested loop look super-linear, but we are dealing with a (kind of)
|
||||
@ -489,13 +468,13 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
|
||||
BOOST_ASSERT(is_encoded_forwards || is_encoded_backwards);
|
||||
if (is_encoded_forwards)
|
||||
{
|
||||
original_edge_data_vector.emplace_back(
|
||||
turn_data_container.push_back(
|
||||
GeometryID{m_compressed_edge_container.GetZippedPositionForForwardID(
|
||||
incoming_edge),
|
||||
true},
|
||||
edge_data1.name_id,
|
||||
turn.lane_data_id,
|
||||
turn.instruction,
|
||||
turn.lane_data_id,
|
||||
entry_class_id,
|
||||
edge_data1.travel_mode,
|
||||
util::guidance::TurnBearing(intersection[0].bearing),
|
||||
@ -503,25 +482,19 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
|
||||
}
|
||||
else if (is_encoded_backwards)
|
||||
{
|
||||
original_edge_data_vector.emplace_back(
|
||||
turn_data_container.push_back(
|
||||
GeometryID{m_compressed_edge_container.GetZippedPositionForReverseID(
|
||||
incoming_edge),
|
||||
false},
|
||||
edge_data1.name_id,
|
||||
turn.lane_data_id,
|
||||
turn.instruction,
|
||||
turn.lane_data_id,
|
||||
entry_class_id,
|
||||
edge_data1.travel_mode,
|
||||
util::guidance::TurnBearing(intersection[0].bearing),
|
||||
util::guidance::TurnBearing(turn.bearing));
|
||||
}
|
||||
|
||||
++original_edges_counter;
|
||||
if (original_edge_data_vector.size() > 1024 * 1024 * 10)
|
||||
{
|
||||
FlushVectorToStream(edge_data_file, original_edge_data_vector);
|
||||
}
|
||||
|
||||
// compute weight and duration penalties
|
||||
auto is_traffic_light = m_traffic_lights.count(node_at_center_of_intersection);
|
||||
ExtractionTurn extracted_turn(turn, is_traffic_light);
|
||||
@ -554,7 +527,6 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
|
||||
duration,
|
||||
true,
|
||||
false);
|
||||
BOOST_ASSERT(original_edges_counter == m_edge_based_edge_list.size());
|
||||
|
||||
BOOST_ASSERT(turn_weight_penalties.size() == turn_id);
|
||||
turn_weight_penalties.push_back(weight_penalty);
|
||||
@ -626,13 +598,7 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
|
||||
|
||||
util::Log() << "done.";
|
||||
|
||||
FlushVectorToStream(edge_data_file, original_edge_data_vector);
|
||||
|
||||
// Finally jump back to the empty space at the beginning and write length prefix
|
||||
edge_data_file.SkipToBeginning();
|
||||
|
||||
const auto length_prefix = boost::numeric_cast<std::uint64_t>(original_edges_counter);
|
||||
edge_data_file.WriteElementCount64(length_prefix);
|
||||
files::writeTurnData(turn_data_filename, turn_data_container);
|
||||
|
||||
util::Log() << "Generated " << m_edge_based_node_list.size() << " edge based nodes";
|
||||
util::Log() << "Node-based graph contains " << node_based_edge_counter << " edges";
|
||||
|
@ -3,8 +3,8 @@
|
||||
#include "customizer/edge_based_graph.hpp"
|
||||
#include "extractor/compressed_edge_container.hpp"
|
||||
#include "extractor/edge_based_edge.hpp"
|
||||
#include "extractor/guidance/turn_instruction.hpp"
|
||||
#include "extractor/files.hpp"
|
||||
#include "extractor/guidance/turn_instruction.hpp"
|
||||
#include "extractor/original_edge_data.hpp"
|
||||
#include "extractor/profile_properties.hpp"
|
||||
#include "extractor/query_node.hpp"
|
||||
@ -56,9 +56,8 @@ namespace storage
|
||||
{
|
||||
|
||||
using RTreeLeaf = engine::datafacade::BaseDataFacade::RTreeLeaf;
|
||||
using RTreeNode = util::StaticRTree<RTreeLeaf,
|
||||
util::vector_view<util::Coordinate>,
|
||||
storage::Ownership::View>::TreeNode;
|
||||
using RTreeNode = util::
|
||||
StaticRTree<RTreeLeaf, util::vector_view<util::Coordinate>, storage::Ownership::View>::TreeNode;
|
||||
using QueryGraph = util::StaticGraph<contractor::QueryEdge::EdgeData>;
|
||||
using EdgeBasedGraph = util::StaticGraph<extractor::EdgeBasedEdge::EdgeData>;
|
||||
|
||||
@ -596,43 +595,57 @@ void Storage::PopulateData(const DataLayout &layout, char *memory_ptr)
|
||||
|
||||
// Load original edge data
|
||||
{
|
||||
io::FileReader edges_input_file(config.edges_data_path, io::FileReader::HasNoFingerprint);
|
||||
auto via_geometry_list_ptr =
|
||||
layout.GetBlockPtr<GeometryID, true>(memory_ptr, storage::DataLayout::VIA_NODE_LIST);
|
||||
util::vector_view<GeometryID> geometry_ids(
|
||||
via_geometry_list_ptr, layout.num_entries[storage::DataLayout::VIA_NODE_LIST]);
|
||||
|
||||
const auto number_of_original_edges = edges_input_file.ReadElementCount64();
|
||||
|
||||
const auto via_geometry_ptr =
|
||||
layout.GetBlockPtr<GeometryID, true>(memory_ptr, DataLayout::VIA_NODE_LIST);
|
||||
|
||||
const auto name_id_ptr =
|
||||
layout.GetBlockPtr<unsigned, true>(memory_ptr, DataLayout::NAME_ID_LIST);
|
||||
|
||||
const auto travel_mode_ptr =
|
||||
layout.GetBlockPtr<extractor::TravelMode, true>(memory_ptr, DataLayout::TRAVEL_MODE);
|
||||
const auto pre_turn_bearing_ptr = layout.GetBlockPtr<util::guidance::TurnBearing, true>(
|
||||
memory_ptr, DataLayout::PRE_TURN_BEARING);
|
||||
const auto post_turn_bearing_ptr = layout.GetBlockPtr<util::guidance::TurnBearing, true>(
|
||||
memory_ptr, DataLayout::POST_TURN_BEARING);
|
||||
const auto travel_mode_list_ptr = layout.GetBlockPtr<extractor::TravelMode, true>(
|
||||
memory_ptr, storage::DataLayout::TRAVEL_MODE);
|
||||
util::vector_view<extractor::TravelMode> travel_modes(
|
||||
travel_mode_list_ptr, layout.num_entries[storage::DataLayout::TRAVEL_MODE]);
|
||||
|
||||
const auto lane_data_id_ptr =
|
||||
layout.GetBlockPtr<LaneDataID, true>(memory_ptr, DataLayout::LANE_DATA_ID);
|
||||
layout.GetBlockPtr<LaneDataID, true>(memory_ptr, storage::DataLayout::LANE_DATA_ID);
|
||||
util::vector_view<LaneDataID> lane_data_ids(
|
||||
lane_data_id_ptr, layout.num_entries[storage::DataLayout::LANE_DATA_ID]);
|
||||
|
||||
const auto turn_instructions_ptr =
|
||||
const auto turn_instruction_list_ptr =
|
||||
layout.GetBlockPtr<extractor::guidance::TurnInstruction, true>(
|
||||
memory_ptr, DataLayout::TURN_INSTRUCTION);
|
||||
memory_ptr, storage::DataLayout::TURN_INSTRUCTION);
|
||||
util::vector_view<extractor::guidance::TurnInstruction> turn_instructions(
|
||||
turn_instruction_list_ptr, layout.num_entries[storage::DataLayout::TURN_INSTRUCTION]);
|
||||
|
||||
const auto entry_class_id_ptr =
|
||||
layout.GetBlockPtr<EntryClassID, true>(memory_ptr, DataLayout::ENTRY_CLASSID);
|
||||
const auto name_id_list_ptr =
|
||||
layout.GetBlockPtr<NameID, true>(memory_ptr, storage::DataLayout::NAME_ID_LIST);
|
||||
util::vector_view<NameID> name_ids(name_id_list_ptr,
|
||||
layout.num_entries[storage::DataLayout::NAME_ID_LIST]);
|
||||
|
||||
serialization::readEdges(edges_input_file,
|
||||
via_geometry_ptr,
|
||||
name_id_ptr,
|
||||
turn_instructions_ptr,
|
||||
lane_data_id_ptr,
|
||||
travel_mode_ptr,
|
||||
entry_class_id_ptr,
|
||||
pre_turn_bearing_ptr,
|
||||
post_turn_bearing_ptr,
|
||||
number_of_original_edges);
|
||||
const auto entry_class_id_list_ptr =
|
||||
layout.GetBlockPtr<EntryClassID, true>(memory_ptr, storage::DataLayout::ENTRY_CLASSID);
|
||||
util::vector_view<EntryClassID> entry_class_ids(
|
||||
entry_class_id_list_ptr, layout.num_entries[storage::DataLayout::ENTRY_CLASSID]);
|
||||
|
||||
const auto pre_turn_bearing_ptr = layout.GetBlockPtr<util::guidance::TurnBearing, true>(
|
||||
memory_ptr, storage::DataLayout::PRE_TURN_BEARING);
|
||||
util::vector_view<util::guidance::TurnBearing> pre_turn_bearings(
|
||||
pre_turn_bearing_ptr, layout.num_entries[storage::DataLayout::PRE_TURN_BEARING]);
|
||||
|
||||
const auto post_turn_bearing_ptr = layout.GetBlockPtr<util::guidance::TurnBearing, true>(
|
||||
memory_ptr, storage::DataLayout::POST_TURN_BEARING);
|
||||
util::vector_view<util::guidance::TurnBearing> post_turn_bearings(
|
||||
post_turn_bearing_ptr, layout.num_entries[storage::DataLayout::POST_TURN_BEARING]);
|
||||
|
||||
extractor::TurnDataView turn_data(std::move(geometry_ids),
|
||||
std::move(name_ids),
|
||||
std::move(turn_instructions),
|
||||
std::move(lane_data_ids),
|
||||
std::move(travel_modes),
|
||||
std::move(entry_class_ids),
|
||||
std::move(pre_turn_bearings),
|
||||
std::move(post_turn_bearings));
|
||||
|
||||
extractor::files::readTurnData(config.edges_data_path, turn_data);
|
||||
}
|
||||
|
||||
// load compressed geometry
|
||||
|
@ -83,20 +83,15 @@ void checkWeightsConsistency(
|
||||
const UpdaterConfig &config,
|
||||
const std::vector<osrm::extractor::EdgeBasedEdge> &edge_based_edge_list)
|
||||
{
|
||||
using Reader = storage::io::FileReader;
|
||||
using OriginalEdgeData = osrm::extractor::OriginalEdgeData;
|
||||
|
||||
extractor::SegmentDataContainer segment_data;
|
||||
extractor::files::readSegmentData(config.geometry_path, segment_data);
|
||||
|
||||
Reader edges_input_file(config.osrm_input_path.string() + ".edges", Reader::HasNoFingerprint);
|
||||
std::vector<OriginalEdgeData> current_edge_data(edges_input_file.ReadElementCount64());
|
||||
edges_input_file.ReadInto(current_edge_data);
|
||||
extractor::TurnDataContainer turn_data;
|
||||
extractor::files::readTurnData(config.osrm_input_path.string() + ".edges", turn_data);
|
||||
|
||||
for (auto &edge : edge_based_edge_list)
|
||||
{
|
||||
BOOST_ASSERT(edge.data.turn_id < current_edge_data.size());
|
||||
auto geometry_id = current_edge_data[edge.data.turn_id].via_geometry;
|
||||
auto geometry_id = turn_data.GetGeometryID(edge.data.turn_id);
|
||||
|
||||
if (geometry_id.forward)
|
||||
{
|
||||
@ -453,9 +448,9 @@ Updater::LoadAndUpdateEdgeExpandedGraph(std::vector<extractor::EdgeBasedEdge> &e
|
||||
throw util::exception("Limit of 255 segment speed and turn penalty files each reached" +
|
||||
SOURCE_REF);
|
||||
|
||||
extractor::ProfileProperties profile_properties;
|
||||
std::vector<extractor::OriginalEdgeData> edge_data;
|
||||
extractor::TurnDataContainer turn_data;
|
||||
extractor::SegmentDataContainer segment_data;
|
||||
extractor::ProfileProperties profile_properties;
|
||||
std::vector<TurnPenalty> turn_weight_penalties;
|
||||
std::vector<TurnPenalty> turn_duration_penalties;
|
||||
if (update_edge_weights || update_turn_penalties)
|
||||
@ -465,9 +460,7 @@ Updater::LoadAndUpdateEdgeExpandedGraph(std::vector<extractor::EdgeBasedEdge> &e
|
||||
};
|
||||
|
||||
const auto load_edge_data = [&] {
|
||||
storage::io::FileReader edges_input_file(config.edge_data_path,
|
||||
storage::io::FileReader::HasNoFingerprint);
|
||||
edges_input_file.DeserializeVector(edge_data);
|
||||
extractor::files::readTurnData(config.edge_data_path, turn_data);
|
||||
};
|
||||
|
||||
const auto load_turn_weight_penalties = [&] {
|
||||
@ -525,8 +518,8 @@ Updater::LoadAndUpdateEdgeExpandedGraph(std::vector<extractor::EdgeBasedEdge> &e
|
||||
std::transform(updated_turn_penalties.begin(),
|
||||
updated_turn_penalties.end(),
|
||||
updated_segments.begin() + offset,
|
||||
[&edge_data](const std::uint64_t edge_index) {
|
||||
return edge_data[edge_index].via_geometry;
|
||||
[&turn_data](const std::uint64_t turn_id) {
|
||||
return turn_data.GetGeometryID(turn_id);
|
||||
});
|
||||
}
|
||||
|
||||
@ -585,7 +578,7 @@ Updater::LoadAndUpdateEdgeExpandedGraph(std::vector<extractor::EdgeBasedEdge> &e
|
||||
});
|
||||
|
||||
const auto update_edge = [&](extractor::EdgeBasedEdge &edge) {
|
||||
const auto geometry_id = edge_data[edge.data.turn_id].via_geometry;
|
||||
const auto geometry_id = turn_data.GetGeometryID(edge.data.turn_id);
|
||||
auto updated_iter = std::lower_bound(updated_segments.begin(),
|
||||
updated_segments.end(),
|
||||
geometry_id,
|
||||
|
@ -203,7 +203,7 @@ class MockBaseDataFacade : public engine::datafacade::BaseDataFacade
|
||||
return util::guidance::TurnBearing{0.0};
|
||||
}
|
||||
|
||||
bool hasLaneData(const EdgeID /*id*/) const override final { return true; };
|
||||
bool HasLaneData(const EdgeID /*id*/) const override final { return true; };
|
||||
util::guidance::LaneTupleIdPair GetLaneData(const EdgeID /*id*/) const override final
|
||||
{
|
||||
return {{0, 0}, 0};
|
||||
|
Loading…
Reference in New Issue
Block a user