2017-04-01 14:44:49 -04:00
|
|
|
#ifndef OSRM_EXTRACTOR_FILES_HPP
|
|
|
|
#define OSRM_EXTRACTOR_FILES_HPP
|
|
|
|
|
2017-04-02 13:47:17 -04:00
|
|
|
#include "extractor/guidance/turn_lane_types.hpp"
|
2017-04-04 18:00:17 -04:00
|
|
|
#include "extractor/serialization.hpp"
|
2017-04-01 14:44:49 -04:00
|
|
|
|
2017-04-02 19:58:06 -04:00
|
|
|
#include "util/coordinate.hpp"
|
|
|
|
#include "util/packed_vector.hpp"
|
|
|
|
#include "util/serialization.hpp"
|
|
|
|
|
2017-04-01 14:44:49 -04:00
|
|
|
#include <boost/assert.hpp>
|
|
|
|
|
|
|
|
namespace osrm
|
|
|
|
{
|
|
|
|
namespace extractor
|
|
|
|
{
|
|
|
|
namespace files
|
|
|
|
{
|
|
|
|
|
2017-04-02 19:58:06 -04:00
|
|
|
// reads .osrm.nodes
|
2017-04-04 20:11:39 -04:00
|
|
|
template <typename CoordinatesT, typename PackedOSMIDsT>
|
2017-04-02 19:58:06 -04:00
|
|
|
inline void readNodes(const boost::filesystem::path &path,
|
2017-04-04 20:11:39 -04:00
|
|
|
CoordinatesT &coordinates,
|
|
|
|
PackedOSMIDsT &osm_node_ids)
|
2017-04-02 19:58:06 -04:00
|
|
|
{
|
2017-04-04 20:11:39 -04:00
|
|
|
static_assert(std::is_same<typename CoordinatesT::value_type, util::Coordinate>::value, "");
|
|
|
|
static_assert(std::is_same<typename PackedOSMIDsT::value_type, OSMNodeID>::value, "");
|
|
|
|
|
2017-04-02 19:58:06 -04:00
|
|
|
const auto fingerprint = storage::io::FileReader::VerifyFingerprint;
|
|
|
|
storage::io::FileReader reader{path, fingerprint};
|
|
|
|
|
2017-04-04 18:00:17 -04:00
|
|
|
storage::serialization::read(reader, coordinates);
|
2017-04-02 19:58:06 -04:00
|
|
|
util::serialization::read(reader, osm_node_ids);
|
|
|
|
}
|
|
|
|
|
|
|
|
// writes .osrm.nodes
|
2017-04-04 20:11:39 -04:00
|
|
|
template <typename CoordinatesT, typename PackedOSMIDsT>
|
2017-04-02 19:58:06 -04:00
|
|
|
inline void writeNodes(const boost::filesystem::path &path,
|
2017-04-04 20:11:39 -04:00
|
|
|
const CoordinatesT &coordinates,
|
|
|
|
const PackedOSMIDsT &osm_node_ids)
|
2017-04-02 19:58:06 -04:00
|
|
|
{
|
2017-04-04 20:11:39 -04:00
|
|
|
static_assert(std::is_same<typename CoordinatesT::value_type, util::Coordinate>::value, "");
|
|
|
|
static_assert(std::is_same<typename PackedOSMIDsT::value_type, OSMNodeID>::value, "");
|
|
|
|
|
2017-04-02 19:58:06 -04:00
|
|
|
const auto fingerprint = storage::io::FileWriter::GenerateFingerprint;
|
|
|
|
storage::io::FileWriter writer{path, fingerprint};
|
|
|
|
|
2017-04-04 18:00:17 -04:00
|
|
|
storage::serialization::write(writer, coordinates);
|
2017-04-02 19:58:06 -04:00
|
|
|
util::serialization::write(writer, osm_node_ids);
|
|
|
|
}
|
|
|
|
|
2017-04-01 14:44:49 -04:00
|
|
|
// reads .osrm.cnbg_to_ebg
|
|
|
|
inline void readNBGMapping(const boost::filesystem::path &path, std::vector<NBGToEBG> &mapping)
|
|
|
|
{
|
|
|
|
const auto fingerprint = storage::io::FileReader::VerifyFingerprint;
|
|
|
|
storage::io::FileReader reader{path, fingerprint};
|
|
|
|
|
2017-04-04 18:00:17 -04:00
|
|
|
storage::serialization::read(reader, mapping);
|
2017-04-01 14:44:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// writes .osrm.cnbg_to_ebg
|
2017-04-01 21:25:55 -04:00
|
|
|
inline void writeNBGMapping(const boost::filesystem::path &path,
|
|
|
|
const std::vector<NBGToEBG> &mapping)
|
2017-04-01 14:44:49 -04:00
|
|
|
{
|
|
|
|
const auto fingerprint = storage::io::FileWriter::GenerateFingerprint;
|
|
|
|
storage::io::FileWriter writer{path, fingerprint};
|
|
|
|
|
2017-04-04 18:00:17 -04:00
|
|
|
storage::serialization::write(writer, mapping);
|
2017-04-01 14:44:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// reads .osrm.datasource_names
|
|
|
|
inline void readDatasources(const boost::filesystem::path &path, Datasources &sources)
|
|
|
|
{
|
2017-04-07 05:25:06 -04:00
|
|
|
const auto fingerprint = storage::io::FileReader::VerifyFingerprint;
|
2017-04-01 14:44:49 -04:00
|
|
|
storage::io::FileReader reader{path, fingerprint};
|
|
|
|
|
|
|
|
serialization::read(reader, sources);
|
|
|
|
}
|
|
|
|
|
|
|
|
// writes .osrm.datasource_names
|
|
|
|
inline void writeDatasources(const boost::filesystem::path &path, Datasources &sources)
|
|
|
|
{
|
2017-04-07 05:25:06 -04:00
|
|
|
const auto fingerprint = storage::io::FileWriter::GenerateFingerprint;
|
2017-04-01 14:44:49 -04:00
|
|
|
storage::io::FileWriter writer{path, fingerprint};
|
|
|
|
|
|
|
|
serialization::write(writer, sources);
|
|
|
|
}
|
|
|
|
|
|
|
|
// reads .osrm.geometry
|
2017-04-04 20:11:39 -04:00
|
|
|
template <typename SegmentDataT>
|
|
|
|
inline void readSegmentData(const boost::filesystem::path &path, SegmentDataT &segment_data)
|
2017-04-01 14:44:49 -04:00
|
|
|
{
|
2017-04-04 20:11:39 -04:00
|
|
|
static_assert(std::is_same<SegmentDataContainer, SegmentDataT>::value ||
|
|
|
|
std::is_same<SegmentDataView, SegmentDataT>::value,
|
|
|
|
"");
|
2017-04-07 06:00:07 -04:00
|
|
|
const auto fingerprint = storage::io::FileReader::VerifyFingerprint;
|
2017-04-01 14:44:49 -04:00
|
|
|
storage::io::FileReader reader{path, fingerprint};
|
|
|
|
|
|
|
|
serialization::read(reader, segment_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
// writes .osrm.geometry
|
2017-04-04 20:11:39 -04:00
|
|
|
template <typename SegmentDataT>
|
|
|
|
inline void writeSegmentData(const boost::filesystem::path &path, const SegmentDataT &segment_data)
|
2017-04-01 14:44:49 -04:00
|
|
|
{
|
2017-04-04 20:11:39 -04:00
|
|
|
static_assert(std::is_same<SegmentDataContainer, SegmentDataT>::value ||
|
|
|
|
std::is_same<SegmentDataView, SegmentDataT>::value,
|
|
|
|
"");
|
2017-04-07 06:00:07 -04:00
|
|
|
const auto fingerprint = storage::io::FileWriter::GenerateFingerprint;
|
2017-04-01 14:44:49 -04:00
|
|
|
storage::io::FileWriter writer{path, fingerprint};
|
|
|
|
|
|
|
|
serialization::write(writer, segment_data);
|
|
|
|
}
|
2017-04-01 21:00:03 -04:00
|
|
|
|
|
|
|
// reads .osrm.edges
|
2017-04-04 20:11:39 -04:00
|
|
|
template <typename TurnDataT>
|
|
|
|
inline void readTurnData(const boost::filesystem::path &path, TurnDataT &turn_data)
|
2017-04-01 21:00:03 -04:00
|
|
|
{
|
2017-04-04 20:11:39 -04:00
|
|
|
static_assert(std::is_same<TurnDataContainer, TurnDataT>::value ||
|
2017-04-09 09:59:55 -04:00
|
|
|
std::is_same<TurnDataView, TurnDataT>::value ||
|
|
|
|
std::is_same<TurnDataExternalContainer, TurnDataT>::value,
|
2017-04-04 20:11:39 -04:00
|
|
|
"");
|
2017-04-07 07:34:15 -04:00
|
|
|
const auto fingerprint = storage::io::FileReader::VerifyFingerprint;
|
2017-04-01 21:00:03 -04:00
|
|
|
storage::io::FileReader reader{path, fingerprint};
|
|
|
|
|
|
|
|
serialization::read(reader, turn_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
// writes .osrm.edges
|
2017-04-04 20:11:39 -04:00
|
|
|
template <typename TurnDataT>
|
|
|
|
inline void writeTurnData(const boost::filesystem::path &path, const TurnDataT &turn_data)
|
2017-04-01 21:00:03 -04:00
|
|
|
{
|
2017-04-04 20:11:39 -04:00
|
|
|
static_assert(std::is_same<TurnDataContainer, TurnDataT>::value ||
|
2017-04-09 09:59:55 -04:00
|
|
|
std::is_same<TurnDataView, TurnDataT>::value ||
|
|
|
|
std::is_same<TurnDataExternalContainer, TurnDataT>::value,
|
2017-04-04 20:11:39 -04:00
|
|
|
"");
|
2017-04-07 07:34:15 -04:00
|
|
|
const auto fingerprint = storage::io::FileWriter::GenerateFingerprint;
|
2017-04-01 21:00:03 -04:00
|
|
|
storage::io::FileWriter writer{path, fingerprint};
|
|
|
|
|
|
|
|
serialization::write(writer, turn_data);
|
|
|
|
}
|
2017-04-02 13:47:17 -04:00
|
|
|
|
|
|
|
// reads .osrm.tls
|
2017-04-04 20:11:39 -04:00
|
|
|
template <typename OffsetsT, typename MaskT>
|
|
|
|
inline void readTurnLaneDescriptions(const boost::filesystem::path &path,
|
|
|
|
OffsetsT &turn_offsets,
|
|
|
|
MaskT &turn_masks)
|
2017-04-02 13:47:17 -04:00
|
|
|
{
|
2017-04-04 20:11:39 -04:00
|
|
|
static_assert(
|
|
|
|
std::is_same<typename MaskT::value_type, extractor::guidance::TurnLaneType::Mask>::value,
|
|
|
|
"");
|
|
|
|
static_assert(std::is_same<typename OffsetsT::value_type, std::uint32_t>::value, "");
|
|
|
|
|
2017-04-02 13:47:17 -04:00
|
|
|
const auto fingerprint = storage::io::FileReader::HasNoFingerprint;
|
|
|
|
storage::io::FileReader reader{path, fingerprint};
|
|
|
|
|
2017-04-04 18:00:17 -04:00
|
|
|
storage::serialization::read(reader, turn_offsets);
|
|
|
|
storage::serialization::read(reader, turn_masks);
|
2017-04-02 13:47:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// writes .osrm.tls
|
2017-04-04 20:11:39 -04:00
|
|
|
template <typename OffsetsT, typename MaskT>
|
|
|
|
inline void writeTurnLaneDescriptions(const boost::filesystem::path &path,
|
|
|
|
const OffsetsT &turn_offsets,
|
|
|
|
const MaskT &turn_masks)
|
2017-04-02 13:47:17 -04:00
|
|
|
{
|
2017-04-04 20:11:39 -04:00
|
|
|
static_assert(
|
|
|
|
std::is_same<typename MaskT::value_type, extractor::guidance::TurnLaneType::Mask>::value,
|
|
|
|
"");
|
|
|
|
static_assert(std::is_same<typename OffsetsT::value_type, std::uint32_t>::value, "");
|
|
|
|
|
2017-04-02 13:47:17 -04:00
|
|
|
const auto fingerprint = storage::io::FileWriter::HasNoFingerprint;
|
|
|
|
storage::io::FileWriter writer{path, fingerprint};
|
|
|
|
|
2017-04-04 18:00:17 -04:00
|
|
|
storage::serialization::write(writer, turn_offsets);
|
|
|
|
storage::serialization::write(writer, turn_masks);
|
2017-04-02 13:47:17 -04:00
|
|
|
}
|
2017-04-01 14:44:49 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|