Port .cnbg file to tar format

This commit is contained in:
Patrick Niklaus
2018-03-21 18:17:24 +00:00
parent 8152dcfb4c
commit c410c200bd
8 changed files with 87 additions and 132 deletions
@@ -0,0 +1,21 @@
#ifndef OSRM_EXTRACTOR_COMPRESSED_NODE_BASED_GRAPH_EDGE_HPP
#define OSRM_EXTRACTOR_COMPRESSED_NODE_BASED_GRAPH_EDGE_HPP
#include "util/typedefs.hpp"
namespace osrm
{
namespace extractor
{
// We encode the cnbg graph only using its topology as edge list
struct CompressedNodeBasedGraphEdge
{
NodeID source;
NodeID target;
};
}
}
#endif // OSRM_EXTRACTOR_COMPRESSED_NODE_BASED_GRAPH_EDGE_HPP
-5
View File
@@ -99,11 +99,6 @@ class Extractor
const std::vector<util::Coordinate> &coordinates);
std::shared_ptr<RestrictionMap> LoadRestrictionMap();
// Writes compressed node based graph and its embedding into a file for osrm-partition to use.
static void WriteCompressedNodeBasedGraph(const std::string &path,
const util::NodeBasedDynamicGraph &graph,
const std::vector<util::Coordinate> &coordiantes);
void WriteConditionalRestrictions(
const std::string &path,
std::vector<ConditionalTurnRestriction> &conditional_turn_restrictions);
+32
View File
@@ -94,6 +94,7 @@ void writeEdgeBasedGraph(const boost::filesystem::path &path,
writer.WriteFrom("/common/connectivity_checksum", connectivity_checksum);
}
// reads .osrm.ebg file
template <typename EdgeBasedEdgeVector>
void readEdgeBasedGraph(const boost::filesystem::path &path,
EdgeID &number_of_edge_based_nodes,
@@ -125,6 +126,19 @@ inline void readNodes(const boost::filesystem::path &path,
util::serialization::read(reader, "/common/osm_node_ids", osm_node_ids);
}
// reads only coordinates from .osrm.nbg_nodes
template <typename CoordinatesT>
inline void readNodeCoordinates(const boost::filesystem::path &path,
CoordinatesT &coordinates)
{
static_assert(std::is_same<typename CoordinatesT::value_type, util::Coordinate>::value, "");
const auto fingerprint = storage::tar::FileReader::VerifyFingerprint;
storage::tar::FileReader reader{path, fingerprint};
storage::serialization::read(reader, "/common/coordinates", coordinates);
}
// writes .osrm.nbg_nodes
template <typename CoordinatesT, typename PackedOSMIDsT>
inline void writeNodes(const boost::filesystem::path &path,
@@ -476,6 +490,24 @@ void readRamIndex(const boost::filesystem::path &path, RTreeT &rtree)
util::serialization::read(reader, "/common/rtree", rtree);
}
template <typename EdgeListT>
void writeCompressedNodeBasedGraph(const boost::filesystem::path &path, const EdgeListT &edge_list)
{
const auto fingerprint = storage::tar::FileWriter::GenerateFingerprint;
storage::tar::FileWriter writer{path, fingerprint};
storage::serialization::write(writer, "/extractor/cnbg", edge_list);
}
template <typename EdgeListT>
void readCompressedNodeBasedGraph(const boost::filesystem::path &path, EdgeListT &edge_list)
{
const auto fingerprint = storage::tar::FileReader::VerifyFingerprint;
storage::tar::FileReader reader{path, fingerprint};
storage::serialization::read(reader, "/extractor/cnbg", edge_list);
}
}
}
}