2017-04-01 14:44:49 -04:00
|
|
|
#ifndef OSRM_EXTRACTOR_FILES_HPP
|
|
|
|
#define OSRM_EXTRACTOR_FILES_HPP
|
|
|
|
|
2017-05-19 18:28:01 -04:00
|
|
|
#include "extractor/edge_based_edge.hpp"
|
2017-04-25 05:36:34 -04:00
|
|
|
#include "extractor/node_data_container.hpp"
|
2017-06-19 09:27:46 -04:00
|
|
|
#include "extractor/profile_properties.hpp"
|
2017-04-04 18:00:17 -04:00
|
|
|
#include "extractor/serialization.hpp"
|
2018-01-05 08:33:53 -05:00
|
|
|
#include "extractor/turn_lane_types.hpp"
|
2017-04-01 14:44:49 -04:00
|
|
|
|
2017-04-02 19:58:06 -04:00
|
|
|
#include "util/coordinate.hpp"
|
2017-06-19 09:27:46 -04:00
|
|
|
#include "util/guidance/bearing_class.hpp"
|
|
|
|
#include "util/guidance/entry_class.hpp"
|
2017-04-02 19:58:06 -04:00
|
|
|
#include "util/packed_vector.hpp"
|
2017-06-19 09:27:46 -04:00
|
|
|
#include "util/range_table.hpp"
|
2017-04-02 19:58:06 -04:00
|
|
|
#include "util/serialization.hpp"
|
|
|
|
|
2017-04-01 14:44:49 -04:00
|
|
|
#include <boost/assert.hpp>
|
|
|
|
|
|
|
|
namespace osrm
|
|
|
|
{
|
|
|
|
namespace extractor
|
|
|
|
{
|
|
|
|
namespace files
|
|
|
|
{
|
|
|
|
|
2017-06-19 09:27:46 -04:00
|
|
|
// 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);
|
|
|
|
}
|
|
|
|
|
2017-06-16 05:30:37 -04:00
|
|
|
// reads .osrm.properties
|
2017-06-19 09:27:46 -04:00
|
|
|
inline void readProfileProperties(const boost::filesystem::path &path,
|
|
|
|
ProfileProperties &properties)
|
2017-06-16 05:30:37 -04:00
|
|
|
{
|
|
|
|
const auto fingerprint = storage::io::FileReader::VerifyFingerprint;
|
|
|
|
storage::io::FileReader reader{path, fingerprint};
|
|
|
|
|
|
|
|
serialization::read(reader, properties);
|
|
|
|
}
|
|
|
|
|
|
|
|
// writes .osrm.properties
|
|
|
|
inline void writeProfileProperties(const boost::filesystem::path &path,
|
2017-06-19 09:27:46 -04:00
|
|
|
const ProfileProperties &properties)
|
2017-06-16 05:30:37 -04:00
|
|
|
{
|
|
|
|
const auto fingerprint = storage::io::FileWriter::GenerateFingerprint;
|
|
|
|
storage::io::FileWriter writer{path, fingerprint};
|
|
|
|
|
|
|
|
serialization::write(writer, properties);
|
|
|
|
}
|
|
|
|
|
2017-05-19 18:28:01 -04:00
|
|
|
template <typename EdgeBasedEdgeVector>
|
|
|
|
void writeEdgeBasedGraph(const boost::filesystem::path &path,
|
2017-09-25 09:37:11 -04:00
|
|
|
EdgeID const number_of_edge_based_nodes,
|
2018-02-01 10:00:15 -05:00
|
|
|
const EdgeBasedEdgeVector &edge_based_edge_list,
|
|
|
|
const std::uint32_t connectivity_checksum)
|
2017-05-19 18:28:01 -04:00
|
|
|
{
|
|
|
|
static_assert(std::is_same<typename EdgeBasedEdgeVector::value_type, EdgeBasedEdge>::value, "");
|
|
|
|
|
|
|
|
storage::io::FileWriter writer(path, storage::io::FileWriter::GenerateFingerprint);
|
|
|
|
|
2017-09-25 09:37:11 -04:00
|
|
|
writer.WriteElementCount64(number_of_edge_based_nodes);
|
2017-05-19 18:28:01 -04:00
|
|
|
storage::serialization::write(writer, edge_based_edge_list);
|
2018-02-01 10:00:15 -05:00
|
|
|
writer.WriteOne(connectivity_checksum);
|
2017-05-19 18:28:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename EdgeBasedEdgeVector>
|
|
|
|
void readEdgeBasedGraph(const boost::filesystem::path &path,
|
2017-09-25 09:37:11 -04:00
|
|
|
EdgeID &number_of_edge_based_nodes,
|
2018-02-01 10:00:15 -05:00
|
|
|
EdgeBasedEdgeVector &edge_based_edge_list,
|
|
|
|
std::uint32_t &connectivity_checksum)
|
2017-05-19 18:28:01 -04:00
|
|
|
{
|
|
|
|
static_assert(std::is_same<typename EdgeBasedEdgeVector::value_type, EdgeBasedEdge>::value, "");
|
|
|
|
|
|
|
|
storage::io::FileReader reader(path, storage::io::FileReader::VerifyFingerprint);
|
|
|
|
|
2017-09-25 09:37:11 -04:00
|
|
|
number_of_edge_based_nodes = reader.ReadElementCount64();
|
2017-05-19 18:28:01 -04:00
|
|
|
storage::serialization::read(reader, edge_based_edge_list);
|
2018-02-01 10:00:15 -05:00
|
|
|
reader.ReadInto(connectivity_checksum);
|
2017-05-19 18:28:01 -04:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2017-05-23 11:37:41 -04:00
|
|
|
// reads .osrm.ebg_nodes
|
2017-04-25 05:36:34 -04:00
|
|
|
template <typename NodeDataT>
|
|
|
|
inline void readNodeData(const boost::filesystem::path &path, NodeDataT &node_data)
|
|
|
|
{
|
|
|
|
static_assert(std::is_same<EdgeBasedNodeDataContainer, NodeDataT>::value ||
|
|
|
|
std::is_same<EdgeBasedNodeDataView, NodeDataT>::value ||
|
|
|
|
std::is_same<EdgeBasedNodeDataExternalContainer, NodeDataT>::value,
|
|
|
|
"");
|
|
|
|
const auto fingerprint = storage::io::FileReader::VerifyFingerprint;
|
|
|
|
storage::io::FileReader reader{path, fingerprint};
|
|
|
|
|
|
|
|
serialization::read(reader, node_data);
|
|
|
|
}
|
|
|
|
|
2017-05-23 11:37:41 -04:00
|
|
|
// writes .osrm.ebg_nodes
|
2017-04-25 05:36:34 -04:00
|
|
|
template <typename NodeDataT>
|
|
|
|
inline void writeNodeData(const boost::filesystem::path &path, const NodeDataT &node_data)
|
|
|
|
{
|
|
|
|
static_assert(std::is_same<EdgeBasedNodeDataContainer, NodeDataT>::value ||
|
|
|
|
std::is_same<EdgeBasedNodeDataView, NodeDataT>::value ||
|
|
|
|
std::is_same<EdgeBasedNodeDataExternalContainer, NodeDataT>::value,
|
|
|
|
"");
|
|
|
|
const auto fingerprint = storage::io::FileWriter::GenerateFingerprint;
|
|
|
|
storage::io::FileWriter writer{path, fingerprint};
|
|
|
|
|
|
|
|
serialization::write(writer, node_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
|
|
|
{
|
2018-01-05 08:33:53 -05:00
|
|
|
static_assert(std::is_same<typename MaskT::value_type, extractor::TurnLaneType::Mask>::value,
|
|
|
|
"");
|
2017-04-04 20:11:39 -04:00
|
|
|
static_assert(std::is_same<typename OffsetsT::value_type, std::uint32_t>::value, "");
|
|
|
|
|
2017-04-07 08:05:19 -04:00
|
|
|
const auto fingerprint = storage::io::FileReader::VerifyFingerprint;
|
2017-04-02 13:47:17 -04:00
|
|
|
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
|
|
|
{
|
2018-01-05 08:33:53 -05:00
|
|
|
static_assert(std::is_same<typename MaskT::value_type, extractor::TurnLaneType::Mask>::value,
|
|
|
|
"");
|
2017-04-04 20:11:39 -04:00
|
|
|
static_assert(std::is_same<typename OffsetsT::value_type, std::uint32_t>::value, "");
|
|
|
|
|
2017-04-07 08:05:19 -04:00
|
|
|
const auto fingerprint = storage::io::FileWriter::GenerateFingerprint;
|
2017-04-02 13:47:17 -04:00
|
|
|
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
|