Add update functionality to osrm-customize
All speed file flags are compatible with osrm-contract.
This commit is contained in:
committed by
Patrick Niklaus
parent
c6e9cc8024
commit
907f933a54
@@ -0,0 +1,43 @@
|
||||
#ifndef OSRM_EDGE_BASED_GRAPH_HPP
|
||||
#define OSRM_EDGE_BASED_GRAPH_HPP
|
||||
|
||||
#include "extractor/edge_based_edge.hpp"
|
||||
#include "storage/io.hpp"
|
||||
#include "util/coordinate.hpp"
|
||||
#include "util/dynamic_graph.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace partition
|
||||
{
|
||||
|
||||
struct EdgeBasedGraphEdgeData : extractor::EdgeBasedEdge::EdgeData
|
||||
{
|
||||
// We need to write out the full edge based graph again.
|
||||
|
||||
// TODO: in case we want to modify the graph we need to store a boundary_arc flag here
|
||||
};
|
||||
|
||||
struct DynamicEdgeBasedGraph : util::DynamicGraph<EdgeBasedGraphEdgeData>
|
||||
{
|
||||
using Base = util::DynamicGraph<EdgeBasedGraphEdgeData>;
|
||||
using Base::Base;
|
||||
};
|
||||
|
||||
struct DynamicEdgeBasedGraphEdge : DynamicEdgeBasedGraph::InputEdge
|
||||
{
|
||||
using Base = DynamicEdgeBasedGraph::InputEdge;
|
||||
using Base::Base;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef OSRM_EDGE_BASED_GRAPH_READER_HPP
|
||||
#define OSRM_EDGE_BASED_GRAPH_READER_HPP
|
||||
|
||||
#include "partition/edge_based_graph.hpp"
|
||||
|
||||
#include "extractor/edge_based_edge.hpp"
|
||||
#include "storage/io.hpp"
|
||||
#include "util/coordinate.hpp"
|
||||
@@ -19,25 +21,6 @@ namespace osrm
|
||||
namespace partition
|
||||
{
|
||||
|
||||
struct EdgeBasedGraphEdgeData : extractor::EdgeBasedEdge::EdgeData
|
||||
{
|
||||
// We need to write out the full edge based graph again.
|
||||
|
||||
// TODO: in case we want to modify the graph we need to store a boundary_arc flag here
|
||||
};
|
||||
|
||||
struct EdgeBasedGraph : util::DynamicGraph<EdgeBasedGraphEdgeData>
|
||||
{
|
||||
using Base = util::DynamicGraph<EdgeBasedGraphEdgeData>;
|
||||
using Base::Base;
|
||||
};
|
||||
|
||||
struct EdgeBasedGraphEdge : EdgeBasedGraph::InputEdge
|
||||
{
|
||||
using Base = EdgeBasedGraph::InputEdge;
|
||||
using Base::Base;
|
||||
};
|
||||
|
||||
// Bidirectional (s,t) to (s,t) and (t,s)
|
||||
std::vector<extractor::EdgeBasedEdge>
|
||||
splitBidirectionalEdges(const std::vector<extractor::EdgeBasedEdge> &edges)
|
||||
@@ -67,12 +50,12 @@ splitBidirectionalEdges(const std::vector<extractor::EdgeBasedEdge> &edges)
|
||||
return directed;
|
||||
}
|
||||
|
||||
std::vector<EdgeBasedGraphEdge>
|
||||
prepareEdgesForUsageInGraph(std::vector<extractor::EdgeBasedEdge> edges)
|
||||
template <typename OutputEdgeT>
|
||||
std::vector<OutputEdgeT> prepareEdgesForUsageInGraph(std::vector<extractor::EdgeBasedEdge> edges)
|
||||
{
|
||||
std::sort(begin(edges), end(edges));
|
||||
|
||||
std::vector<EdgeBasedGraphEdge> graph_edges;
|
||||
std::vector<OutputEdgeT> graph_edges;
|
||||
graph_edges.reserve(edges.size());
|
||||
|
||||
for (NodeID i = 0; i < edges.size();)
|
||||
@@ -87,8 +70,8 @@ prepareEdgesForUsageInGraph(std::vector<extractor::EdgeBasedEdge> edges)
|
||||
continue;
|
||||
}
|
||||
|
||||
EdgeBasedGraphEdge forward_edge;
|
||||
EdgeBasedGraphEdge reverse_edge;
|
||||
OutputEdgeT forward_edge;
|
||||
OutputEdgeT reverse_edge;
|
||||
forward_edge.source = reverse_edge.source = source;
|
||||
forward_edge.target = reverse_edge.target = target;
|
||||
forward_edge.data.edge_id = reverse_edge.data.edge_id = edges[i].data.edge_id;
|
||||
@@ -161,7 +144,7 @@ struct EdgeBasedGraphReader
|
||||
|
||||
// FIXME: wrapped in unique_ptr since dynamic_graph is not move-able
|
||||
|
||||
std::unique_ptr<EdgeBasedGraph> BuildEdgeBasedGraph()
|
||||
std::unique_ptr<DynamicEdgeBasedGraph> BuildEdgeBasedGraph()
|
||||
{
|
||||
// FIXME: The following is a rough adaption from:
|
||||
// - adaptToContractorInput
|
||||
@@ -170,9 +153,9 @@ struct EdgeBasedGraphReader
|
||||
// FIXME: edges passed as a const reference, can be changed pass-by-value if can be moved
|
||||
|
||||
auto directed = splitBidirectionalEdges(edges);
|
||||
auto tidied = prepareEdgesForUsageInGraph(std::move(directed));
|
||||
auto tidied = prepareEdgesForUsageInGraph<DynamicEdgeBasedGraphEdge>(std::move(directed));
|
||||
|
||||
return std::make_unique<EdgeBasedGraph>(num_nodes, std::move(tidied));
|
||||
return std::make_unique<DynamicEdgeBasedGraph>(num_nodes, std::move(tidied));
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -180,7 +163,7 @@ struct EdgeBasedGraphReader
|
||||
std::size_t num_nodes;
|
||||
};
|
||||
|
||||
inline std::unique_ptr<EdgeBasedGraph> LoadEdgeBasedGraph(const std::string &path)
|
||||
inline std::unique_ptr<DynamicEdgeBasedGraph> LoadEdgeBasedGraph(const std::string &path)
|
||||
{
|
||||
const auto fingerprint = storage::io::FileReader::VerifyFingerprint;
|
||||
storage::io::FileReader reader(path, fingerprint);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define OSRM_PARTITION_IO_HPP
|
||||
|
||||
#include "partition/cell_storage.hpp"
|
||||
#include "partition/edge_based_graph.hpp"
|
||||
#include "partition/multi_level_partition.hpp"
|
||||
|
||||
#include "storage/io.hpp"
|
||||
|
||||
Reference in New Issue
Block a user