Implements Mapping for NodeBasedGraph -> EdgeBasedgraph Translation
This commit is contained in:
committed by
Patrick Niklaus
parent
299d071e9d
commit
f71d742b5e
@@ -7,18 +7,16 @@
|
||||
#include "extractor/edge_based_edge.hpp"
|
||||
#include "extractor/edge_based_node.hpp"
|
||||
#include "extractor/extraction_turn.hpp"
|
||||
#include "extractor/guidance/turn_analysis.hpp"
|
||||
#include "extractor/guidance/turn_instruction.hpp"
|
||||
#include "extractor/guidance/turn_lane_types.hpp"
|
||||
#include "extractor/original_edge_data.hpp"
|
||||
#include "extractor/profile_properties.hpp"
|
||||
#include "extractor/query_node.hpp"
|
||||
#include "extractor/restriction_map.hpp"
|
||||
|
||||
#include "extractor/guidance/turn_analysis.hpp"
|
||||
#include "extractor/guidance/turn_instruction.hpp"
|
||||
#include "extractor/guidance/turn_lane_types.hpp"
|
||||
#include "util/deallocating_vector.hpp"
|
||||
#include "util/guidance/bearing_class.hpp"
|
||||
#include "util/guidance/entry_class.hpp"
|
||||
|
||||
#include "util/deallocating_vector.hpp"
|
||||
#include "util/name_table.hpp"
|
||||
#include "util/node_based_graph.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
@@ -35,6 +33,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
@@ -86,7 +85,9 @@ struct TurnIndexBlock
|
||||
#pragma pack(pop)
|
||||
static_assert(std::is_trivial<TurnIndexBlock>::value, "TurnIndexBlock is not trivial");
|
||||
static_assert(sizeof(TurnIndexBlock) == 24, "TurnIndexBlock is not packed correctly");
|
||||
}
|
||||
} // ns lookup
|
||||
|
||||
struct NodeBasedGraphToEdgeBasedGraphMappingWriter; // fwd. decl
|
||||
|
||||
class EdgeBasedGraphFactory
|
||||
{
|
||||
@@ -113,7 +114,9 @@ class EdgeBasedGraphFactory
|
||||
const std::string &turn_weight_penalties_filename,
|
||||
const std::string &turn_duration_penalties_filename,
|
||||
const std::string &turn_penalties_index_filename,
|
||||
const bool generate_edge_lookup);
|
||||
const bool generate_edge_lookup,
|
||||
const bool generate_nbg_ebg_mapping,
|
||||
const std::string &nbg_ebg_mapping_path);
|
||||
|
||||
// The following get access functions destroy the content in the factory
|
||||
void GetEdgeBasedEdges(util::DeallocatingVector<EdgeBasedEdge> &edges);
|
||||
@@ -172,7 +175,10 @@ class EdgeBasedGraphFactory
|
||||
guidance::LaneDescriptionMap &lane_description_map;
|
||||
|
||||
unsigned RenumberEdges();
|
||||
void GenerateEdgeExpandedNodes();
|
||||
|
||||
void GenerateEdgeExpandedNodes(const bool generate_nbg_ebg_mapping,
|
||||
const std::string &nbg_ebg_mapping_path);
|
||||
|
||||
void GenerateEdgeExpandedEdges(ScriptingEnvironment &scripting_environment,
|
||||
const std::string &original_edge_data_filename,
|
||||
const std::string &turn_lane_data_filename,
|
||||
@@ -182,7 +188,15 @@ class EdgeBasedGraphFactory
|
||||
const std::string &turn_penalties_index_filename,
|
||||
const bool generate_edge_lookup);
|
||||
|
||||
void InsertEdgeBasedNode(const NodeID u, const NodeID v);
|
||||
// Mapping betweenn the node based graph u,v nodes and the edge based graph head,tail edge ids.
|
||||
// Required in the osrm-partition tool to translate from a nbg partition to a ebg partition.
|
||||
struct Mapping
|
||||
{
|
||||
NodeID u, v;
|
||||
EdgeID head, tail;
|
||||
};
|
||||
|
||||
boost::optional<Mapping> InsertEdgeBasedNode(const NodeID u, const NodeID v);
|
||||
|
||||
void FlushVectorToStream(std::ofstream &edge_data_file,
|
||||
std::vector<OriginalEdgeData> &original_edge_data_vector) const;
|
||||
|
||||
@@ -78,6 +78,7 @@ struct ExtractorConfig
|
||||
profile_properties_output_path = basepath + ".osrm.properties";
|
||||
intersection_class_data_output_path = basepath + ".osrm.icd";
|
||||
compressed_node_based_graph_output_path = basepath + ".osrm.cnbg";
|
||||
nbg_ebg_graph_mapping_output_path = basepath + ".osrm.nbg_to_ebg";
|
||||
}
|
||||
|
||||
boost::filesystem::path input_path;
|
||||
@@ -110,8 +111,10 @@ struct ExtractorConfig
|
||||
|
||||
bool use_metadata;
|
||||
|
||||
// Auxiliary data for osrm-partition
|
||||
bool dump_compressed_node_based_graph;
|
||||
std::string compressed_node_based_graph_output_path;
|
||||
std::string nbg_ebg_graph_mapping_output_path;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
#ifndef NODE_BASED_GRAPH_TO_EDGE_BASED_GRAPH_MAPPING_WRITER_HPP
|
||||
#define NODE_BASED_GRAPH_TO_EDGE_BASED_GRAPH_MAPPING_WRITER_HPP
|
||||
|
||||
#include "storage/io.hpp"
|
||||
#include "util/log.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace extractor
|
||||
{
|
||||
|
||||
// Writes: | Fingerprint | #mappings | u v fwd_node bkw_node | u v fwd_node bkw_node | ..
|
||||
// - uint64: number of mappings (u, v, fwd_node bkw_node) chunks
|
||||
// - NodeID u, NodeID v, EdgeID fwd_node, EdgeID bkw_node
|
||||
|
||||
struct NodeBasedGraphToEdgeBasedGraphMappingWriter
|
||||
{
|
||||
NodeBasedGraphToEdgeBasedGraphMappingWriter(const std::string &path)
|
||||
: writer{path, storage::io::FileWriter::GenerateFingerprint}, num_written{0}
|
||||
{
|
||||
const std::uint64_t dummy{0}; // filled in later
|
||||
writer.WriteElementCount64(dummy);
|
||||
}
|
||||
|
||||
void WriteMapping(NodeID u, NodeID v, EdgeID fwd_ebg_node, EdgeID bkw_ebg_node)
|
||||
{
|
||||
BOOST_ASSERT(u != SPECIAL_NODEID);
|
||||
BOOST_ASSERT(v != SPECIAL_NODEID);
|
||||
BOOST_ASSERT(fwd_ebg_node != SPECIAL_EDGEID || bkw_ebg_node != SPECIAL_EDGEID);
|
||||
|
||||
writer.WriteOne(u);
|
||||
writer.WriteOne(v);
|
||||
writer.WriteOne(fwd_ebg_node);
|
||||
writer.WriteOne(bkw_ebg_node);
|
||||
|
||||
num_written += 1;
|
||||
}
|
||||
|
||||
~NodeBasedGraphToEdgeBasedGraphMappingWriter()
|
||||
{
|
||||
if (num_written != 0)
|
||||
{
|
||||
writer.SkipToBeginning();
|
||||
writer.WriteOne(num_written);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
storage::io::FileWriter writer;
|
||||
std::uint64_t num_written;
|
||||
};
|
||||
|
||||
} // ns extractor
|
||||
} // ns osrm
|
||||
|
||||
#endif // NODE_BASED_GRAPH_TO_EDGE_BASED_GRAPH_MAPPING_WRITER_HPP
|
||||
Reference in New Issue
Block a user