Remove all boundary nodes and use simple u-v-stragtegy to pick id
This commit removes all occurences of unconnected boundary nodes and switches to the simple heuristic of picking U for the forward and V for the backward node. This performs better than several fancy heuristics.
This commit is contained in:
committed by
Patrick Niklaus
parent
bf6698f4cc
commit
57c6c6e51c
@@ -10,10 +10,12 @@
|
||||
#include "extractor/guidance/turn_analysis.hpp"
|
||||
#include "extractor/guidance/turn_instruction.hpp"
|
||||
#include "extractor/guidance/turn_lane_types.hpp"
|
||||
#include "extractor/nbg_to_ebg.hpp"
|
||||
#include "extractor/original_edge_data.hpp"
|
||||
#include "extractor/profile_properties.hpp"
|
||||
#include "extractor/query_node.hpp"
|
||||
#include "extractor/restriction_map.hpp"
|
||||
|
||||
#include "util/deallocating_vector.hpp"
|
||||
#include "util/guidance/bearing_class.hpp"
|
||||
#include "util/guidance/entry_class.hpp"
|
||||
@@ -35,7 +37,6 @@
|
||||
#include <vector>
|
||||
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
@@ -144,7 +145,7 @@ class EdgeBasedGraphFactory
|
||||
|
||||
unsigned RenumberEdges();
|
||||
|
||||
void GenerateEdgeExpandedNodes(const std::string &nbg_ebg_mapping_path);
|
||||
std::vector<NBGToEBG> GenerateEdgeExpandedNodes();
|
||||
|
||||
void GenerateEdgeExpandedEdges(ScriptingEnvironment &scripting_environment,
|
||||
const std::string &original_edge_data_filename,
|
||||
@@ -153,15 +154,7 @@ class EdgeBasedGraphFactory
|
||||
const std::string &turn_duration_penalties_filename,
|
||||
const std::string &turn_penalties_index_filename);
|
||||
|
||||
// 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);
|
||||
NBGToEBG InsertEdgeBasedNode(const NodeID u, const NodeID v);
|
||||
|
||||
void FlushVectorToStream(storage::io::FileWriter &edge_data_file,
|
||||
std::vector<OriginalEdgeData> &original_edge_data_vector) const;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define OSRM_EXTRACTOR_IO_HPP
|
||||
|
||||
#include "extractor/datasources.hpp"
|
||||
#include "extractor/nbg_to_ebg.hpp"
|
||||
#include "extractor/segment_data_container.hpp"
|
||||
|
||||
#include "storage/io.hpp"
|
||||
@@ -15,7 +16,23 @@ namespace extractor
|
||||
namespace io
|
||||
{
|
||||
|
||||
void read(const boost::filesystem::path &path, Datasources &sources)
|
||||
inline void read(const boost::filesystem::path &path, std::vector<NBGToEBG> &mapping)
|
||||
{
|
||||
const auto fingerprint = storage::io::FileReader::VerifyFingerprint;
|
||||
storage::io::FileReader reader{path, fingerprint};
|
||||
|
||||
reader.DeserializeVector(mapping);
|
||||
}
|
||||
|
||||
inline void write(const boost::filesystem::path &path, const std::vector<NBGToEBG> &mapping)
|
||||
{
|
||||
const auto fingerprint = storage::io::FileWriter::GenerateFingerprint;
|
||||
storage::io::FileWriter reader{path, fingerprint};
|
||||
|
||||
reader.SerializeVector(mapping);
|
||||
}
|
||||
|
||||
inline void read(const boost::filesystem::path &path, Datasources &sources)
|
||||
{
|
||||
const auto fingerprint = storage::io::FileReader::HasNoFingerprint;
|
||||
storage::io::FileReader reader{path, fingerprint};
|
||||
@@ -23,7 +40,7 @@ void read(const boost::filesystem::path &path, Datasources &sources)
|
||||
reader.ReadInto(sources);
|
||||
}
|
||||
|
||||
void write(const boost::filesystem::path &path, Datasources &sources)
|
||||
inline void write(const boost::filesystem::path &path, Datasources &sources)
|
||||
{
|
||||
const auto fingerprint = storage::io::FileWriter::HasNoFingerprint;
|
||||
storage::io::FileWriter writer{path, fingerprint};
|
||||
@@ -31,7 +48,8 @@ void write(const boost::filesystem::path &path, Datasources &sources)
|
||||
writer.WriteFrom(sources);
|
||||
}
|
||||
|
||||
template <> void read(const boost::filesystem::path &path, SegmentDataContainer &segment_data)
|
||||
template <>
|
||||
inline void read(const boost::filesystem::path &path, SegmentDataContainer &segment_data)
|
||||
{
|
||||
const auto fingerprint = storage::io::FileReader::HasNoFingerprint;
|
||||
storage::io::FileReader reader{path, fingerprint};
|
||||
@@ -57,7 +75,7 @@ template <> void read(const boost::filesystem::path &path, SegmentDataContainer
|
||||
}
|
||||
|
||||
template <>
|
||||
void write(const boost::filesystem::path &path, const SegmentDataContainer &segment_data)
|
||||
inline void write(const boost::filesystem::path &path, const SegmentDataContainer &segment_data)
|
||||
{
|
||||
const auto fingerprint = storage::io::FileWriter::HasNoFingerprint;
|
||||
storage::io::FileWriter writer{path, fingerprint};
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef OSRM_EXTRACTOR_NBG_TO_EBG_HPP
|
||||
#define OSRM_EXTRACTOR_NBG_TO_EBG_HPP
|
||||
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace extractor
|
||||
{
|
||||
|
||||
// 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 NBGToEBG
|
||||
{
|
||||
NodeID u, v;
|
||||
NodeID forward_ebg_node, backward_ebg_node;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,63 +0,0 @@
|
||||
#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