Port isc file
This commit is contained in:
parent
37b8d3acd4
commit
e5464526c8
@ -14,6 +14,7 @@
|
|||||||
#include "extractor/datasources.hpp"
|
#include "extractor/datasources.hpp"
|
||||||
#include "extractor/guidance/turn_instruction.hpp"
|
#include "extractor/guidance/turn_instruction.hpp"
|
||||||
#include "extractor/guidance/turn_lane_types.hpp"
|
#include "extractor/guidance/turn_lane_types.hpp"
|
||||||
|
#include "extractor/intersection_bearings_container.hpp"
|
||||||
#include "extractor/node_data_container.hpp"
|
#include "extractor/node_data_container.hpp"
|
||||||
#include "extractor/packed_osm_ids.hpp"
|
#include "extractor/packed_osm_ids.hpp"
|
||||||
#include "extractor/profile_properties.hpp"
|
#include "extractor/profile_properties.hpp"
|
||||||
@ -218,7 +219,6 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
|||||||
unsigned m_check_sum;
|
unsigned m_check_sum;
|
||||||
util::vector_view<util::Coordinate> m_coordinate_list;
|
util::vector_view<util::Coordinate> m_coordinate_list;
|
||||||
extractor::PackedOSMIDsView m_osmnodeid_list;
|
extractor::PackedOSMIDsView m_osmnodeid_list;
|
||||||
util::NameTable m_names_table;
|
|
||||||
util::vector_view<std::uint32_t> m_lane_description_offsets;
|
util::vector_view<std::uint32_t> m_lane_description_offsets;
|
||||||
util::vector_view<extractor::guidance::TurnLaneType::Mask> m_lane_description_masks;
|
util::vector_view<extractor::guidance::TurnLaneType::Mask> m_lane_description_masks;
|
||||||
util::vector_view<TurnPenalty> m_turn_weight_penalties;
|
util::vector_view<TurnPenalty> m_turn_weight_penalties;
|
||||||
@ -236,19 +236,12 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
|||||||
std::unique_ptr<SharedGeospatialQuery> m_geospatial_query;
|
std::unique_ptr<SharedGeospatialQuery> m_geospatial_query;
|
||||||
boost::filesystem::path file_index_path;
|
boost::filesystem::path file_index_path;
|
||||||
|
|
||||||
util::NameTable m_name_table;
|
extractor::IntersectionBearingsView intersection_bearings_view;
|
||||||
// bearing classes by node based node
|
|
||||||
util::vector_view<BearingClassID> m_bearing_class_id_table;
|
|
||||||
// entry class IDs
|
|
||||||
util::vector_view<EntryClassID> m_entry_class_id_list;
|
|
||||||
|
|
||||||
|
util::NameTable m_name_table;
|
||||||
// the look-up table for entry classes. An entry class lists the possibility of entry for all
|
// the look-up table for entry classes. An entry class lists the possibility of entry for all
|
||||||
// available turns. Such a class id is stored with every edge.
|
// available turns. Such a class id is stored with every edge.
|
||||||
util::vector_view<util::guidance::EntryClass> m_entry_class_table;
|
util::vector_view<util::guidance::EntryClass> m_entry_class_table;
|
||||||
// the look-up table for distinct bearing classes. A bearing class lists the available bearings
|
|
||||||
// at an intersection
|
|
||||||
std::shared_ptr<util::RangeTable<16, storage::Ownership::View>> m_bearing_ranges_table;
|
|
||||||
util::vector_view<DiscreteBearing> m_bearing_values_table;
|
|
||||||
|
|
||||||
// allocator that keeps the allocation data
|
// allocator that keeps the allocation data
|
||||||
std::shared_ptr<ContiguousBlockAllocator> allocator;
|
std::shared_ptr<ContiguousBlockAllocator> allocator;
|
||||||
@ -502,15 +495,13 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
|||||||
{
|
{
|
||||||
auto bearing_class_id_ptr = data_layout.GetBlockPtr<BearingClassID>(
|
auto bearing_class_id_ptr = data_layout.GetBlockPtr<BearingClassID>(
|
||||||
memory_block, storage::DataLayout::BEARING_CLASSID);
|
memory_block, storage::DataLayout::BEARING_CLASSID);
|
||||||
typename util::vector_view<BearingClassID> bearing_class_id_table(
|
util::vector_view<BearingClassID> bearing_class_id(
|
||||||
bearing_class_id_ptr, data_layout.num_entries[storage::DataLayout::BEARING_CLASSID]);
|
bearing_class_id_ptr, data_layout.num_entries[storage::DataLayout::BEARING_CLASSID]);
|
||||||
m_bearing_class_id_table = std::move(bearing_class_id_table);
|
|
||||||
|
|
||||||
auto bearing_class_ptr = data_layout.GetBlockPtr<DiscreteBearing>(
|
auto bearing_values_ptr = data_layout.GetBlockPtr<DiscreteBearing>(
|
||||||
memory_block, storage::DataLayout::BEARING_VALUES);
|
memory_block, storage::DataLayout::BEARING_VALUES);
|
||||||
typename util::vector_view<DiscreteBearing> bearing_class_table(
|
util::vector_view<DiscreteBearing> bearing_values(
|
||||||
bearing_class_ptr, data_layout.num_entries[storage::DataLayout::BEARING_VALUES]);
|
bearing_values_ptr, data_layout.num_entries[storage::DataLayout::BEARING_VALUES]);
|
||||||
m_bearing_values_table = std::move(bearing_class_table);
|
|
||||||
|
|
||||||
auto offsets_ptr =
|
auto offsets_ptr =
|
||||||
data_layout.GetBlockPtr<unsigned>(memory_block, storage::DataLayout::BEARING_OFFSETS);
|
data_layout.GetBlockPtr<unsigned>(memory_block, storage::DataLayout::BEARING_OFFSETS);
|
||||||
@ -521,12 +512,15 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
|||||||
util::vector_view<IndexBlock> bearing_blocks(
|
util::vector_view<IndexBlock> bearing_blocks(
|
||||||
blocks_ptr, data_layout.num_entries[storage::DataLayout::BEARING_BLOCKS]);
|
blocks_ptr, data_layout.num_entries[storage::DataLayout::BEARING_BLOCKS]);
|
||||||
|
|
||||||
m_bearing_ranges_table = std::make_unique<util::RangeTable<16, storage::Ownership::View>>(
|
util::RangeTable<16, storage::Ownership::View> bearing_range_table(
|
||||||
bearing_offsets, bearing_blocks, static_cast<unsigned>(m_bearing_values_table.size()));
|
bearing_offsets, bearing_blocks, static_cast<unsigned>(bearing_values.size()));
|
||||||
|
|
||||||
|
intersection_bearings_view = extractor::IntersectionBearingsView{
|
||||||
|
std::move(bearing_values), std::move(bearing_class_id), std::move(bearing_range_table)};
|
||||||
|
|
||||||
auto entry_class_ptr = data_layout.GetBlockPtr<util::guidance::EntryClass>(
|
auto entry_class_ptr = data_layout.GetBlockPtr<util::guidance::EntryClass>(
|
||||||
memory_block, storage::DataLayout::ENTRY_CLASS);
|
memory_block, storage::DataLayout::ENTRY_CLASS);
|
||||||
typename util::vector_view<util::guidance::EntryClass> entry_class_table(
|
util::vector_view<util::guidance::EntryClass> entry_class_table(
|
||||||
entry_class_ptr, data_layout.num_entries[storage::DataLayout::ENTRY_CLASS]);
|
entry_class_ptr, data_layout.num_entries[storage::DataLayout::ENTRY_CLASS]);
|
||||||
m_entry_class_table = std::move(entry_class_table);
|
m_entry_class_table = std::move(entry_class_table);
|
||||||
}
|
}
|
||||||
@ -843,27 +837,9 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
|||||||
return m_profile_properties->GetWeightMultiplier();
|
return m_profile_properties->GetWeightMultiplier();
|
||||||
}
|
}
|
||||||
|
|
||||||
BearingClassID GetBearingClassID(const NodeID id) const override final
|
util::guidance::BearingClass GetBearingClass(const NodeID node) const override final
|
||||||
{
|
{
|
||||||
return m_bearing_class_id_table.at(id);
|
return intersection_bearings_view.GetBearingClass(node);
|
||||||
}
|
|
||||||
|
|
||||||
util::guidance::BearingClass
|
|
||||||
GetBearingClass(const BearingClassID bearing_class_id) const override final
|
|
||||||
{
|
|
||||||
BOOST_ASSERT(bearing_class_id != INVALID_BEARING_CLASSID);
|
|
||||||
auto range = m_bearing_ranges_table->GetRange(bearing_class_id);
|
|
||||||
util::guidance::BearingClass result;
|
|
||||||
for (auto itr = m_bearing_values_table.begin() + range.front();
|
|
||||||
itr != m_bearing_values_table.begin() + range.back() + 1;
|
|
||||||
++itr)
|
|
||||||
result.add(*itr);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
EntryClassID GetEntryClassID(const EdgeID eid) const override final
|
|
||||||
{
|
|
||||||
return turn_data.GetEntryClassID(eid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
util::guidance::TurnBearing PreTurnBearing(const EdgeID eid) const override final
|
util::guidance::TurnBearing PreTurnBearing(const EdgeID eid) const override final
|
||||||
@ -875,8 +851,9 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
|||||||
return turn_data.GetPostTurnBearing(eid);
|
return turn_data.GetPostTurnBearing(eid);
|
||||||
}
|
}
|
||||||
|
|
||||||
util::guidance::EntryClass GetEntryClass(const EntryClassID entry_class_id) const override final
|
util::guidance::EntryClass GetEntryClass(const EdgeID turn_id) const override final
|
||||||
{
|
{
|
||||||
|
auto entry_class_id = turn_data.GetEntryClassID(turn_id);
|
||||||
return m_entry_class_table.at(entry_class_id);
|
return m_entry_class_table.at(entry_class_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,17 +170,12 @@ class BaseDataFacade
|
|||||||
|
|
||||||
virtual double GetWeightMultiplier() const = 0;
|
virtual double GetWeightMultiplier() const = 0;
|
||||||
|
|
||||||
virtual BearingClassID GetBearingClassID(const NodeID id) const = 0;
|
|
||||||
|
|
||||||
virtual util::guidance::TurnBearing PreTurnBearing(const EdgeID eid) const = 0;
|
virtual util::guidance::TurnBearing PreTurnBearing(const EdgeID eid) const = 0;
|
||||||
virtual util::guidance::TurnBearing PostTurnBearing(const EdgeID eid) const = 0;
|
virtual util::guidance::TurnBearing PostTurnBearing(const EdgeID eid) const = 0;
|
||||||
|
|
||||||
virtual util::guidance::BearingClass
|
virtual util::guidance::BearingClass GetBearingClass(const NodeID node) const = 0;
|
||||||
GetBearingClass(const BearingClassID bearing_class_id) const = 0;
|
|
||||||
|
|
||||||
virtual EntryClassID GetEntryClassID(const EdgeID eid) const = 0;
|
virtual util::guidance::EntryClass GetEntryClass(const EdgeID turn_id) const = 0;
|
||||||
|
|
||||||
virtual util::guidance::EntryClass GetEntryClass(const EntryClassID entry_class_id) const = 0;
|
|
||||||
|
|
||||||
virtual bool IsLeftHandDriving() const = 0;
|
virtual bool IsLeftHandDriving() const = 0;
|
||||||
};
|
};
|
||||||
|
@ -144,9 +144,7 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
|
|||||||
// extract bearings
|
// extract bearings
|
||||||
bearings = std::make_pair<std::uint16_t, std::uint16_t>(
|
bearings = std::make_pair<std::uint16_t, std::uint16_t>(
|
||||||
path_point.pre_turn_bearing.Get(), path_point.post_turn_bearing.Get());
|
path_point.pre_turn_bearing.Get(), path_point.post_turn_bearing.Get());
|
||||||
const auto entry_class = facade.GetEntryClass(path_point.entry_classid);
|
const auto bearing_class = facade.GetBearingClass(path_point.turn_via_node);
|
||||||
const auto bearing_class =
|
|
||||||
facade.GetBearingClass(facade.GetBearingClassID(path_point.turn_via_node));
|
|
||||||
auto bearing_data = bearing_class.getAvailableBearings();
|
auto bearing_data = bearing_class.getAvailableBearings();
|
||||||
intersection.in = bearing_class.findMatchingBearing(bearings.first);
|
intersection.in = bearing_class.findMatchingBearing(bearings.first);
|
||||||
intersection.out = bearing_class.findMatchingBearing(bearings.second);
|
intersection.out = bearing_class.findMatchingBearing(bearings.second);
|
||||||
@ -174,7 +172,7 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
|
|||||||
intersection.entry.clear();
|
intersection.entry.clear();
|
||||||
for (auto idx : util::irange<std::size_t>(0, intersection.bearings.size()))
|
for (auto idx : util::irange<std::size_t>(0, intersection.bearings.size()))
|
||||||
{
|
{
|
||||||
intersection.entry.push_back(entry_class.allowsEntry(idx));
|
intersection.entry.push_back(path_point.entry_class.allowsEntry(idx));
|
||||||
}
|
}
|
||||||
std::int16_t bearing_in_driving_direction =
|
std::int16_t bearing_in_driving_direction =
|
||||||
util::bearing::reverse(std::round(bearings.first));
|
util::bearing::reverse(std::round(bearings.first));
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "extractor/travel_mode.hpp"
|
#include "extractor/travel_mode.hpp"
|
||||||
#include "engine/phantom_node.hpp"
|
#include "engine/phantom_node.hpp"
|
||||||
#include "osrm/coordinate.hpp"
|
#include "osrm/coordinate.hpp"
|
||||||
|
#include "util/guidance/entry_class.hpp"
|
||||||
#include "util/guidance/turn_bearing.hpp"
|
#include "util/guidance/turn_bearing.hpp"
|
||||||
#include "util/guidance/turn_lanes.hpp"
|
#include "util/guidance/turn_lanes.hpp"
|
||||||
#include "util/typedefs.hpp"
|
#include "util/typedefs.hpp"
|
||||||
@ -33,7 +34,7 @@ struct PathData
|
|||||||
// travel mode of the street that leads to the turn
|
// travel mode of the street that leads to the turn
|
||||||
extractor::TravelMode travel_mode : 4;
|
extractor::TravelMode travel_mode : 4;
|
||||||
// entry class of the turn, indicating possibility of turns
|
// entry class of the turn, indicating possibility of turns
|
||||||
EntryClassID entry_classid;
|
util::guidance::EntryClass entry_class;
|
||||||
|
|
||||||
// Source of the speed value on this road segment
|
// Source of the speed value on this road segment
|
||||||
DatasourceID datasource_id;
|
DatasourceID datasource_id;
|
||||||
|
@ -158,7 +158,7 @@ void annotatePath(const FacadeT &facade,
|
|||||||
extractor::guidance::TurnInstruction::NO_TURN(),
|
extractor::guidance::TurnInstruction::NO_TURN(),
|
||||||
{{0, INVALID_LANEID}, INVALID_LANE_DESCRIPTIONID},
|
{{0, INVALID_LANEID}, INVALID_LANE_DESCRIPTIONID},
|
||||||
travel_mode,
|
travel_mode,
|
||||||
INVALID_ENTRY_CLASSID,
|
{},
|
||||||
datasource_vector[segment_idx],
|
datasource_vector[segment_idx],
|
||||||
util::guidance::TurnBearing(0),
|
util::guidance::TurnBearing(0),
|
||||||
util::guidance::TurnBearing(0)});
|
util::guidance::TurnBearing(0)});
|
||||||
@ -167,7 +167,7 @@ void annotatePath(const FacadeT &facade,
|
|||||||
if (facade.HasLaneData(turn_id))
|
if (facade.HasLaneData(turn_id))
|
||||||
unpacked_path.back().lane_data = facade.GetLaneData(turn_id);
|
unpacked_path.back().lane_data = facade.GetLaneData(turn_id);
|
||||||
|
|
||||||
unpacked_path.back().entry_classid = facade.GetEntryClassID(turn_id);
|
unpacked_path.back().entry_class = facade.GetEntryClass(turn_id);
|
||||||
unpacked_path.back().turn_instruction = turn_instruction;
|
unpacked_path.back().turn_instruction = turn_instruction;
|
||||||
unpacked_path.back().duration_until_turn += facade.GetDurationPenaltyForEdgeID(turn_id);
|
unpacked_path.back().duration_until_turn += facade.GetDurationPenaltyForEdgeID(turn_id);
|
||||||
unpacked_path.back().weight_until_turn += facade.GetWeightPenaltyForEdgeID(turn_id);
|
unpacked_path.back().weight_until_turn += facade.GetWeightPenaltyForEdgeID(turn_id);
|
||||||
@ -233,7 +233,7 @@ void annotatePath(const FacadeT &facade,
|
|||||||
extractor::guidance::TurnInstruction::NO_TURN(),
|
extractor::guidance::TurnInstruction::NO_TURN(),
|
||||||
{{0, INVALID_LANEID}, INVALID_LANE_DESCRIPTIONID},
|
{{0, INVALID_LANEID}, INVALID_LANE_DESCRIPTIONID},
|
||||||
facade.GetTravelMode(target_node_id),
|
facade.GetTravelMode(target_node_id),
|
||||||
INVALID_ENTRY_CLASSID,
|
{},
|
||||||
datasource_vector[segment_idx],
|
datasource_vector[segment_idx],
|
||||||
util::guidance::TurnBearing(0),
|
util::guidance::TurnBearing(0),
|
||||||
util::guidance::TurnBearing(0)});
|
util::guidance::TurnBearing(0)});
|
||||||
|
@ -4,12 +4,15 @@
|
|||||||
#include "extractor/edge_based_edge.hpp"
|
#include "extractor/edge_based_edge.hpp"
|
||||||
#include "extractor/guidance/turn_lane_types.hpp"
|
#include "extractor/guidance/turn_lane_types.hpp"
|
||||||
#include "extractor/node_data_container.hpp"
|
#include "extractor/node_data_container.hpp"
|
||||||
|
#include "extractor/profile_properties.hpp"
|
||||||
#include "extractor/serialization.hpp"
|
#include "extractor/serialization.hpp"
|
||||||
#include "extractor/turn_data_container.hpp"
|
#include "extractor/turn_data_container.hpp"
|
||||||
#include "extractor/profile_properties.hpp"
|
|
||||||
|
|
||||||
#include "util/coordinate.hpp"
|
#include "util/coordinate.hpp"
|
||||||
|
#include "util/guidance/bearing_class.hpp"
|
||||||
|
#include "util/guidance/entry_class.hpp"
|
||||||
#include "util/packed_vector.hpp"
|
#include "util/packed_vector.hpp"
|
||||||
|
#include "util/range_table.hpp"
|
||||||
#include "util/serialization.hpp"
|
#include "util/serialization.hpp"
|
||||||
|
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
@ -21,8 +24,41 @@ namespace extractor
|
|||||||
namespace files
|
namespace files
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// writes the .osrm.icd file
|
||||||
|
template <typename IntersectionBearingsT, typename EntryClassVectorT>
|
||||||
|
inline void writeIntersections(const boost::filesystem::path &path,
|
||||||
|
const IntersectionBearingsT &intersection_bearings,
|
||||||
|
const EntryClassVectorT &entry_classes)
|
||||||
|
{
|
||||||
|
static_assert(std::is_same<IntersectionBearingsContainer, IntersectionBearingsT>::value ||
|
||||||
|
std::is_same<IntersectionBearingsView, IntersectionBearingsT>::value,
|
||||||
|
"");
|
||||||
|
|
||||||
|
storage::io::FileWriter writer(path, storage::io::FileWriter::GenerateFingerprint);
|
||||||
|
|
||||||
|
serialization::write(writer, intersection_bearings);
|
||||||
|
storage::serialization::write(writer, entry_classes);
|
||||||
|
}
|
||||||
|
|
||||||
|
// read the .osrm.icd file
|
||||||
|
template <typename IntersectionBearingsT, typename EntryClassVectorT>
|
||||||
|
inline void readIntersections(const boost::filesystem::path &path,
|
||||||
|
IntersectionBearingsT &intersection_bearings,
|
||||||
|
EntryClassVectorT &entry_classes)
|
||||||
|
{
|
||||||
|
static_assert(std::is_same<IntersectionBearingsContainer, IntersectionBearingsT>::value ||
|
||||||
|
std::is_same<IntersectionBearingsView, IntersectionBearingsT>::value,
|
||||||
|
"");
|
||||||
|
|
||||||
|
storage::io::FileReader reader(path, storage::io::FileReader::VerifyFingerprint);
|
||||||
|
|
||||||
|
serialization::read(reader, intersection_bearings);
|
||||||
|
storage::serialization::read(reader, entry_classes);
|
||||||
|
}
|
||||||
|
|
||||||
// reads .osrm.properties
|
// reads .osrm.properties
|
||||||
inline void readProfileProperties(const boost::filesystem::path &path, ProfileProperties &properties)
|
inline void readProfileProperties(const boost::filesystem::path &path,
|
||||||
|
ProfileProperties &properties)
|
||||||
{
|
{
|
||||||
const auto fingerprint = storage::io::FileReader::VerifyFingerprint;
|
const auto fingerprint = storage::io::FileReader::VerifyFingerprint;
|
||||||
storage::io::FileReader reader{path, fingerprint};
|
storage::io::FileReader reader{path, fingerprint};
|
||||||
@ -32,7 +68,7 @@ inline void readProfileProperties(const boost::filesystem::path &path, ProfilePr
|
|||||||
|
|
||||||
// writes .osrm.properties
|
// writes .osrm.properties
|
||||||
inline void writeProfileProperties(const boost::filesystem::path &path,
|
inline void writeProfileProperties(const boost::filesystem::path &path,
|
||||||
const ProfileProperties &properties)
|
const ProfileProperties &properties)
|
||||||
{
|
{
|
||||||
const auto fingerprint = storage::io::FileWriter::GenerateFingerprint;
|
const auto fingerprint = storage::io::FileWriter::GenerateFingerprint;
|
||||||
storage::io::FileWriter writer{path, fingerprint};
|
storage::io::FileWriter writer{path, fingerprint};
|
||||||
|
@ -4,10 +4,10 @@
|
|||||||
#include <bitset>
|
#include <bitset>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <numeric> //partial_sum
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <numeric> //partial_sum
|
|
||||||
|
|
||||||
#include <boost/functional/hash.hpp>
|
#include <boost/functional/hash.hpp>
|
||||||
|
|
||||||
|
105
include/extractor/intersection_bearings_container.hpp
Normal file
105
include/extractor/intersection_bearings_container.hpp
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
#ifndef OSRM_EXTRACTOR_BEARING_CONTAINER_HPP
|
||||||
|
#define OSRM_EXTRACTOR_BEARING_CONTAINER_HPP
|
||||||
|
|
||||||
|
#include "storage/shared_memory_ownership.hpp"
|
||||||
|
|
||||||
|
#include "util/guidance/bearing_class.hpp"
|
||||||
|
#include "util/range_table.hpp"
|
||||||
|
#include "util/vector_view.hpp"
|
||||||
|
|
||||||
|
#include <numeric>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace extractor
|
||||||
|
{
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
template <storage::Ownership Ownership> class IntersectionBearingsContainer;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace serialization
|
||||||
|
{
|
||||||
|
template <storage::Ownership Ownership>
|
||||||
|
void read(storage::io::FileReader &reader,
|
||||||
|
detail::IntersectionBearingsContainer<Ownership> &turn_data);
|
||||||
|
|
||||||
|
template <storage::Ownership Ownership>
|
||||||
|
void write(storage::io::FileWriter &writer,
|
||||||
|
const detail::IntersectionBearingsContainer<Ownership> &turn_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
template <storage::Ownership Ownership> class IntersectionBearingsContainer
|
||||||
|
{
|
||||||
|
template <typename T> using Vector = util::ViewOrVector<T, Ownership>;
|
||||||
|
template <unsigned size> using RangeTable = util::RangeTable<size, Ownership>;
|
||||||
|
|
||||||
|
public:
|
||||||
|
IntersectionBearingsContainer() = default;
|
||||||
|
IntersectionBearingsContainer(IntersectionBearingsContainer &&) = default;
|
||||||
|
IntersectionBearingsContainer(const IntersectionBearingsContainer &) = default;
|
||||||
|
IntersectionBearingsContainer &operator=(IntersectionBearingsContainer &&) = default;
|
||||||
|
IntersectionBearingsContainer &operator=(const IntersectionBearingsContainer &) = default;
|
||||||
|
|
||||||
|
IntersectionBearingsContainer(std::vector<BearingClassID> node_to_class_id_,
|
||||||
|
const std::vector<util::guidance::BearingClass> &bearing_classes)
|
||||||
|
: node_to_class_id(std::move(node_to_class_id_))
|
||||||
|
{
|
||||||
|
std::vector<unsigned> bearing_counts(bearing_classes.size());
|
||||||
|
std::transform(bearing_classes.begin(),
|
||||||
|
bearing_classes.end(),
|
||||||
|
bearing_counts.begin(),
|
||||||
|
[](const auto &bearings) { return bearings.getAvailableBearings().size(); });
|
||||||
|
auto total_bearings = std::accumulate(bearing_counts.begin(), bearing_counts.end(), 0);
|
||||||
|
class_id_to_ranges_table = RangeTable<16>{bearing_counts};
|
||||||
|
|
||||||
|
values.reserve(total_bearings);
|
||||||
|
for (const auto &bearing_class : bearing_classes)
|
||||||
|
{
|
||||||
|
const auto &bearings = bearing_class.getAvailableBearings();
|
||||||
|
values.insert(values.end(), bearings.begin(), bearings.end());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IntersectionBearingsContainer(Vector<DiscreteBearing> values_,
|
||||||
|
Vector<BearingClassID> node_to_class_id_,
|
||||||
|
RangeTable<16> class_id_to_ranges_table_)
|
||||||
|
: values(std::move(values_)), node_to_class_id(std::move(node_to_class_id_)),
|
||||||
|
class_id_to_ranges_table(std::move(class_id_to_ranges_table_))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns the bearing class for an intersection node
|
||||||
|
util::guidance::BearingClass GetBearingClass(const NodeID node) const
|
||||||
|
{
|
||||||
|
auto class_id = node_to_class_id[node];
|
||||||
|
auto range = class_id_to_ranges_table.GetRange(class_id);
|
||||||
|
util::guidance::BearingClass result;
|
||||||
|
std::for_each(values.begin() + range.front(),
|
||||||
|
values.begin() + range.back() + 1,
|
||||||
|
[&](const DiscreteBearing &bearing) { result.add(bearing); });
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
friend void serialization::read<Ownership>(storage::io::FileReader &reader,
|
||||||
|
IntersectionBearingsContainer &turn_data_container);
|
||||||
|
friend void
|
||||||
|
serialization::write<Ownership>(storage::io::FileWriter &writer,
|
||||||
|
const IntersectionBearingsContainer &turn_data_container);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Vector<DiscreteBearing> values;
|
||||||
|
Vector<BearingClassID> node_to_class_id;
|
||||||
|
RangeTable<16> class_id_to_ranges_table;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
using IntersectionBearingsContainer =
|
||||||
|
detail::IntersectionBearingsContainer<storage::Ownership::Container>;
|
||||||
|
using IntersectionBearingsView = detail::IntersectionBearingsContainer<storage::Ownership::View>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -2,12 +2,13 @@
|
|||||||
#define OSRM_EXTRACTOR_IO_HPP
|
#define OSRM_EXTRACTOR_IO_HPP
|
||||||
|
|
||||||
#include "extractor/datasources.hpp"
|
#include "extractor/datasources.hpp"
|
||||||
|
#include "extractor/intersection_bearings_container.hpp"
|
||||||
#include "extractor/nbg_to_ebg.hpp"
|
#include "extractor/nbg_to_ebg.hpp"
|
||||||
#include "extractor/node_data_container.hpp"
|
#include "extractor/node_data_container.hpp"
|
||||||
|
#include "extractor/profile_properties.hpp"
|
||||||
#include "extractor/restriction.hpp"
|
#include "extractor/restriction.hpp"
|
||||||
#include "extractor/segment_data_container.hpp"
|
#include "extractor/segment_data_container.hpp"
|
||||||
#include "extractor/turn_data_container.hpp"
|
#include "extractor/turn_data_container.hpp"
|
||||||
#include "extractor/profile_properties.hpp"
|
|
||||||
|
|
||||||
#include "storage/io.hpp"
|
#include "storage/io.hpp"
|
||||||
#include "storage/serialization.hpp"
|
#include "storage/serialization.hpp"
|
||||||
@ -21,6 +22,25 @@ namespace extractor
|
|||||||
namespace serialization
|
namespace serialization
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// read/write for bearing data
|
||||||
|
template <storage::Ownership Ownership>
|
||||||
|
inline void read(storage::io::FileReader &reader,
|
||||||
|
detail::IntersectionBearingsContainer<Ownership> &intersection_bearings)
|
||||||
|
{
|
||||||
|
storage::serialization::read(reader, intersection_bearings.values);
|
||||||
|
storage::serialization::read(reader, intersection_bearings.node_to_class_id);
|
||||||
|
util::serialization::read(reader, intersection_bearings.class_id_to_ranges_table);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <storage::Ownership Ownership>
|
||||||
|
inline void write(storage::io::FileWriter &writer,
|
||||||
|
const detail::IntersectionBearingsContainer<Ownership> &intersection_bearings)
|
||||||
|
{
|
||||||
|
storage::serialization::write(writer, intersection_bearings.values);
|
||||||
|
storage::serialization::write(writer, intersection_bearings.node_to_class_id);
|
||||||
|
util::serialization::write(writer, intersection_bearings.class_id_to_ranges_table);
|
||||||
|
}
|
||||||
|
|
||||||
// read/write for properties file
|
// read/write for properties file
|
||||||
inline void read(storage::io::FileReader &reader, ProfileProperties &properties)
|
inline void read(storage::io::FileReader &reader, ProfileProperties &properties)
|
||||||
{
|
{
|
||||||
|
@ -35,7 +35,7 @@ struct ConcurrentIDMap
|
|||||||
|
|
||||||
data = std::move(other.data);
|
data = std::move(other.data);
|
||||||
}
|
}
|
||||||
ConcurrentIDMap& operator=(ConcurrentIDMap &&other)
|
ConcurrentIDMap &operator=(ConcurrentIDMap &&other)
|
||||||
{
|
{
|
||||||
ScopedWriterLock other_lock{other.mutex};
|
ScopedWriterLock other_lock{other.mutex};
|
||||||
ScopedWriterLock lock{mutex};
|
ScopedWriterLock lock{mutex};
|
||||||
|
@ -22,11 +22,14 @@ namespace util
|
|||||||
template <unsigned BLOCK_SIZE = 16, storage::Ownership Ownership = storage::Ownership::Container>
|
template <unsigned BLOCK_SIZE = 16, storage::Ownership Ownership = storage::Ownership::Container>
|
||||||
class RangeTable;
|
class RangeTable;
|
||||||
|
|
||||||
template <unsigned BLOCK_SIZE, storage::Ownership Ownership>
|
namespace serialization
|
||||||
std::ostream &operator<<(std::ostream &out, const RangeTable<BLOCK_SIZE, Ownership> &table);
|
{
|
||||||
|
template <unsigned BlockSize, storage::Ownership Ownership>
|
||||||
|
void write(storage::io::FileWriter &writer, const util::RangeTable<BlockSize, Ownership> &table);
|
||||||
|
|
||||||
template <unsigned BLOCK_SIZE, storage::Ownership Ownership>
|
template <unsigned BlockSize, storage::Ownership Ownership>
|
||||||
std::istream &operator>>(std::istream &in, RangeTable<BLOCK_SIZE, Ownership> &table);
|
void read(storage::io::FileReader &reader, util::RangeTable<BlockSize, Ownership> &table);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores adjacent ranges in a compressed format.
|
* Stores adjacent ranges in a compressed format.
|
||||||
@ -45,9 +48,6 @@ template <unsigned BLOCK_SIZE, storage::Ownership Ownership> class RangeTable
|
|||||||
using OffsetContainerT = util::ViewOrVector<unsigned, Ownership>;
|
using OffsetContainerT = util::ViewOrVector<unsigned, Ownership>;
|
||||||
using RangeT = range<unsigned>;
|
using RangeT = range<unsigned>;
|
||||||
|
|
||||||
friend std::ostream &operator<<<>(std::ostream &out, const RangeTable &table);
|
|
||||||
friend std::istream &operator>><>(std::istream &in, RangeTable &table);
|
|
||||||
|
|
||||||
RangeTable() : sum_lengths(0) {}
|
RangeTable() : sum_lengths(0) {}
|
||||||
|
|
||||||
// for loading from shared memory
|
// for loading from shared memory
|
||||||
@ -141,33 +141,6 @@ template <unsigned BLOCK_SIZE, storage::Ownership Ownership> class RangeTable
|
|||||||
sum_lengths = lengths_prefix_sum;
|
sum_lengths = lengths_prefix_sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Write(storage::io::FileWriter &filewriter)
|
|
||||||
{
|
|
||||||
auto number_of_blocks = diff_blocks.size();
|
|
||||||
|
|
||||||
filewriter.WriteElementCount64(number_of_blocks);
|
|
||||||
|
|
||||||
filewriter.WriteOne(sum_lengths);
|
|
||||||
|
|
||||||
filewriter.WriteFrom(block_offsets.data(), number_of_blocks);
|
|
||||||
filewriter.WriteFrom(diff_blocks.data(), number_of_blocks);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Read(storage::io::FileReader &filereader)
|
|
||||||
{
|
|
||||||
auto number_of_blocks = filereader.ReadElementCount64();
|
|
||||||
// read total length
|
|
||||||
filereader.ReadInto(&sum_lengths, 1);
|
|
||||||
|
|
||||||
block_offsets.resize(number_of_blocks);
|
|
||||||
diff_blocks.resize(number_of_blocks);
|
|
||||||
|
|
||||||
// read block offsets
|
|
||||||
filereader.ReadInto(block_offsets.data(), number_of_blocks);
|
|
||||||
// read blocks
|
|
||||||
filereader.ReadInto(diff_blocks.data(), number_of_blocks);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline RangeT GetRange(const unsigned id) const
|
inline RangeT GetRange(const unsigned id) const
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(id < block_offsets.size() + diff_blocks.size() * BLOCK_SIZE);
|
BOOST_ASSERT(id < block_offsets.size() + diff_blocks.size() * BLOCK_SIZE);
|
||||||
@ -204,6 +177,11 @@ template <unsigned BLOCK_SIZE, storage::Ownership Ownership> class RangeTable
|
|||||||
return irange(begin_idx, end_idx);
|
return irange(begin_idx, end_idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
friend void serialization::write<BLOCK_SIZE, Ownership>(storage::io::FileWriter &writer,
|
||||||
|
const RangeTable &table);
|
||||||
|
friend void serialization::read<BLOCK_SIZE, Ownership>(storage::io::FileReader &reader,
|
||||||
|
RangeTable &table);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
inline unsigned PrefixSumAtIndex(int index, const BlockT &block) const;
|
inline unsigned PrefixSumAtIndex(int index, const BlockT &block) const;
|
||||||
|
|
||||||
@ -227,41 +205,6 @@ unsigned RangeTable<BLOCK_SIZE, Ownership>::PrefixSumAtIndex(int index, const Bl
|
|||||||
|
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <unsigned BLOCK_SIZE, storage::Ownership Ownership>
|
|
||||||
std::ostream &operator<<(std::ostream &out, const RangeTable<BLOCK_SIZE, Ownership> &table)
|
|
||||||
{
|
|
||||||
// write number of block
|
|
||||||
const unsigned number_of_blocks = table.diff_blocks.size();
|
|
||||||
out.write((char *)&number_of_blocks, sizeof(unsigned));
|
|
||||||
// write total length
|
|
||||||
out.write((char *)&table.sum_lengths, sizeof(unsigned));
|
|
||||||
// write block offsets
|
|
||||||
out.write((char *)table.block_offsets.data(), sizeof(unsigned) * table.block_offsets.size());
|
|
||||||
// write blocks
|
|
||||||
out.write((char *)table.diff_blocks.data(), BLOCK_SIZE * table.diff_blocks.size());
|
|
||||||
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <unsigned BLOCK_SIZE, storage::Ownership Ownership>
|
|
||||||
std::istream &operator>>(std::istream &in, RangeTable<BLOCK_SIZE, Ownership> &table)
|
|
||||||
{
|
|
||||||
// read number of block
|
|
||||||
unsigned number_of_blocks;
|
|
||||||
in.read((char *)&number_of_blocks, sizeof(unsigned));
|
|
||||||
// read total length
|
|
||||||
in.read((char *)&table.sum_lengths, sizeof(unsigned));
|
|
||||||
|
|
||||||
table.block_offsets.resize(number_of_blocks);
|
|
||||||
table.diff_blocks.resize(number_of_blocks);
|
|
||||||
|
|
||||||
// read block offsets
|
|
||||||
in.read((char *)table.block_offsets.data(), sizeof(unsigned) * number_of_blocks);
|
|
||||||
// read blocks
|
|
||||||
in.read((char *)table.diff_blocks.data(), BLOCK_SIZE * number_of_blocks);
|
|
||||||
return in;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "util/dynamic_graph.hpp"
|
#include "util/dynamic_graph.hpp"
|
||||||
#include "util/packed_vector.hpp"
|
#include "util/packed_vector.hpp"
|
||||||
|
#include "util/range_table.hpp"
|
||||||
#include "util/static_graph.hpp"
|
#include "util/static_graph.hpp"
|
||||||
|
|
||||||
#include "storage/io.hpp"
|
#include "storage/io.hpp"
|
||||||
@ -14,6 +15,22 @@ namespace util
|
|||||||
{
|
{
|
||||||
namespace serialization
|
namespace serialization
|
||||||
{
|
{
|
||||||
|
template <unsigned BlockSize, storage::Ownership Ownership>
|
||||||
|
void write(storage::io::FileWriter &writer, const util::RangeTable<BlockSize, Ownership> &table)
|
||||||
|
{
|
||||||
|
writer.WriteOne(table.sum_lengths);
|
||||||
|
storage::serialization::write(writer, table.block_offsets);
|
||||||
|
storage::serialization::write(writer, table.diff_blocks);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <unsigned BlockSize, storage::Ownership Ownership>
|
||||||
|
void read(storage::io::FileReader &reader, util::RangeTable<BlockSize, Ownership> &table)
|
||||||
|
{
|
||||||
|
table.sum_lengths = reader.ReadOne<unsigned>();
|
||||||
|
storage::serialization::read(reader, table.block_offsets);
|
||||||
|
storage::serialization::read(reader, table.diff_blocks);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T, std::size_t Bits, storage::Ownership Ownership>
|
template <typename T, std::size_t Bits, storage::Ownership Ownership>
|
||||||
inline void read(storage::io::FileReader &reader, detail::PackedVector<T, Bits, Ownership> &vec)
|
inline void read(storage::io::FileReader &reader, detail::PackedVector<T, Bits, Ownership> &vec)
|
||||||
{
|
{
|
||||||
|
@ -348,10 +348,8 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
|
|||||||
profile_properties);
|
profile_properties);
|
||||||
|
|
||||||
util::guidance::LaneDataIdMap lane_data_map;
|
util::guidance::LaneDataIdMap lane_data_map;
|
||||||
guidance::lanes::TurnLaneHandler turn_lane_handler(*m_node_based_graph,
|
guidance::lanes::TurnLaneHandler turn_lane_handler(
|
||||||
lane_description_map,
|
*m_node_based_graph, lane_description_map, turn_analysis, lane_data_map);
|
||||||
turn_analysis,
|
|
||||||
lane_data_map);
|
|
||||||
|
|
||||||
bearing_class_by_node_based_node.resize(m_node_based_graph->GetNumberOfNodes(),
|
bearing_class_by_node_based_node.resize(m_node_based_graph->GetNumberOfNodes(),
|
||||||
std::numeric_limits<std::uint32_t>::max());
|
std::numeric_limits<std::uint32_t>::max());
|
||||||
|
@ -518,10 +518,15 @@ Extractor::BuildEdgeExpandedGraph(ScriptingEnvironment &scripting_environment,
|
|||||||
|
|
||||||
const std::size_t number_of_node_based_nodes = node_based_graph->GetNumberOfNodes();
|
const std::size_t number_of_node_based_nodes = node_based_graph->GetNumberOfNodes();
|
||||||
|
|
||||||
WriteIntersectionClassificationData(intersection_class_output_file,
|
util::Log() << "Writing Intersection Classification Data";
|
||||||
edge_based_graph_factory.GetBearingClassIds(),
|
TIMER_START(write_intersections);
|
||||||
edge_based_graph_factory.GetBearingClasses(),
|
files::writeIntersections(
|
||||||
edge_based_graph_factory.GetEntryClasses());
|
intersection_class_output_file,
|
||||||
|
IntersectionBearingsContainer{edge_based_graph_factory.GetBearingClassIds(),
|
||||||
|
edge_based_graph_factory.GetBearingClasses()},
|
||||||
|
edge_based_graph_factory.GetEntryClasses());
|
||||||
|
TIMER_STOP(write_intersections);
|
||||||
|
util::Log() << "ok, after " << TIMER_SEC(write_intersections) << "s";
|
||||||
|
|
||||||
return std::make_pair(number_of_node_based_nodes, max_edge_id);
|
return std::make_pair(number_of_node_based_nodes, max_edge_id);
|
||||||
}
|
}
|
||||||
@ -572,49 +577,6 @@ void Extractor::BuildRTree(std::vector<EdgeBasedNodeSegment> edge_based_node_seg
|
|||||||
util::Log() << "finished r-tree construction in " << TIMER_SEC(construction) << " seconds";
|
util::Log() << "finished r-tree construction in " << TIMER_SEC(construction) << " seconds";
|
||||||
}
|
}
|
||||||
|
|
||||||
void Extractor::WriteIntersectionClassificationData(
|
|
||||||
const std::string &output_file_name,
|
|
||||||
const std::vector<BearingClassID> &node_based_intersection_classes,
|
|
||||||
const std::vector<util::guidance::BearingClass> &bearing_classes,
|
|
||||||
const std::vector<util::guidance::EntryClass> &entry_classes) const
|
|
||||||
{
|
|
||||||
storage::io::FileWriter writer(output_file_name, storage::io::FileWriter::GenerateFingerprint);
|
|
||||||
|
|
||||||
util::Log() << "Writing Intersection Classification Data";
|
|
||||||
TIMER_START(write_edges);
|
|
||||||
storage::serialization::write(writer, node_based_intersection_classes);
|
|
||||||
|
|
||||||
// create range table for vectors:
|
|
||||||
std::vector<unsigned> bearing_counts;
|
|
||||||
bearing_counts.reserve(bearing_classes.size());
|
|
||||||
std::uint64_t total_bearings = 0;
|
|
||||||
for (const auto &bearing_class : bearing_classes)
|
|
||||||
{
|
|
||||||
bearing_counts.push_back(
|
|
||||||
static_cast<unsigned>(bearing_class.getAvailableBearings().size()));
|
|
||||||
total_bearings += bearing_class.getAvailableBearings().size();
|
|
||||||
}
|
|
||||||
|
|
||||||
util::RangeTable<> bearing_class_range_table(bearing_counts);
|
|
||||||
bearing_class_range_table.Write(writer);
|
|
||||||
|
|
||||||
writer.WriteOne(total_bearings);
|
|
||||||
|
|
||||||
for (const auto &bearing_class : bearing_classes)
|
|
||||||
{
|
|
||||||
const auto &bearings = bearing_class.getAvailableBearings();
|
|
||||||
writer.WriteFrom(bearings.data(), bearings.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
storage::serialization::write(writer, entry_classes);
|
|
||||||
|
|
||||||
TIMER_STOP(write_edges);
|
|
||||||
util::Log() << "ok, after " << TIMER_SEC(write_edges) << "s for "
|
|
||||||
<< node_based_intersection_classes.size() << " Indices into "
|
|
||||||
<< bearing_classes.size() << " bearing classes and " << entry_classes.size()
|
|
||||||
<< " entry classes and " << total_bearings << " bearing values.";
|
|
||||||
}
|
|
||||||
|
|
||||||
void Extractor::WriteCompressedNodeBasedGraph(const std::string &path,
|
void Extractor::WriteCompressedNodeBasedGraph(const std::string &path,
|
||||||
const util::NodeBasedDynamicGraph &graph,
|
const util::NodeBasedDynamicGraph &graph,
|
||||||
const std::vector<util::Coordinate> &coordinates)
|
const std::vector<util::Coordinate> &coordinates)
|
||||||
|
@ -37,10 +37,11 @@ TurnLaneHandler::TurnLaneHandler(const util::NodeBasedDynamicGraph &node_based_g
|
|||||||
LaneDescriptionMap &lane_description_map,
|
LaneDescriptionMap &lane_description_map,
|
||||||
const TurnAnalysis &turn_analysis,
|
const TurnAnalysis &turn_analysis,
|
||||||
util::guidance::LaneDataIdMap &id_map)
|
util::guidance::LaneDataIdMap &id_map)
|
||||||
: node_based_graph(node_based_graph), lane_description_map(lane_description_map),
|
: node_based_graph(node_based_graph), lane_description_map(lane_description_map),
|
||||||
turn_analysis(turn_analysis), id_map(id_map)
|
turn_analysis(turn_analysis), id_map(id_map)
|
||||||
{
|
{
|
||||||
std::tie(turn_lane_offsets, turn_lane_masks) = transformTurnLaneMapIntoArrays(lane_description_map);
|
std::tie(turn_lane_offsets, turn_lane_masks) =
|
||||||
|
transformTurnLaneMapIntoArrays(lane_description_map);
|
||||||
count_handled = count_called = 0;
|
count_handled = count_called = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -387,39 +387,26 @@ void Storage::PopulateLayout(DataLayout &layout)
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
io::FileReader intersection_file(config.intersection_class_path,
|
io::FileReader reader(config.intersection_class_path, io::FileReader::VerifyFingerprint);
|
||||||
io::FileReader::VerifyFingerprint);
|
|
||||||
|
|
||||||
std::vector<BearingClassID> bearing_class_id_table;
|
auto num_discreate_bearings = reader.ReadVectorSize<DiscreteBearing>();
|
||||||
serialization::read(intersection_file, bearing_class_id_table);
|
layout.SetBlockSize<DiscreteBearing>(DataLayout::BEARING_VALUES, num_discreate_bearings);
|
||||||
|
|
||||||
layout.SetBlockSize<BearingClassID>(DataLayout::BEARING_CLASSID,
|
auto num_bearing_classes = reader.ReadVectorSize<BearingClassID>();
|
||||||
bearing_class_id_table.size());
|
layout.SetBlockSize<BearingClassID>(DataLayout::BEARING_CLASSID, num_bearing_classes);
|
||||||
|
|
||||||
const auto bearing_blocks = intersection_file.ReadElementCount64();
|
reader.Skip<std::uint32_t>(1); // sum_lengths
|
||||||
intersection_file.Skip<std::uint32_t>(1); // sum_lengths
|
const auto bearing_blocks = reader.ReadVectorSize<unsigned>();
|
||||||
|
const auto bearing_offsets =
|
||||||
|
reader
|
||||||
|
.ReadVectorSize<typename util::RangeTable<16, storage::Ownership::View>::BlockT>();
|
||||||
|
|
||||||
layout.SetBlockSize<unsigned>(DataLayout::BEARING_OFFSETS, bearing_blocks);
|
layout.SetBlockSize<unsigned>(DataLayout::BEARING_OFFSETS, bearing_blocks);
|
||||||
layout.SetBlockSize<typename util::RangeTable<16, storage::Ownership::View>::BlockT>(
|
layout.SetBlockSize<typename util::RangeTable<16, storage::Ownership::View>::BlockT>(
|
||||||
DataLayout::BEARING_BLOCKS, bearing_blocks);
|
DataLayout::BEARING_BLOCKS, bearing_offsets);
|
||||||
|
|
||||||
// No need to read the data
|
auto num_entry_classes = reader.ReadVectorSize<util::guidance::EntryClass>();
|
||||||
intersection_file.Skip<unsigned>(bearing_blocks);
|
layout.SetBlockSize<util::guidance::EntryClass>(DataLayout::ENTRY_CLASS, num_entry_classes);
|
||||||
intersection_file.Skip<typename util::RangeTable<16, storage::Ownership::View>::BlockT>(
|
|
||||||
bearing_blocks);
|
|
||||||
|
|
||||||
const auto num_bearings = intersection_file.ReadElementCount64();
|
|
||||||
|
|
||||||
// Skip over the actual data
|
|
||||||
intersection_file.Skip<DiscreteBearing>(num_bearings);
|
|
||||||
|
|
||||||
layout.SetBlockSize<DiscreteBearing>(DataLayout::BEARING_VALUES, num_bearings);
|
|
||||||
|
|
||||||
std::vector<util::guidance::EntryClass> entry_class_table;
|
|
||||||
serialization::read(intersection_file, entry_class_table);
|
|
||||||
|
|
||||||
layout.SetBlockSize<util::guidance::EntryClass>(DataLayout::ENTRY_CLASS,
|
|
||||||
entry_class_table.size());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -826,86 +813,39 @@ void Storage::PopulateData(const DataLayout &layout, char *memory_ptr)
|
|||||||
|
|
||||||
// Load intersection data
|
// Load intersection data
|
||||||
{
|
{
|
||||||
io::FileReader intersection_file(config.intersection_class_path,
|
auto bearing_class_id_ptr = layout.GetBlockPtr<BearingClassID, true>(
|
||||||
io::FileReader::VerifyFingerprint);
|
memory_ptr, storage::DataLayout::BEARING_CLASSID);
|
||||||
|
util::vector_view<BearingClassID> bearing_class_id(
|
||||||
|
bearing_class_id_ptr, layout.num_entries[storage::DataLayout::BEARING_CLASSID]);
|
||||||
|
|
||||||
std::vector<BearingClassID> bearing_class_id_table;
|
auto bearing_values_ptr = layout.GetBlockPtr<DiscreteBearing, true>(
|
||||||
serialization::read(intersection_file, bearing_class_id_table);
|
memory_ptr, storage::DataLayout::BEARING_VALUES);
|
||||||
|
util::vector_view<DiscreteBearing> bearing_values(
|
||||||
|
bearing_values_ptr, layout.num_entries[storage::DataLayout::BEARING_VALUES]);
|
||||||
|
|
||||||
const auto bearing_blocks = intersection_file.ReadElementCount64();
|
auto offsets_ptr =
|
||||||
intersection_file.Skip<std::uint32_t>(1); // sum_lengths
|
layout.GetBlockPtr<unsigned, true>(memory_ptr, storage::DataLayout::BEARING_OFFSETS);
|
||||||
|
auto blocks_ptr =
|
||||||
|
layout.GetBlockPtr<util::RangeTable<16, storage::Ownership::View>::BlockT, true>(
|
||||||
|
memory_ptr, storage::DataLayout::BEARING_BLOCKS);
|
||||||
|
util::vector_view<unsigned> bearing_offsets(
|
||||||
|
offsets_ptr, layout.num_entries[storage::DataLayout::BEARING_OFFSETS]);
|
||||||
|
util::vector_view<util::RangeTable<16, storage::Ownership::View>::BlockT> bearing_blocks(
|
||||||
|
blocks_ptr, layout.num_entries[storage::DataLayout::BEARING_BLOCKS]);
|
||||||
|
|
||||||
std::vector<unsigned> bearing_offsets_data(bearing_blocks);
|
util::RangeTable<16, storage::Ownership::View> bearing_range_table(
|
||||||
std::vector<typename util::RangeTable<16, storage::Ownership::View>::BlockT>
|
bearing_offsets, bearing_blocks, static_cast<unsigned>(bearing_values.size()));
|
||||||
bearing_blocks_data(bearing_blocks);
|
|
||||||
|
|
||||||
intersection_file.ReadInto(bearing_offsets_data.data(), bearing_blocks);
|
extractor::IntersectionBearingsView intersection_bearings_view{
|
||||||
intersection_file.ReadInto(bearing_blocks_data.data(), bearing_blocks);
|
std::move(bearing_values), std::move(bearing_class_id), std::move(bearing_range_table)};
|
||||||
|
|
||||||
const auto num_bearings = intersection_file.ReadElementCount64();
|
auto entry_class_ptr = layout.GetBlockPtr<util::guidance::EntryClass, true>(
|
||||||
|
memory_ptr, storage::DataLayout::ENTRY_CLASS);
|
||||||
|
util::vector_view<util::guidance::EntryClass> entry_classes(
|
||||||
|
entry_class_ptr, layout.num_entries[storage::DataLayout::ENTRY_CLASS]);
|
||||||
|
|
||||||
std::vector<DiscreteBearing> bearing_class_table(num_bearings);
|
extractor::files::readIntersections(
|
||||||
intersection_file.ReadInto(bearing_class_table.data(), num_bearings);
|
config.intersection_class_path, intersection_bearings_view, entry_classes);
|
||||||
|
|
||||||
std::vector<util::guidance::EntryClass> entry_class_table;
|
|
||||||
serialization::read(intersection_file, entry_class_table);
|
|
||||||
|
|
||||||
// load intersection classes
|
|
||||||
if (!bearing_class_id_table.empty())
|
|
||||||
{
|
|
||||||
const auto bearing_id_ptr =
|
|
||||||
layout.GetBlockPtr<BearingClassID, true>(memory_ptr, DataLayout::BEARING_CLASSID);
|
|
||||||
BOOST_ASSERT(
|
|
||||||
static_cast<std::size_t>(layout.GetBlockSize(DataLayout::BEARING_CLASSID)) >=
|
|
||||||
std::distance(bearing_class_id_table.begin(), bearing_class_id_table.end()) *
|
|
||||||
sizeof(decltype(bearing_class_id_table)::value_type));
|
|
||||||
std::copy(bearing_class_id_table.begin(), bearing_class_id_table.end(), bearing_id_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (layout.GetBlockSize(DataLayout::BEARING_OFFSETS) > 0)
|
|
||||||
{
|
|
||||||
const auto bearing_offsets_ptr =
|
|
||||||
layout.GetBlockPtr<unsigned, true>(memory_ptr, DataLayout::BEARING_OFFSETS);
|
|
||||||
BOOST_ASSERT(
|
|
||||||
static_cast<std::size_t>(layout.GetBlockSize(DataLayout::BEARING_OFFSETS)) >=
|
|
||||||
std::distance(bearing_offsets_data.begin(), bearing_offsets_data.end()) *
|
|
||||||
sizeof(decltype(bearing_offsets_data)::value_type));
|
|
||||||
std::copy(
|
|
||||||
bearing_offsets_data.begin(), bearing_offsets_data.end(), bearing_offsets_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (layout.GetBlockSize(DataLayout::BEARING_BLOCKS) > 0)
|
|
||||||
{
|
|
||||||
const auto bearing_blocks_ptr =
|
|
||||||
layout.GetBlockPtr<typename util::RangeTable<16, storage::Ownership::View>::BlockT,
|
|
||||||
true>(memory_ptr, DataLayout::BEARING_BLOCKS);
|
|
||||||
BOOST_ASSERT(
|
|
||||||
static_cast<std::size_t>(layout.GetBlockSize(DataLayout::BEARING_BLOCKS)) >=
|
|
||||||
std::distance(bearing_blocks_data.begin(), bearing_blocks_data.end()) *
|
|
||||||
sizeof(decltype(bearing_blocks_data)::value_type));
|
|
||||||
std::copy(bearing_blocks_data.begin(), bearing_blocks_data.end(), bearing_blocks_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!bearing_class_table.empty())
|
|
||||||
{
|
|
||||||
const auto bearing_class_ptr =
|
|
||||||
layout.GetBlockPtr<DiscreteBearing, true>(memory_ptr, DataLayout::BEARING_VALUES);
|
|
||||||
BOOST_ASSERT(
|
|
||||||
static_cast<std::size_t>(layout.GetBlockSize(DataLayout::BEARING_VALUES)) >=
|
|
||||||
std::distance(bearing_class_table.begin(), bearing_class_table.end()) *
|
|
||||||
sizeof(decltype(bearing_class_table)::value_type));
|
|
||||||
std::copy(bearing_class_table.begin(), bearing_class_table.end(), bearing_class_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!entry_class_table.empty())
|
|
||||||
{
|
|
||||||
const auto entry_class_ptr = layout.GetBlockPtr<util::guidance::EntryClass, true>(
|
|
||||||
memory_ptr, DataLayout::ENTRY_CLASS);
|
|
||||||
BOOST_ASSERT(static_cast<std::size_t>(layout.GetBlockSize(DataLayout::ENTRY_CLASS)) >=
|
|
||||||
std::distance(entry_class_table.begin(), entry_class_table.end()) *
|
|
||||||
sizeof(decltype(entry_class_table)::value_type));
|
|
||||||
std::copy(entry_class_table.begin(), entry_class_table.end(), entry_class_ptr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -208,8 +208,6 @@ class MockBaseDataFacade : public engine::datafacade::BaseDataFacade
|
|||||||
const char *GetWeightName() const override final { return "duration"; }
|
const char *GetWeightName() const override final { return "duration"; }
|
||||||
unsigned GetWeightPrecision() const override final { return 1; }
|
unsigned GetWeightPrecision() const override final { return 1; }
|
||||||
double GetWeightMultiplier() const override final { return 10.; }
|
double GetWeightMultiplier() const override final { return 10.; }
|
||||||
BearingClassID GetBearingClassID(const NodeID /*id*/) const override { return 0; }
|
|
||||||
EntryClassID GetEntryClassID(const EdgeID /*id*/) const override { return 0; }
|
|
||||||
bool IsLeftHandDriving() const override { return false; }
|
bool IsLeftHandDriving() const override { return false; }
|
||||||
|
|
||||||
util::guidance::TurnBearing PreTurnBearing(const EdgeID /*eid*/) const override final
|
util::guidance::TurnBearing PreTurnBearing(const EdgeID /*eid*/) const override final
|
||||||
@ -232,8 +230,7 @@ class MockBaseDataFacade : public engine::datafacade::BaseDataFacade
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
util::guidance::BearingClass
|
util::guidance::BearingClass GetBearingClass(const NodeID /*node*/) const override
|
||||||
GetBearingClass(const BearingClassID /*bearing_class_id*/) const override
|
|
||||||
{
|
{
|
||||||
util::guidance::BearingClass result;
|
util::guidance::BearingClass result;
|
||||||
result.add(0);
|
result.add(0);
|
||||||
@ -243,7 +240,7 @@ class MockBaseDataFacade : public engine::datafacade::BaseDataFacade
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
util::guidance::EntryClass GetEntryClass(const EntryClassID /*entry_class_id*/) const override
|
util::guidance::EntryClass GetEntryClass(const EdgeID /*id*/) const override
|
||||||
{
|
{
|
||||||
util::guidance::EntryClass result;
|
util::guidance::EntryClass result;
|
||||||
result.activate(1);
|
result.activate(1);
|
||||||
|
Loading…
Reference in New Issue
Block a user