Port isc file
This commit is contained in:
committed by
Patrick Niklaus
parent
37b8d3acd4
commit
e5464526c8
@@ -4,12 +4,15 @@
|
||||
#include "extractor/edge_based_edge.hpp"
|
||||
#include "extractor/guidance/turn_lane_types.hpp"
|
||||
#include "extractor/node_data_container.hpp"
|
||||
#include "extractor/profile_properties.hpp"
|
||||
#include "extractor/serialization.hpp"
|
||||
#include "extractor/turn_data_container.hpp"
|
||||
#include "extractor/profile_properties.hpp"
|
||||
|
||||
#include "util/coordinate.hpp"
|
||||
#include "util/guidance/bearing_class.hpp"
|
||||
#include "util/guidance/entry_class.hpp"
|
||||
#include "util/packed_vector.hpp"
|
||||
#include "util/range_table.hpp"
|
||||
#include "util/serialization.hpp"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
@@ -21,8 +24,41 @@ namespace extractor
|
||||
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
|
||||
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;
|
||||
storage::io::FileReader reader{path, fingerprint};
|
||||
@@ -32,7 +68,7 @@ inline void readProfileProperties(const boost::filesystem::path &path, ProfilePr
|
||||
|
||||
// writes .osrm.properties
|
||||
inline void writeProfileProperties(const boost::filesystem::path &path,
|
||||
const ProfileProperties &properties)
|
||||
const ProfileProperties &properties)
|
||||
{
|
||||
const auto fingerprint = storage::io::FileWriter::GenerateFingerprint;
|
||||
storage::io::FileWriter writer{path, fingerprint};
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
#include <bitset>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <numeric> //partial_sum
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <numeric> //partial_sum
|
||||
|
||||
#include <boost/functional/hash.hpp>
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
#include "extractor/datasources.hpp"
|
||||
#include "extractor/intersection_bearings_container.hpp"
|
||||
#include "extractor/nbg_to_ebg.hpp"
|
||||
#include "extractor/node_data_container.hpp"
|
||||
#include "extractor/profile_properties.hpp"
|
||||
#include "extractor/restriction.hpp"
|
||||
#include "extractor/segment_data_container.hpp"
|
||||
#include "extractor/turn_data_container.hpp"
|
||||
#include "extractor/profile_properties.hpp"
|
||||
|
||||
#include "storage/io.hpp"
|
||||
#include "storage/serialization.hpp"
|
||||
@@ -21,6 +22,25 @@ namespace extractor
|
||||
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
|
||||
inline void read(storage::io::FileReader &reader, ProfileProperties &properties)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user