Add ability to debug routing graph visually by dumping

annotated GeoJSON during processing.
This commit is contained in:
Daniel Patterson
2015-10-14 15:08:22 -07:00
parent 673bf356e4
commit b9a4c322a7
15 changed files with 341 additions and 41 deletions
+45 -7
View File
@@ -35,6 +35,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../util/timing_util.hpp"
#include "../util/osrm_exception.hpp"
#include "../util/debug_geometry.hpp"
#include <boost/assert.hpp>
#include <fstream>
@@ -222,12 +224,20 @@ void EdgeBasedGraphFactory::FlushVectorToStream(
original_edge_data_vector.clear();
}
#ifdef DEBUG_GEOMETRY
void EdgeBasedGraphFactory::Run(const std::string &original_edge_data_filename,
lua_State *lua_state,
const std::string &edge_segment_lookup_filename,
const std::string &edge_penalty_filename,
const bool generate_edge_lookup
)
const bool generate_edge_lookup,
const std::string &debug_turns_path)
#else
void EdgeBasedGraphFactory::Run(const std::string &original_edge_data_filename,
lua_State *lua_state,
const std::string &edge_segment_lookup_filename,
const std::string &edge_penalty_filename,
const bool generate_edge_lookup)
#endif
{
TIMER_START(renumber);
m_max_edge_id = RenumberEdges() - 1;
@@ -238,9 +248,16 @@ void EdgeBasedGraphFactory::Run(const std::string &original_edge_data_filename,
TIMER_STOP(generate_nodes);
TIMER_START(generate_edges);
#ifdef DEBUG_GEOMETRY
GenerateEdgeExpandedEdges(original_edge_data_filename, lua_state,
edge_segment_lookup_filename,edge_penalty_filename, generate_edge_lookup
);
edge_segment_lookup_filename,edge_penalty_filename,
generate_edge_lookup, debug_turns_path);
#else
GenerateEdgeExpandedEdges(original_edge_data_filename, lua_state,
edge_segment_lookup_filename,edge_penalty_filename,
generate_edge_lookup);
#endif
TIMER_STOP(generate_edges);
SimpleLogger().Write() << "Timing statistics for edge-expanded graph:";
@@ -324,12 +341,20 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedNodes()
}
/// Actually it also generates OriginalEdgeData and serializes them...
#ifdef DEBUG_GEOMETRY
void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
const std::string &original_edge_data_filename, lua_State *lua_state,
const std::string &edge_segment_lookup_filename,
const std::string &edge_fixed_penalties_filename,
const bool generate_edge_lookup
)
const bool generate_edge_lookup,
const std::string &debug_turns_path)
#else
void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
const std::string &original_edge_data_filename, lua_State *lua_state,
const std::string &edge_segment_lookup_filename,
const std::string &edge_fixed_penalties_filename,
const bool generate_edge_lookup)
#endif
{
SimpleLogger().Write() << "generating edge-expanded edges";
@@ -362,9 +387,13 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
Percent progress(m_node_based_graph->GetNumberOfNodes());
#ifdef DEBUG_GEOMETRY
DEBUG_TURNS_START(debug_turns_path);
#endif
for (const auto node_u : osrm::irange(0u, m_node_based_graph->GetNumberOfNodes()))
{
progress.printStatus(node_u);
//progress.printStatus(node_u);
for (const EdgeID e1 : m_node_based_graph->GetAdjacentEdgeRange(node_u))
{
if (m_node_based_graph->GetEdgeData(e1).reversed)
@@ -435,6 +464,8 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
if (m_traffic_lights.find(node_v) != m_traffic_lights.end())
{
distance += speed_profile.traffic_signal_penalty;
DEBUG_SIGNAL(node_v, m_node_info_list, speed_profile.traffic_signal_penalty);
}
// unpack last node of first segment if packed
@@ -457,8 +488,12 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
if (turn_instruction == TurnInstruction::UTurn)
{
distance += speed_profile.u_turn_penalty;
DEBUG_UTURN(node_v, m_node_info_list, speed_profile.u_turn_penalty);
}
DEBUG_TURN(node_v, m_node_info_list, first_coordinate, turn_angle, turn_penalty);
distance += turn_penalty;
const bool edge_is_compressed = m_compressed_edge_container.HasEntryForID(e1);
@@ -541,6 +576,9 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
}
}
}
DEBUG_TURNS_STOP();
FlushVectorToStream(edge_data_file, original_edge_data_vector);
edge_data_file.seekp(std::ios::beg);
+22 -4
View File
@@ -50,6 +50,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <unordered_set>
#include <vector>
#include <boost/filesystem/fstream.hpp>
struct lua_State;
class EdgeBasedGraphFactory
@@ -66,12 +68,20 @@ class EdgeBasedGraphFactory
const std::vector<QueryNode> &node_info_list,
SpeedProfileProperties speed_profile);
#ifdef DEBUG_GEOMETRY
void Run(const std::string &original_edge_data_filename,
lua_State *lua_state,
const std::string &edge_segment_lookup_filename,
const std::string &edge_penalty_filename,
const bool generate_edge_lookup
);
const bool generate_edge_lookup,
const std::string &debug_turns_path);
#else
void Run(const std::string &original_edge_data_filename,
lua_State *lua_state,
const std::string &edge_segment_lookup_filename,
const std::string &edge_penalty_filename,
const bool generate_edge_lookup);
#endif
void GetEdgeBasedEdges(DeallocatingVector<EdgeBasedEdge> &edges);
@@ -103,12 +113,20 @@ class EdgeBasedGraphFactory
void CompressGeometry();
unsigned RenumberEdges();
void GenerateEdgeExpandedNodes();
#ifdef DEBUG_GEOMETRY
void GenerateEdgeExpandedEdges(const std::string &original_edge_data_filename,
lua_State *lua_state,
const std::string &edge_segment_lookup_filename,
const std::string &edge_fixed_penalties_filename,
const bool generate_edge_lookup
);
const bool generate_edge_lookup,
const std::string &debug_turns_path);
#else
void GenerateEdgeExpandedEdges(const std::string &original_edge_data_filename,
lua_State *lua_state,
const std::string &edge_segment_lookup_filename,
const std::string &edge_fixed_penalties_filename,
const bool generate_edge_lookup);
#endif
void InsertEdgeBasedNode(const NodeID u, const NodeID v);
+3 -5
View File
@@ -536,6 +536,9 @@ extractor::BuildEdgeExpandedGraph(std::vector<QueryNode> &internal_to_external_n
config.edge_segment_lookup_path,
config.edge_penalty_path,
config.generate_edge_lookup
#ifdef DEBUG_GEOMETRY
, config.debug_turns_path
#endif
);
lua_close(lua_state);
@@ -543,11 +546,6 @@ extractor::BuildEdgeExpandedGraph(std::vector<QueryNode> &internal_to_external_n
edge_based_graph_factory.GetEdgeBasedNodes(node_based_edge_list);
auto max_edge_id = edge_based_graph_factory.GetHighestEdgeID();
// danpat TODO: somewhere right around here, we will need to
// use the internal_to_external_node_map (which contains original OSM node ids)
// the edges from the compressed edge container
// and the edge-based-edges
const std::size_t number_of_node_based_nodes = node_based_graph->GetNumberOfNodes();
return std::make_pair(number_of_node_based_nodes, max_edge_id);
}
+6
View File
@@ -66,6 +66,12 @@ ExtractorOptions::ParseArguments(int argc, char *argv[], ExtractorConfig &extrac
&extractor_config.generate_edge_lookup)->implicit_value(true)->default_value(false),
"Generate a lookup table for internal edge-expanded-edge IDs to OSM node pairs");
#ifdef DEBUG_GEOMETRY
config_options.add_options()("debug-turns",
boost::program_options::value<std::string>(&extractor_config.debug_turns_path),
"Write out GeoJSON with turn penalty data");
#endif // DEBUG_GEOMETRY
// hidden options, will be allowed both on command line and in config file, but will not be
// shown to the user
boost::program_options::options_description hidden_options("Hidden options");
+3
View File
@@ -62,6 +62,9 @@ struct ExtractorConfig
bool generate_edge_lookup;
std::string edge_penalty_path;
std::string edge_segment_lookup_path;
#ifdef DEBUG_GEOMETRY
std::string debug_turns_path;
#endif
};
struct ExtractorOptions