Fix routing when start and target are on the same segment

Fixes issue #1864. Given the simple set-up:

a --> b --> c
^-----------|

This would translate into an edge based graph (ab) -> (bc),
(bc) -> (ca), (ca) -> (ab).

Starting at the end of the one-way street (ab) and going to
the beginning, the query has to find a self-loop within the
graph (ab) -> (bc) -> (ca) -> (ab), as both nodes map to the
same segment (ab).
This commit is contained in:
Moritz Kobitzsch
2016-01-07 10:33:47 +01:00
committed by Patrick Niklaus
parent 238e77d959
commit 1c1bfd7541
22 changed files with 744 additions and 287 deletions
@@ -62,10 +62,11 @@ class EdgeBasedGraphFactory
const bool generate_edge_lookup);
#endif
//The following get access functions destroy the content in the factory
void GetEdgeBasedEdges(util::DeallocatingVector<EdgeBasedEdge> &edges);
void GetEdgeBasedNodes(std::vector<EdgeBasedNode> &nodes);
void GetStartPointMarkers(std::vector<bool> &node_is_startpoint);
void GetEdgeBasedNodeWeights(std::vector<EdgeWeight> &output_node_weights);
unsigned GetHighestEdgeID();
@@ -80,6 +81,11 @@ class EdgeBasedGraphFactory
//! maps index from m_edge_based_node_list to ture/false if the node is an entry point to the
//! graph
std::vector<bool> m_edge_based_node_is_startpoint;
//! node weights that indicate the length of the segment (node based) represented by the
//! edge-based node
std::vector<EdgeWeight> m_edge_based_node_weights;
//! list of edge based nodes (compressed segments)
std::vector<EdgeBasedNode> m_edge_based_node_list;
util::DeallocatingVector<EdgeBasedEdge> m_edge_based_edge_list;
+8 -4
View File
@@ -6,24 +6,28 @@
#include "extractor/edge_based_graph_factory.hpp"
#include "extractor/graph_compressor.hpp"
#include "util/typedefs.hpp"
namespace osrm
{
namespace extractor
{
class extractor
class Extractor
{
public:
extractor(ExtractorConfig extractor_config) : config(std::move(extractor_config)) {}
Extractor(ExtractorConfig extractor_config) : config(std::move(extractor_config)) {}
int run();
private:
ExtractorConfig config;
void SetupScriptingEnvironment(lua_State *myLuaState, SpeedProfileProperties &speed_profile);
std::pair<std::size_t, std::size_t>
BuildEdgeExpandedGraph(std::vector<QueryNode> &internal_to_external_node_map,
std::vector<EdgeBasedNode> &node_based_edge_list,
std::vector<bool> &node_is_startpoint,
std::vector<EdgeWeight> &edge_based_node_weights,
util::DeallocatingVector<EdgeBasedEdge> &edge_based_edge_list);
void WriteNodeMapping(const std::vector<QueryNode> &internal_to_external_node_map);
void FindComponents(unsigned max_edge_id,
@@ -38,8 +42,8 @@ class extractor
std::unordered_set<NodeID> &traffic_lights,
std::vector<QueryNode> &internal_to_external_node_map);
void WriteEdgeBasedGraph(std::string const &output_file_filename,
size_t const max_edge_id,
void WriteEdgeBasedGraph(const std::string &output_file_filename,
const size_t max_edge_id,
util::DeallocatingVector<EdgeBasedEdge> const &edge_based_edge_list);
};
}
+5
View File
@@ -35,6 +35,11 @@ struct ExtractorConfig
std::string rtree_nodes_output_path;
std::string rtree_leafs_output_path;
// every edge based node represents a segment in the original graph. During contraciton we need
// to know about this segment length, as we might have to add self-loops in cases of shorter
// parts than the segment represents itself
std::string edge_based_node_weights_output_path;
unsigned requested_num_threads;
unsigned small_component_size;