Refactor graph writing code in contractor
This commit is contained in:
committed by
Patrick Niklaus
parent
90c194fc81
commit
ef3fcdc6e6
@@ -68,9 +68,9 @@ class Contractor
|
||||
void WriteCoreNodeMarker(std::vector<bool> &&is_core_node) const;
|
||||
void WriteNodeLevels(std::vector<float> &&node_levels) const;
|
||||
void ReadNodeLevels(std::vector<float> &contraction_order) const;
|
||||
std::size_t
|
||||
void
|
||||
WriteContractedGraph(unsigned number_of_edge_based_nodes,
|
||||
const util::DeallocatingVector<QueryEdge> &contracted_edge_list);
|
||||
util::DeallocatingVector<QueryEdge> contracted_edge_list);
|
||||
void FindComponents(unsigned max_edge_id,
|
||||
const util::DeallocatingVector<extractor::EdgeBasedEdge> &edges,
|
||||
std::vector<extractor::EdgeBasedNode> &nodes) const;
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
#ifndef OSRM_CONTRACTOR_FILES_HPP
|
||||
#define OSRM_CONTRACTOR_FILES_HPP
|
||||
|
||||
#include "contractor/query_graph.hpp"
|
||||
|
||||
#include "util/serialization.hpp"
|
||||
|
||||
#include "storage/io.hpp"
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace contractor
|
||||
{
|
||||
namespace files
|
||||
{
|
||||
|
||||
// reads .osrm.hsgr file
|
||||
template<storage::Ownership Ownership>
|
||||
inline void readGraph(const boost::filesystem::path &path,
|
||||
unsigned &checksum,
|
||||
detail::QueryGraph<Ownership> &graph)
|
||||
{
|
||||
const auto fingerprint = storage::io::FileReader::VerifyFingerprint;
|
||||
storage::io::FileReader reader{path, fingerprint};
|
||||
|
||||
reader.ReadInto(checksum);
|
||||
util::serialization::read(reader, graph);
|
||||
}
|
||||
|
||||
// writes .osrm.hsgr file
|
||||
template<storage::Ownership Ownership>
|
||||
inline void writeGraph(const boost::filesystem::path &path,
|
||||
unsigned checksum,
|
||||
const detail::QueryGraph<Ownership> &graph)
|
||||
{
|
||||
const auto fingerprint = storage::io::FileWriter::GenerateFingerprint;
|
||||
storage::io::FileWriter writer{path, fingerprint};
|
||||
|
||||
writer.WriteOne(checksum);
|
||||
util::serialization::write(writer, graph);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef OSRM_CONTRACTOR_QUERY_GRAPH_HPP
|
||||
#define OSRM_CONTRACTOR_QUERY_GRAPH_HPP
|
||||
|
||||
#include "contractor/query_edge.hpp"
|
||||
|
||||
#include "util/typedefs.hpp"
|
||||
#include "util/static_graph.hpp"
|
||||
|
||||
#include <tuple>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace contractor
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <storage::Ownership Ownership> using QueryGraph = util::StaticGraph<typename QueryEdge::EdgeData, Ownership>;
|
||||
}
|
||||
|
||||
using QueryGraph = detail::QueryGraph<storage::Ownership::Container>;
|
||||
using QueryGraphView = detail::QueryGraph<storage::Ownership::View>;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // QUERYEDGE_HPP
|
||||
Reference in New Issue
Block a user