Refactor logging, improve error handling workflow, clang-format. (#3385)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#include "extractor/compressed_edge_container.hpp"
|
||||
#include "util/simple_logger.hpp"
|
||||
#include "util/log.hpp"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
@@ -300,14 +300,13 @@ void CompressedEdgeContainer::PrintStatistics() const
|
||||
longest_chain_length = std::max(longest_chain_length, (uint64_t)current_vector.size());
|
||||
}
|
||||
|
||||
util::SimpleLogger().Write()
|
||||
<< "Geometry successfully removed:"
|
||||
"\n compressed edges: "
|
||||
<< compressed_edges << "\n compressed geometries: " << compressed_geometries
|
||||
<< "\n longest chain length: " << longest_chain_length << "\n cmpr ratio: "
|
||||
<< ((float)compressed_edges / std::max(compressed_geometries, (uint64_t)1))
|
||||
<< "\n avg chain length: "
|
||||
<< (float)compressed_geometries / std::max((uint64_t)1, compressed_edges);
|
||||
util::Log() << "Geometry successfully removed:"
|
||||
"\n compressed edges: "
|
||||
<< compressed_edges << "\n compressed geometries: " << compressed_geometries
|
||||
<< "\n longest chain length: " << longest_chain_length << "\n cmpr ratio: "
|
||||
<< ((float)compressed_edges / std::max(compressed_geometries, (uint64_t)1))
|
||||
<< "\n avg chain length: "
|
||||
<< (float)compressed_geometries / std::max((uint64_t)1, compressed_edges);
|
||||
}
|
||||
|
||||
const CompressedEdgeContainer::OnewayEdgeBucket &
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
#include "util/exception.hpp"
|
||||
#include "util/guidance/turn_bearing.hpp"
|
||||
#include "util/integer_range.hpp"
|
||||
#include "util/log.hpp"
|
||||
#include "util/percent.hpp"
|
||||
#include "util/simple_logger.hpp"
|
||||
#include "util/timing_util.hpp"
|
||||
|
||||
#include "extractor/guidance/toolkit.hpp"
|
||||
@@ -213,10 +213,10 @@ void EdgeBasedGraphFactory::Run(ScriptingEnvironment &scripting_environment,
|
||||
|
||||
TIMER_STOP(generate_edges);
|
||||
|
||||
util::SimpleLogger().Write() << "Timing statistics for edge-expanded graph:";
|
||||
util::SimpleLogger().Write() << "Renumbering edges: " << TIMER_SEC(renumber) << "s";
|
||||
util::SimpleLogger().Write() << "Generating nodes: " << TIMER_SEC(generate_nodes) << "s";
|
||||
util::SimpleLogger().Write() << "Generating edges: " << TIMER_SEC(generate_edges) << "s";
|
||||
util::Log() << "Timing statistics for edge-expanded graph:";
|
||||
util::Log() << "Renumbering edges: " << TIMER_SEC(renumber) << "s";
|
||||
util::Log() << "Generating nodes: " << TIMER_SEC(generate_nodes) << "s";
|
||||
util::Log() << "Generating edges: " << TIMER_SEC(generate_edges) << "s";
|
||||
}
|
||||
|
||||
/// Renumbers all _forward_ edges and sets the edge_id.
|
||||
@@ -258,40 +258,44 @@ unsigned EdgeBasedGraphFactory::RenumberEdges()
|
||||
/// Creates the nodes in the edge expanded graph from edges in the node-based graph.
|
||||
void EdgeBasedGraphFactory::GenerateEdgeExpandedNodes()
|
||||
{
|
||||
util::Percent progress(m_node_based_graph->GetNumberOfNodes());
|
||||
|
||||
m_compressed_edge_container.InitializeBothwayVector();
|
||||
|
||||
// loop over all edges and generate new set of nodes
|
||||
for (const auto node_u : util::irange(0u, m_node_based_graph->GetNumberOfNodes()))
|
||||
util::Log() << "Generating edge expanded nodes ... ";
|
||||
{
|
||||
BOOST_ASSERT(node_u != SPECIAL_NODEID);
|
||||
BOOST_ASSERT(node_u < m_node_based_graph->GetNumberOfNodes());
|
||||
progress.PrintStatus(node_u);
|
||||
for (EdgeID e1 : m_node_based_graph->GetAdjacentEdgeRange(node_u))
|
||||
util::UnbufferedLog log;
|
||||
util::Percent progress(log, m_node_based_graph->GetNumberOfNodes());
|
||||
|
||||
m_compressed_edge_container.InitializeBothwayVector();
|
||||
|
||||
// loop over all edges and generate new set of nodes
|
||||
for (const auto node_u : util::irange(0u, m_node_based_graph->GetNumberOfNodes()))
|
||||
{
|
||||
const EdgeData &edge_data = m_node_based_graph->GetEdgeData(e1);
|
||||
BOOST_ASSERT(e1 != SPECIAL_EDGEID);
|
||||
const NodeID node_v = m_node_based_graph->GetTarget(e1);
|
||||
|
||||
BOOST_ASSERT(SPECIAL_NODEID != node_v);
|
||||
// pick only every other edge, since we have every edge as an outgoing
|
||||
// and incoming egde
|
||||
if (node_u > node_v)
|
||||
BOOST_ASSERT(node_u != SPECIAL_NODEID);
|
||||
BOOST_ASSERT(node_u < m_node_based_graph->GetNumberOfNodes());
|
||||
progress.PrintStatus(node_u);
|
||||
for (EdgeID e1 : m_node_based_graph->GetAdjacentEdgeRange(node_u))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
const EdgeData &edge_data = m_node_based_graph->GetEdgeData(e1);
|
||||
BOOST_ASSERT(e1 != SPECIAL_EDGEID);
|
||||
const NodeID node_v = m_node_based_graph->GetTarget(e1);
|
||||
|
||||
BOOST_ASSERT(node_u < node_v);
|
||||
BOOST_ASSERT(SPECIAL_NODEID != node_v);
|
||||
// pick only every other edge, since we have every edge as an outgoing
|
||||
// and incoming egde
|
||||
if (node_u > node_v)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// if we found a non-forward edge reverse and try again
|
||||
if (edge_data.edge_id == SPECIAL_NODEID)
|
||||
{
|
||||
InsertEdgeBasedNode(node_v, node_u);
|
||||
}
|
||||
else
|
||||
{
|
||||
InsertEdgeBasedNode(node_u, node_v);
|
||||
BOOST_ASSERT(node_u < node_v);
|
||||
|
||||
// if we found a non-forward edge reverse and try again
|
||||
if (edge_data.edge_id == SPECIAL_NODEID)
|
||||
{
|
||||
InsertEdgeBasedNode(node_v, node_u);
|
||||
}
|
||||
else
|
||||
{
|
||||
InsertEdgeBasedNode(node_u, node_v);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -299,8 +303,7 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedNodes()
|
||||
BOOST_ASSERT(m_edge_based_node_list.size() == m_edge_based_node_is_startpoint.size());
|
||||
BOOST_ASSERT(m_max_edge_id + 1 == m_edge_based_node_weights.size());
|
||||
|
||||
util::SimpleLogger().Write() << "Generated " << m_edge_based_node_list.size()
|
||||
<< " nodes in edge-expanded graph";
|
||||
util::Log() << "Generated " << m_edge_based_node_list.size() << " nodes in edge-expanded graph";
|
||||
}
|
||||
|
||||
/// Actually it also generates OriginalEdgeData and serializes them...
|
||||
@@ -312,7 +315,7 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
|
||||
const std::string &edge_fixed_penalties_filename,
|
||||
const bool generate_edge_lookup)
|
||||
{
|
||||
util::SimpleLogger().Write() << "generating edge-expanded edges";
|
||||
util::Log() << "Generating edge-expanded edges ";
|
||||
|
||||
std::size_t node_based_edge_counter = 0;
|
||||
std::size_t original_edges_counter = 0;
|
||||
@@ -341,7 +344,6 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
|
||||
// Loop over all turns and generate new set of edges.
|
||||
// Three nested loop look super-linear, but we are dealing with a (kind of)
|
||||
// linear number of turns only.
|
||||
util::Percent progress(m_node_based_graph->GetNumberOfNodes());
|
||||
SuffixTable street_name_suffix_table(scripting_environment);
|
||||
guidance::TurnAnalysis turn_analysis(*m_node_based_graph,
|
||||
m_node_info_list,
|
||||
@@ -363,260 +365,275 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
|
||||
bearing_class_by_node_based_node.resize(m_node_based_graph->GetNumberOfNodes(),
|
||||
std::numeric_limits<std::uint32_t>::max());
|
||||
|
||||
// going over all nodes (which form the center of an intersection), we compute all
|
||||
// possible turns along these intersections.
|
||||
for (const auto node_at_center_of_intersection :
|
||||
util::irange(0u, m_node_based_graph->GetNumberOfNodes()))
|
||||
{
|
||||
progress.PrintStatus(node_at_center_of_intersection);
|
||||
util::UnbufferedLog log;
|
||||
|
||||
const auto shape_result =
|
||||
turn_analysis.ComputeIntersectionShapes(node_at_center_of_intersection);
|
||||
|
||||
// all nodes in the graph are connected in both directions. We check all outgoing nodes to
|
||||
// find the incoming edge. This is a larger search overhead, but the cost we need to pay to
|
||||
// generate edges here is worth the additional search overhead.
|
||||
//
|
||||
// a -> b <-> c
|
||||
// |
|
||||
// v
|
||||
// d
|
||||
//
|
||||
// will have:
|
||||
// a: b,rev=0
|
||||
// b: a,rev=1 c,rev=0 d,rev=0
|
||||
// c: b,rev=0
|
||||
//
|
||||
// From the flags alone, we cannot determine which nodes are connected to `b` by an outgoing
|
||||
// edge. Therefore, we have to search all connected edges for edges entering `b`
|
||||
for (const EdgeID outgoing_edge :
|
||||
m_node_based_graph->GetAdjacentEdgeRange(node_at_center_of_intersection))
|
||||
util::Percent progress(log, m_node_based_graph->GetNumberOfNodes());
|
||||
// going over all nodes (which form the center of an intersection), we compute all
|
||||
// possible turns along these intersections.
|
||||
for (const auto node_at_center_of_intersection :
|
||||
util::irange(0u, m_node_based_graph->GetNumberOfNodes()))
|
||||
{
|
||||
const NodeID node_along_road_entering = m_node_based_graph->GetTarget(outgoing_edge);
|
||||
progress.PrintStatus(node_at_center_of_intersection);
|
||||
|
||||
const auto incoming_edge = m_node_based_graph->FindEdge(node_along_road_entering,
|
||||
node_at_center_of_intersection);
|
||||
const auto shape_result =
|
||||
turn_analysis.ComputeIntersectionShapes(node_at_center_of_intersection);
|
||||
|
||||
if (m_node_based_graph->GetEdgeData(incoming_edge).reversed)
|
||||
continue;
|
||||
|
||||
++node_based_edge_counter;
|
||||
|
||||
auto intersection_with_flags_and_angles =
|
||||
turn_analysis.GetIntersectionGenerator().TransformIntersectionShapeIntoView(
|
||||
node_along_road_entering,
|
||||
incoming_edge,
|
||||
shape_result.normalised_intersection_shape,
|
||||
shape_result.intersection_shape,
|
||||
shape_result.merging_map);
|
||||
|
||||
auto intersection = turn_analysis.AssignTurnTypes(
|
||||
node_along_road_entering, incoming_edge, intersection_with_flags_and_angles);
|
||||
|
||||
BOOST_ASSERT(intersection.valid());
|
||||
|
||||
intersection = turn_lane_handler.assignTurnLanes(
|
||||
node_along_road_entering, incoming_edge, std::move(intersection));
|
||||
|
||||
// the entry class depends on the turn, so we have to classify the interesction for
|
||||
// every edge
|
||||
const auto turn_classification = classifyIntersection(intersection);
|
||||
|
||||
const auto entry_class_id = [&](const util::guidance::EntryClass entry_class) {
|
||||
if (0 == entry_class_hash.count(entry_class))
|
||||
{
|
||||
const auto id = static_cast<std::uint16_t>(entry_class_hash.size());
|
||||
entry_class_hash[entry_class] = id;
|
||||
return id;
|
||||
}
|
||||
else
|
||||
{
|
||||
return entry_class_hash.find(entry_class)->second;
|
||||
}
|
||||
}(turn_classification.first);
|
||||
|
||||
const auto bearing_class_id = [&](const util::guidance::BearingClass bearing_class) {
|
||||
if (0 == bearing_class_hash.count(bearing_class))
|
||||
{
|
||||
const auto id = static_cast<std::uint32_t>(bearing_class_hash.size());
|
||||
bearing_class_hash[bearing_class] = id;
|
||||
return id;
|
||||
}
|
||||
else
|
||||
{
|
||||
return bearing_class_hash.find(bearing_class)->second;
|
||||
}
|
||||
}(turn_classification.second);
|
||||
bearing_class_by_node_based_node[node_at_center_of_intersection] = bearing_class_id;
|
||||
|
||||
for (const auto &turn : intersection)
|
||||
// all nodes in the graph are connected in both directions. We check all outgoing nodes
|
||||
// to
|
||||
// find the incoming edge. This is a larger search overhead, but the cost we need to pay
|
||||
// to
|
||||
// generate edges here is worth the additional search overhead.
|
||||
//
|
||||
// a -> b <-> c
|
||||
// |
|
||||
// v
|
||||
// d
|
||||
//
|
||||
// will have:
|
||||
// a: b,rev=0
|
||||
// b: a,rev=1 c,rev=0 d,rev=0
|
||||
// c: b,rev=0
|
||||
//
|
||||
// From the flags alone, we cannot determine which nodes are connected to `b` by an
|
||||
// outgoing
|
||||
// edge. Therefore, we have to search all connected edges for edges entering `b`
|
||||
for (const EdgeID outgoing_edge :
|
||||
m_node_based_graph->GetAdjacentEdgeRange(node_at_center_of_intersection))
|
||||
{
|
||||
// only keep valid turns
|
||||
if (!turn.entry_allowed)
|
||||
const NodeID node_along_road_entering =
|
||||
m_node_based_graph->GetTarget(outgoing_edge);
|
||||
|
||||
const auto incoming_edge = m_node_based_graph->FindEdge(
|
||||
node_along_road_entering, node_at_center_of_intersection);
|
||||
|
||||
if (m_node_based_graph->GetEdgeData(incoming_edge).reversed)
|
||||
continue;
|
||||
|
||||
// only add an edge if turn is not prohibited
|
||||
const EdgeData &edge_data1 = m_node_based_graph->GetEdgeData(incoming_edge);
|
||||
const EdgeData &edge_data2 = m_node_based_graph->GetEdgeData(turn.eid);
|
||||
++node_based_edge_counter;
|
||||
|
||||
BOOST_ASSERT(edge_data1.edge_id != edge_data2.edge_id);
|
||||
BOOST_ASSERT(!edge_data1.reversed);
|
||||
BOOST_ASSERT(!edge_data2.reversed);
|
||||
auto intersection_with_flags_and_angles =
|
||||
turn_analysis.GetIntersectionGenerator().TransformIntersectionShapeIntoView(
|
||||
node_along_road_entering,
|
||||
incoming_edge,
|
||||
shape_result.normalised_intersection_shape,
|
||||
shape_result.intersection_shape,
|
||||
shape_result.merging_map);
|
||||
|
||||
// the following is the core of the loop.
|
||||
unsigned distance = edge_data1.distance;
|
||||
if (m_traffic_lights.find(node_at_center_of_intersection) != m_traffic_lights.end())
|
||||
{
|
||||
distance += profile_properties.traffic_signal_penalty;
|
||||
}
|
||||
auto intersection = turn_analysis.AssignTurnTypes(
|
||||
node_along_road_entering, incoming_edge, intersection_with_flags_and_angles);
|
||||
|
||||
const int32_t turn_penalty =
|
||||
scripting_environment.GetTurnPenalty(180. - turn.angle);
|
||||
BOOST_ASSERT(intersection.valid());
|
||||
|
||||
const auto turn_instruction = turn.instruction;
|
||||
if (turn_instruction.direction_modifier == guidance::DirectionModifier::UTurn)
|
||||
{
|
||||
distance += profile_properties.u_turn_penalty;
|
||||
}
|
||||
intersection = turn_lane_handler.assignTurnLanes(
|
||||
node_along_road_entering, incoming_edge, std::move(intersection));
|
||||
|
||||
// don't add turn penalty if it is not an actual turn. This heuristic is necessary
|
||||
// since OSRM cannot handle looping roads/parallel roads
|
||||
if (turn_instruction.type != guidance::TurnType::NoTurn)
|
||||
distance += turn_penalty;
|
||||
// the entry class depends on the turn, so we have to classify the interesction for
|
||||
// every edge
|
||||
const auto turn_classification = classifyIntersection(intersection);
|
||||
|
||||
const bool is_encoded_forwards =
|
||||
m_compressed_edge_container.HasZippedEntryForForwardID(incoming_edge);
|
||||
const bool is_encoded_backwards =
|
||||
m_compressed_edge_container.HasZippedEntryForReverseID(incoming_edge);
|
||||
BOOST_ASSERT(is_encoded_forwards || is_encoded_backwards);
|
||||
if (is_encoded_forwards)
|
||||
{
|
||||
original_edge_data_vector.emplace_back(
|
||||
GeometryID{m_compressed_edge_container.GetZippedPositionForForwardID(
|
||||
incoming_edge),
|
||||
true},
|
||||
edge_data1.name_id,
|
||||
turn.lane_data_id,
|
||||
turn_instruction,
|
||||
entry_class_id,
|
||||
edge_data1.travel_mode,
|
||||
util::guidance::TurnBearing(intersection[0].bearing),
|
||||
util::guidance::TurnBearing(turn.bearing));
|
||||
}
|
||||
else if (is_encoded_backwards)
|
||||
{
|
||||
original_edge_data_vector.emplace_back(
|
||||
GeometryID{m_compressed_edge_container.GetZippedPositionForReverseID(
|
||||
incoming_edge),
|
||||
false},
|
||||
edge_data1.name_id,
|
||||
turn.lane_data_id,
|
||||
turn_instruction,
|
||||
entry_class_id,
|
||||
edge_data1.travel_mode,
|
||||
util::guidance::TurnBearing(intersection[0].bearing),
|
||||
util::guidance::TurnBearing(turn.bearing));
|
||||
}
|
||||
|
||||
++original_edges_counter;
|
||||
|
||||
if (original_edge_data_vector.size() > 1024 * 1024 * 10)
|
||||
{
|
||||
FlushVectorToStream(edge_data_file, original_edge_data_vector);
|
||||
}
|
||||
|
||||
BOOST_ASSERT(SPECIAL_NODEID != edge_data1.edge_id);
|
||||
BOOST_ASSERT(SPECIAL_NODEID != edge_data2.edge_id);
|
||||
|
||||
// NOTE: potential overflow here if we hit 2^32 routable edges
|
||||
BOOST_ASSERT(m_edge_based_edge_list.size() <= std::numeric_limits<NodeID>::max());
|
||||
m_edge_based_edge_list.emplace_back(edge_data1.edge_id,
|
||||
edge_data2.edge_id,
|
||||
m_edge_based_edge_list.size(),
|
||||
distance,
|
||||
true,
|
||||
false);
|
||||
BOOST_ASSERT(original_edges_counter == m_edge_based_edge_list.size());
|
||||
|
||||
// Here is where we write out the mapping between the edge-expanded edges, and
|
||||
// the node-based edges that are originally used to calculate the `distance`
|
||||
// for the edge-expanded edges. About 40 lines back, there is:
|
||||
//
|
||||
// unsigned distance = edge_data1.distance;
|
||||
//
|
||||
// This tells us that the weight for an edge-expanded-edge is based on the weight
|
||||
// of the *source* node-based edge. Therefore, we will look up the individual
|
||||
// segments of the source node-based edge, and write out a mapping between
|
||||
// those and the edge-based-edge ID.
|
||||
// External programs can then use this mapping to quickly perform
|
||||
// updates to the edge-expanded-edge based directly on its ID.
|
||||
if (generate_edge_lookup)
|
||||
{
|
||||
const auto node_based_edges =
|
||||
m_compressed_edge_container.GetBucketReference(incoming_edge);
|
||||
NodeID previous = node_along_road_entering;
|
||||
|
||||
const unsigned node_count = node_based_edges.size() + 1;
|
||||
const QueryNode &first_node = m_node_info_list[previous];
|
||||
|
||||
lookup::SegmentHeaderBlock header = {node_count, first_node.node_id};
|
||||
|
||||
edge_segment_file.write(reinterpret_cast<const char *>(&header),
|
||||
sizeof(header));
|
||||
|
||||
for (auto target_node : node_based_edges)
|
||||
const auto entry_class_id = [&](const util::guidance::EntryClass entry_class) {
|
||||
if (0 == entry_class_hash.count(entry_class))
|
||||
{
|
||||
const QueryNode &from = m_node_info_list[previous];
|
||||
const QueryNode &to = m_node_info_list[target_node.node_id];
|
||||
const double segment_length =
|
||||
util::coordinate_calculation::greatCircleDistance(from, to);
|
||||
const auto id = static_cast<std::uint16_t>(entry_class_hash.size());
|
||||
entry_class_hash[entry_class] = id;
|
||||
return id;
|
||||
}
|
||||
else
|
||||
{
|
||||
return entry_class_hash.find(entry_class)->second;
|
||||
}
|
||||
}(turn_classification.first);
|
||||
|
||||
lookup::SegmentBlock nodeblock = {
|
||||
to.node_id, segment_length, target_node.weight};
|
||||
const auto bearing_class_id =
|
||||
[&](const util::guidance::BearingClass bearing_class) {
|
||||
if (0 == bearing_class_hash.count(bearing_class))
|
||||
{
|
||||
const auto id = static_cast<std::uint32_t>(bearing_class_hash.size());
|
||||
bearing_class_hash[bearing_class] = id;
|
||||
return id;
|
||||
}
|
||||
else
|
||||
{
|
||||
return bearing_class_hash.find(bearing_class)->second;
|
||||
}
|
||||
}(turn_classification.second);
|
||||
bearing_class_by_node_based_node[node_at_center_of_intersection] = bearing_class_id;
|
||||
|
||||
edge_segment_file.write(reinterpret_cast<const char *>(&nodeblock),
|
||||
sizeof(nodeblock));
|
||||
previous = target_node.node_id;
|
||||
for (const auto &turn : intersection)
|
||||
{
|
||||
// only keep valid turns
|
||||
if (!turn.entry_allowed)
|
||||
continue;
|
||||
|
||||
// only add an edge if turn is not prohibited
|
||||
const EdgeData &edge_data1 = m_node_based_graph->GetEdgeData(incoming_edge);
|
||||
const EdgeData &edge_data2 = m_node_based_graph->GetEdgeData(turn.eid);
|
||||
|
||||
BOOST_ASSERT(edge_data1.edge_id != edge_data2.edge_id);
|
||||
BOOST_ASSERT(!edge_data1.reversed);
|
||||
BOOST_ASSERT(!edge_data2.reversed);
|
||||
|
||||
// the following is the core of the loop.
|
||||
unsigned distance = edge_data1.distance;
|
||||
if (m_traffic_lights.find(node_at_center_of_intersection) !=
|
||||
m_traffic_lights.end())
|
||||
{
|
||||
distance += profile_properties.traffic_signal_penalty;
|
||||
}
|
||||
|
||||
// We also now write out the mapping between the edge-expanded edges and the
|
||||
// original nodes. Since each edge represents a possible maneuver, external
|
||||
// programs can use this to quickly perform updates to edge weights in order
|
||||
// to penalize certain turns.
|
||||
const int32_t turn_penalty =
|
||||
scripting_environment.GetTurnPenalty(180. - turn.angle);
|
||||
|
||||
// If this edge is 'trivial' -- where the compressed edge corresponds
|
||||
// exactly to an original OSM segment -- we can pull the turn's preceding
|
||||
// node ID directly with `node_along_road_entering`; otherwise, we need to look
|
||||
// up the node
|
||||
// immediately preceding the turn from the compressed edge container.
|
||||
const bool isTrivial = m_compressed_edge_container.IsTrivial(incoming_edge);
|
||||
const auto turn_instruction = turn.instruction;
|
||||
if (turn_instruction.direction_modifier == guidance::DirectionModifier::UTurn)
|
||||
{
|
||||
distance += profile_properties.u_turn_penalty;
|
||||
}
|
||||
|
||||
const auto &from_node =
|
||||
isTrivial
|
||||
? m_node_info_list[node_along_road_entering]
|
||||
: m_node_info_list[m_compressed_edge_container.GetLastEdgeSourceID(
|
||||
incoming_edge)];
|
||||
const auto &via_node =
|
||||
m_node_info_list[m_compressed_edge_container.GetLastEdgeTargetID(
|
||||
incoming_edge)];
|
||||
const auto &to_node =
|
||||
m_node_info_list[m_compressed_edge_container.GetFirstEdgeTargetID(
|
||||
turn.eid)];
|
||||
// don't add turn penalty if it is not an actual turn. This heuristic is
|
||||
// necessary
|
||||
// since OSRM cannot handle looping roads/parallel roads
|
||||
if (turn_instruction.type != guidance::TurnType::NoTurn)
|
||||
distance += turn_penalty;
|
||||
|
||||
const unsigned fixed_penalty = distance - edge_data1.distance;
|
||||
lookup::PenaltyBlock penaltyblock = {
|
||||
fixed_penalty, from_node.node_id, via_node.node_id, to_node.node_id};
|
||||
edge_penalty_file.write(reinterpret_cast<const char *>(&penaltyblock),
|
||||
sizeof(penaltyblock));
|
||||
const bool is_encoded_forwards =
|
||||
m_compressed_edge_container.HasZippedEntryForForwardID(incoming_edge);
|
||||
const bool is_encoded_backwards =
|
||||
m_compressed_edge_container.HasZippedEntryForReverseID(incoming_edge);
|
||||
BOOST_ASSERT(is_encoded_forwards || is_encoded_backwards);
|
||||
if (is_encoded_forwards)
|
||||
{
|
||||
original_edge_data_vector.emplace_back(
|
||||
GeometryID{m_compressed_edge_container.GetZippedPositionForForwardID(
|
||||
incoming_edge),
|
||||
true},
|
||||
edge_data1.name_id,
|
||||
turn.lane_data_id,
|
||||
turn_instruction,
|
||||
entry_class_id,
|
||||
edge_data1.travel_mode,
|
||||
util::guidance::TurnBearing(intersection[0].bearing),
|
||||
util::guidance::TurnBearing(turn.bearing));
|
||||
}
|
||||
else if (is_encoded_backwards)
|
||||
{
|
||||
original_edge_data_vector.emplace_back(
|
||||
GeometryID{m_compressed_edge_container.GetZippedPositionForReverseID(
|
||||
incoming_edge),
|
||||
false},
|
||||
edge_data1.name_id,
|
||||
turn.lane_data_id,
|
||||
turn_instruction,
|
||||
entry_class_id,
|
||||
edge_data1.travel_mode,
|
||||
util::guidance::TurnBearing(intersection[0].bearing),
|
||||
util::guidance::TurnBearing(turn.bearing));
|
||||
}
|
||||
|
||||
++original_edges_counter;
|
||||
|
||||
if (original_edge_data_vector.size() > 1024 * 1024 * 10)
|
||||
{
|
||||
FlushVectorToStream(edge_data_file, original_edge_data_vector);
|
||||
}
|
||||
|
||||
BOOST_ASSERT(SPECIAL_NODEID != edge_data1.edge_id);
|
||||
BOOST_ASSERT(SPECIAL_NODEID != edge_data2.edge_id);
|
||||
|
||||
// NOTE: potential overflow here if we hit 2^32 routable edges
|
||||
BOOST_ASSERT(m_edge_based_edge_list.size() <=
|
||||
std::numeric_limits<NodeID>::max());
|
||||
m_edge_based_edge_list.emplace_back(edge_data1.edge_id,
|
||||
edge_data2.edge_id,
|
||||
m_edge_based_edge_list.size(),
|
||||
distance,
|
||||
true,
|
||||
false);
|
||||
BOOST_ASSERT(original_edges_counter == m_edge_based_edge_list.size());
|
||||
|
||||
// Here is where we write out the mapping between the edge-expanded edges, and
|
||||
// the node-based edges that are originally used to calculate the `distance`
|
||||
// for the edge-expanded edges. About 40 lines back, there is:
|
||||
//
|
||||
// unsigned distance = edge_data1.distance;
|
||||
//
|
||||
// This tells us that the weight for an edge-expanded-edge is based on the
|
||||
// weight
|
||||
// of the *source* node-based edge. Therefore, we will look up the individual
|
||||
// segments of the source node-based edge, and write out a mapping between
|
||||
// those and the edge-based-edge ID.
|
||||
// External programs can then use this mapping to quickly perform
|
||||
// updates to the edge-expanded-edge based directly on its ID.
|
||||
if (generate_edge_lookup)
|
||||
{
|
||||
const auto node_based_edges =
|
||||
m_compressed_edge_container.GetBucketReference(incoming_edge);
|
||||
NodeID previous = node_along_road_entering;
|
||||
|
||||
const unsigned node_count = node_based_edges.size() + 1;
|
||||
const QueryNode &first_node = m_node_info_list[previous];
|
||||
|
||||
lookup::SegmentHeaderBlock header = {node_count, first_node.node_id};
|
||||
|
||||
edge_segment_file.write(reinterpret_cast<const char *>(&header),
|
||||
sizeof(header));
|
||||
|
||||
for (auto target_node : node_based_edges)
|
||||
{
|
||||
const QueryNode &from = m_node_info_list[previous];
|
||||
const QueryNode &to = m_node_info_list[target_node.node_id];
|
||||
const double segment_length =
|
||||
util::coordinate_calculation::greatCircleDistance(from, to);
|
||||
|
||||
lookup::SegmentBlock nodeblock = {
|
||||
to.node_id, segment_length, target_node.weight};
|
||||
|
||||
edge_segment_file.write(reinterpret_cast<const char *>(&nodeblock),
|
||||
sizeof(nodeblock));
|
||||
previous = target_node.node_id;
|
||||
}
|
||||
|
||||
// We also now write out the mapping between the edge-expanded edges and the
|
||||
// original nodes. Since each edge represents a possible maneuver, external
|
||||
// programs can use this to quickly perform updates to edge weights in order
|
||||
// to penalize certain turns.
|
||||
|
||||
// If this edge is 'trivial' -- where the compressed edge corresponds
|
||||
// exactly to an original OSM segment -- we can pull the turn's preceding
|
||||
// node ID directly with `node_along_road_entering`; otherwise, we need to
|
||||
// look
|
||||
// up the node
|
||||
// immediately preceding the turn from the compressed edge container.
|
||||
const bool isTrivial = m_compressed_edge_container.IsTrivial(incoming_edge);
|
||||
|
||||
const auto &from_node =
|
||||
isTrivial
|
||||
? m_node_info_list[node_along_road_entering]
|
||||
: m_node_info_list[m_compressed_edge_container.GetLastEdgeSourceID(
|
||||
incoming_edge)];
|
||||
const auto &via_node =
|
||||
m_node_info_list[m_compressed_edge_container.GetLastEdgeTargetID(
|
||||
incoming_edge)];
|
||||
const auto &to_node =
|
||||
m_node_info_list[m_compressed_edge_container.GetFirstEdgeTargetID(
|
||||
turn.eid)];
|
||||
|
||||
const unsigned fixed_penalty = distance - edge_data1.distance;
|
||||
lookup::PenaltyBlock penaltyblock = {
|
||||
fixed_penalty, from_node.node_id, via_node.node_id, to_node.node_id};
|
||||
edge_penalty_file.write(reinterpret_cast<const char *>(&penaltyblock),
|
||||
sizeof(penaltyblock));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
util::SimpleLogger().Write() << "Created " << entry_class_hash.size() << " entry classes and "
|
||||
<< bearing_class_hash.size() << " Bearing Classes";
|
||||
util::Log() << "Created " << entry_class_hash.size() << " entry classes and "
|
||||
<< bearing_class_hash.size() << " Bearing Classes";
|
||||
|
||||
util::SimpleLogger().Write() << "Writing Turn Lane Data to File...";
|
||||
util::Log() << "Writing Turn Lane Data to File...";
|
||||
std::ofstream turn_lane_data_file(turn_lane_data_filename.c_str(), std::ios::binary);
|
||||
std::vector<util::guidance::LaneTupleIdPair> lane_data(lane_data_map.size());
|
||||
// extract lane data sorted by ID
|
||||
@@ -630,7 +647,7 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
|
||||
turn_lane_data_file.write(reinterpret_cast<const char *>(&lane_data[0]),
|
||||
sizeof(util::guidance::LaneTupleIdPair) * lane_data.size());
|
||||
|
||||
util::SimpleLogger().Write() << "done.";
|
||||
util::Log() << "done.";
|
||||
|
||||
FlushVectorToStream(edge_data_file, original_edge_data_vector);
|
||||
|
||||
@@ -642,18 +659,15 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
|
||||
|
||||
edge_data_file.write(reinterpret_cast<const char *>(&length_prefix), sizeof(length_prefix));
|
||||
|
||||
util::SimpleLogger().Write() << "Generated " << m_edge_based_node_list.size()
|
||||
<< " edge based nodes";
|
||||
util::SimpleLogger().Write() << "Node-based graph contains " << node_based_edge_counter
|
||||
<< " edges";
|
||||
util::SimpleLogger().Write() << "Edge-expanded graph ...";
|
||||
util::SimpleLogger().Write() << " contains " << m_edge_based_edge_list.size() << " edges";
|
||||
util::SimpleLogger().Write() << " skips " << restricted_turns_counter << " turns, "
|
||||
"defined by "
|
||||
<< m_restriction_map->size() << " restrictions";
|
||||
util::SimpleLogger().Write() << " skips " << skipped_uturns_counter << " U turns";
|
||||
util::SimpleLogger().Write() << " skips " << skipped_barrier_turns_counter
|
||||
<< " turns over barriers";
|
||||
util::Log() << "Generated " << m_edge_based_node_list.size() << " edge based nodes";
|
||||
util::Log() << "Node-based graph contains " << node_based_edge_counter << " edges";
|
||||
util::Log() << "Edge-expanded graph ...";
|
||||
util::Log() << " contains " << m_edge_based_edge_list.size() << " edges";
|
||||
util::Log() << " skips " << restricted_turns_counter << " turns, "
|
||||
"defined by "
|
||||
<< m_restriction_map->size() << " restrictions";
|
||||
util::Log() << " skips " << skipped_uturns_counter << " U turns";
|
||||
util::Log() << " skips " << skipped_barrier_turns_counter << " turns over barriers";
|
||||
}
|
||||
|
||||
std::vector<util::guidance::BearingClass> EdgeBasedGraphFactory::GetBearingClasses() const
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+53
-59
@@ -11,11 +11,13 @@
|
||||
#include "extractor/raster_source.hpp"
|
||||
#include "storage/io.hpp"
|
||||
#include "storage/io.hpp"
|
||||
#include "util/exception.hpp"
|
||||
#include "util/exception_utils.hpp"
|
||||
#include "util/graph_loader.hpp"
|
||||
#include "util/io.hpp"
|
||||
#include "util/log.hpp"
|
||||
#include "util/name_table.hpp"
|
||||
#include "util/range_table.hpp"
|
||||
#include "util/simple_logger.hpp"
|
||||
#include "util/timing_util.hpp"
|
||||
|
||||
#include "extractor/compressed_edge_container.hpp"
|
||||
@@ -119,12 +121,12 @@ int Extractor::run(ScriptingEnvironment &scripting_environment)
|
||||
tbb::task_scheduler_init init(number_of_threads);
|
||||
|
||||
{
|
||||
util::SimpleLogger().Write() << "Input file: " << config.input_path.filename().string();
|
||||
util::Log() << "Input file: " << config.input_path.filename().string();
|
||||
if (!config.profile_path.empty())
|
||||
{
|
||||
util::SimpleLogger().Write() << "Profile: " << config.profile_path.filename().string();
|
||||
util::Log() << "Profile: " << config.profile_path.filename().string();
|
||||
}
|
||||
util::SimpleLogger().Write() << "Threads: " << number_of_threads;
|
||||
util::Log() << "Threads: " << number_of_threads;
|
||||
|
||||
ExtractionContainers extraction_containers;
|
||||
auto extractor_callbacks = std::make_unique<ExtractorCallbacks>(extraction_containers);
|
||||
@@ -137,7 +139,7 @@ int Extractor::run(ScriptingEnvironment &scripting_environment)
|
||||
unsigned number_of_ways = 0;
|
||||
unsigned number_of_relations = 0;
|
||||
|
||||
util::SimpleLogger().Write() << "Parsing in progress..";
|
||||
util::Log() << "Parsing in progress..";
|
||||
TIMER_START(parsing);
|
||||
|
||||
// setup raster sources
|
||||
@@ -148,7 +150,7 @@ int Extractor::run(ScriptingEnvironment &scripting_environment)
|
||||
{
|
||||
generator = "unknown tool";
|
||||
}
|
||||
util::SimpleLogger().Write() << "input file generated by " << generator;
|
||||
util::Log() << "input file generated by " << generator;
|
||||
|
||||
// write .timestamp data file
|
||||
std::string timestamp = header.get("osmosis_replication_timestamp");
|
||||
@@ -156,7 +158,7 @@ int Extractor::run(ScriptingEnvironment &scripting_environment)
|
||||
{
|
||||
timestamp = "n/a";
|
||||
}
|
||||
util::SimpleLogger().Write() << "timestamp: " << timestamp;
|
||||
util::Log() << "timestamp: " << timestamp;
|
||||
|
||||
boost::filesystem::ofstream timestamp_out(config.timestamp_file_name);
|
||||
timestamp_out.write(timestamp.c_str(), timestamp.length());
|
||||
@@ -210,12 +212,10 @@ int Extractor::run(ScriptingEnvironment &scripting_environment)
|
||||
}
|
||||
}
|
||||
TIMER_STOP(parsing);
|
||||
util::SimpleLogger().Write() << "Parsing finished after " << TIMER_SEC(parsing)
|
||||
<< " seconds";
|
||||
util::Log() << "Parsing finished after " << TIMER_SEC(parsing) << " seconds";
|
||||
|
||||
util::SimpleLogger().Write() << "Raw input contains " << number_of_nodes << " nodes, "
|
||||
<< number_of_ways << " ways, and " << number_of_relations
|
||||
<< " relations";
|
||||
util::Log() << "Raw input contains " << number_of_nodes << " nodes, " << number_of_ways
|
||||
<< " ways, and " << number_of_relations << " relations";
|
||||
|
||||
// take control over the turn lane map
|
||||
turn_lane_map = extractor_callbacks->moveOutLaneDescriptionMap();
|
||||
@@ -224,8 +224,8 @@ int Extractor::run(ScriptingEnvironment &scripting_environment)
|
||||
|
||||
if (extraction_containers.all_edges_list.empty())
|
||||
{
|
||||
util::SimpleLogger().Write(logWARNING) << "The input data is empty, exiting.";
|
||||
return 1;
|
||||
throw util::exception(std::string("There are no edges remaining after parsing.") +
|
||||
SOURCE_REF);
|
||||
}
|
||||
|
||||
extraction_containers.PrepareData(scripting_environment,
|
||||
@@ -237,15 +237,14 @@ int Extractor::run(ScriptingEnvironment &scripting_environment)
|
||||
scripting_environment.GetProfileProperties());
|
||||
|
||||
TIMER_STOP(extracting);
|
||||
util::SimpleLogger().Write() << "extraction finished after " << TIMER_SEC(extracting)
|
||||
<< "s";
|
||||
util::Log() << "extraction finished after " << TIMER_SEC(extracting) << "s";
|
||||
}
|
||||
|
||||
{
|
||||
// Transform the node-based graph that OSM is based on into an edge-based graph
|
||||
// that is better for routing. Every edge becomes a node, and every valid
|
||||
// movement (e.g. turn from A->B, and B->A) becomes an edge
|
||||
util::SimpleLogger().Write() << "Generating edge-expanded graph representation";
|
||||
util::Log() << "Generating edge-expanded graph representation";
|
||||
|
||||
TIMER_START(expansion);
|
||||
|
||||
@@ -267,17 +266,16 @@ int Extractor::run(ScriptingEnvironment &scripting_environment)
|
||||
|
||||
TIMER_STOP(expansion);
|
||||
|
||||
util::SimpleLogger().Write() << "Saving edge-based node weights to file.";
|
||||
util::Log() << "Saving edge-based node weights to file.";
|
||||
TIMER_START(timer_write_node_weights);
|
||||
util::serializeVector(config.edge_based_node_weights_output_path, edge_based_node_weights);
|
||||
TIMER_STOP(timer_write_node_weights);
|
||||
util::SimpleLogger().Write() << "Done writing. (" << TIMER_SEC(timer_write_node_weights)
|
||||
<< ")";
|
||||
util::Log() << "Done writing. (" << TIMER_SEC(timer_write_node_weights) << ")";
|
||||
|
||||
util::SimpleLogger().Write() << "Computing strictly connected components ...";
|
||||
util::Log() << "Computing strictly connected components ...";
|
||||
FindComponents(max_edge_id, edge_based_edge_list, edge_based_node_list);
|
||||
|
||||
util::SimpleLogger().Write() << "Building r-tree ...";
|
||||
util::Log() << "Building r-tree ...";
|
||||
TIMER_START(rtree);
|
||||
BuildRTree(std::move(edge_based_node_list),
|
||||
std::move(node_is_startpoint),
|
||||
@@ -285,7 +283,7 @@ int Extractor::run(ScriptingEnvironment &scripting_environment)
|
||||
|
||||
TIMER_STOP(rtree);
|
||||
|
||||
util::SimpleLogger().Write() << "Writing node map ...";
|
||||
util::Log() << "Writing node map ...";
|
||||
WriteNodeMapping(internal_to_external_node_map);
|
||||
|
||||
WriteEdgeBasedGraph(config.edge_graph_output_path, max_edge_id, edge_based_edge_list);
|
||||
@@ -295,10 +293,10 @@ int Extractor::run(ScriptingEnvironment &scripting_environment)
|
||||
const auto edges_per_second =
|
||||
static_cast<std::uint64_t>((max_edge_id + 1) / TIMER_SEC(expansion));
|
||||
|
||||
util::SimpleLogger().Write() << "Expansion: " << nodes_per_second << " nodes/sec and "
|
||||
<< edges_per_second << " edges/sec";
|
||||
util::SimpleLogger().Write() << "To prepare the data for routing, run: "
|
||||
<< "./osrm-contract " << config.output_file_name << std::endl;
|
||||
util::Log() << "Expansion: " << nodes_per_second << " nodes/sec and " << edges_per_second
|
||||
<< " edges/sec";
|
||||
util::Log() << "To prepare the data for routing, run: "
|
||||
<< "./osrm-contract " << config.output_file_name;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -310,7 +308,7 @@ void Extractor::WriteProfileProperties(const std::string &output_path,
|
||||
boost::filesystem::ofstream out_stream(output_path);
|
||||
if (!out_stream)
|
||||
{
|
||||
throw util::exception("Could not open " + output_path + " for writing.");
|
||||
throw util::exception("Could not open " + output_path + " for writing." + SOURCE_REF);
|
||||
}
|
||||
|
||||
out_stream.write(reinterpret_cast<const char *>(&properties), sizeof(properties));
|
||||
@@ -406,7 +404,7 @@ std::shared_ptr<RestrictionMap> Extractor::LoadRestrictionMap()
|
||||
|
||||
util::loadRestrictionsFromFile(file_reader, restriction_list);
|
||||
|
||||
util::SimpleLogger().Write() << " - " << restriction_list.size() << " restrictions.";
|
||||
util::Log() << " - " << restriction_list.size() << " restrictions.";
|
||||
|
||||
return std::make_shared<RestrictionMap>(restriction_list);
|
||||
}
|
||||
@@ -428,16 +426,16 @@ Extractor::LoadNodeBasedGraph(std::unordered_set<NodeID> &barriers,
|
||||
NodeID number_of_node_based_nodes = util::loadNodesFromFile(
|
||||
file_reader, barriers_iter, traffic_signals_iter, internal_to_external_node_map);
|
||||
|
||||
util::SimpleLogger().Write() << " - " << barriers.size() << " bollard nodes, "
|
||||
<< traffic_signals.size() << " traffic lights";
|
||||
util::Log() << " - " << barriers.size() << " bollard nodes, " << traffic_signals.size()
|
||||
<< " traffic lights";
|
||||
|
||||
std::vector<NodeBasedEdge> edge_list;
|
||||
util::loadEdgesFromFile(file_reader, edge_list);
|
||||
|
||||
if (edge_list.empty())
|
||||
{
|
||||
util::SimpleLogger().Write(logWARNING) << "The input data is empty, exiting.";
|
||||
return std::shared_ptr<util::NodeBasedDynamicGraph>();
|
||||
throw util::exception("Node-based-graph (" + config.output_file_name +
|
||||
") contains no edges." + SOURCE_REF);
|
||||
}
|
||||
|
||||
return util::NodeBasedDynamicGraphFromEdges(number_of_node_based_nodes, edge_list);
|
||||
@@ -541,9 +539,9 @@ void Extractor::BuildRTree(std::vector<EdgeBasedNode> node_based_edge_list,
|
||||
std::vector<bool> node_is_startpoint,
|
||||
const std::vector<QueryNode> &internal_to_external_node_map)
|
||||
{
|
||||
util::SimpleLogger().Write() << "constructing r-tree of " << node_based_edge_list.size()
|
||||
<< " edge elements build on-top of "
|
||||
<< internal_to_external_node_map.size() << " coordinates";
|
||||
util::Log() << "constructing r-tree of " << node_based_edge_list.size()
|
||||
<< " edge elements build on-top of " << internal_to_external_node_map.size()
|
||||
<< " coordinates";
|
||||
|
||||
BOOST_ASSERT(node_is_startpoint.size() == node_based_edge_list.size());
|
||||
|
||||
@@ -564,7 +562,8 @@ void Extractor::BuildRTree(std::vector<EdgeBasedNode> node_based_edge_list,
|
||||
if (new_size == 0)
|
||||
{
|
||||
throw util::exception("There are no snappable edges left after processing. Are you "
|
||||
"setting travel modes correctly in the profile? Cannot continue.");
|
||||
"setting travel modes correctly in the profile? Cannot continue." +
|
||||
SOURCE_REF);
|
||||
}
|
||||
node_based_edge_list.resize(new_size);
|
||||
|
||||
@@ -575,8 +574,7 @@ void Extractor::BuildRTree(std::vector<EdgeBasedNode> node_based_edge_list,
|
||||
internal_to_external_node_map);
|
||||
|
||||
TIMER_STOP(construction);
|
||||
util::SimpleLogger().Write() << "finished r-tree construction in " << TIMER_SEC(construction)
|
||||
<< " seconds";
|
||||
util::Log() << "finished r-tree construction in " << TIMER_SEC(construction) << " seconds";
|
||||
}
|
||||
|
||||
void Extractor::WriteEdgeBasedGraph(
|
||||
@@ -590,8 +588,7 @@ void Extractor::WriteEdgeBasedGraph(
|
||||
const util::FingerPrint fingerprint = util::FingerPrint::GetValid();
|
||||
file_out_stream.write((char *)&fingerprint, sizeof(util::FingerPrint));
|
||||
|
||||
util::SimpleLogger().Write() << "[extractor] Writing edge-based-graph edges ... "
|
||||
<< std::flush;
|
||||
util::Log() << "Writing edge-based-graph edges ... " << std::flush;
|
||||
TIMER_START(write_edges);
|
||||
|
||||
std::uint64_t number_of_used_edges = edge_based_edge_list.size();
|
||||
@@ -604,9 +601,9 @@ void Extractor::WriteEdgeBasedGraph(
|
||||
}
|
||||
|
||||
TIMER_STOP(write_edges);
|
||||
util::SimpleLogger().Write() << "ok, after " << TIMER_SEC(write_edges) << "s" << std::endl;
|
||||
util::Log() << "ok, after " << TIMER_SEC(write_edges) << "s";
|
||||
|
||||
util::SimpleLogger().Write() << "Processed " << number_of_used_edges << " edges";
|
||||
util::Log() << "Processed " << number_of_used_edges << " edges";
|
||||
}
|
||||
|
||||
void Extractor::WriteIntersectionClassificationData(
|
||||
@@ -618,12 +615,11 @@ void Extractor::WriteIntersectionClassificationData(
|
||||
std::ofstream file_out_stream(output_file_name.c_str(), std::ios::binary);
|
||||
if (!file_out_stream)
|
||||
{
|
||||
util::SimpleLogger().Write(logWARNING) << "Failed to open " << output_file_name
|
||||
<< " for writing";
|
||||
util::Log(logERROR) << "Failed to open " << output_file_name << " for writing";
|
||||
return;
|
||||
}
|
||||
|
||||
util::SimpleLogger().Write() << "Writing Intersection Classification Data";
|
||||
util::Log() << "Writing Intersection Classification Data";
|
||||
TIMER_START(write_edges);
|
||||
util::writeFingerprint(file_out_stream);
|
||||
util::serializeVector(file_out_stream, node_based_intersection_classes);
|
||||
@@ -652,16 +648,15 @@ void Extractor::WriteIntersectionClassificationData(
|
||||
|
||||
if (!static_cast<bool>(file_out_stream))
|
||||
{
|
||||
throw util::exception("Failed to write to " + output_file_name + ".");
|
||||
throw util::exception("Failed to write to " + output_file_name + "." + SOURCE_REF);
|
||||
}
|
||||
|
||||
util::serializeVector(file_out_stream, entry_classes);
|
||||
TIMER_STOP(write_edges);
|
||||
util::SimpleLogger().Write() << "ok, after " << TIMER_SEC(write_edges) << "s for "
|
||||
<< node_based_intersection_classes.size() << " Indices into "
|
||||
<< bearing_classes.size() << " bearing classes and "
|
||||
<< entry_classes.size() << " entry classes and " << total_bearings
|
||||
<< " bearing values." << std::endl;
|
||||
util::Log() << "ok, after " << TIMER_SEC(write_edges) << "s for "
|
||||
<< node_based_intersection_classes.size() << " Indices into "
|
||||
<< bearing_classes.size() << " bearing classes and " << entry_classes.size()
|
||||
<< " entry classes and " << total_bearings << " bearing values.";
|
||||
}
|
||||
|
||||
void Extractor::WriteTurnLaneData(const std::string &turn_lane_file) const
|
||||
@@ -671,27 +666,26 @@ void Extractor::WriteTurnLaneData(const std::string &turn_lane_file) const
|
||||
std::vector<guidance::TurnLaneType::Mask> turn_lane_masks;
|
||||
std::tie(turn_lane_offsets, turn_lane_masks) = transformTurnLaneMapIntoArrays(turn_lane_map);
|
||||
|
||||
util::SimpleLogger().Write() << "Writing turn lane masks...";
|
||||
util::Log() << "Writing turn lane masks...";
|
||||
TIMER_START(turn_lane_timer);
|
||||
|
||||
std::ofstream ofs(turn_lane_file, std::ios::binary);
|
||||
if (!ofs)
|
||||
throw osrm::util::exception("Failed to open " + turn_lane_file + " for writing.");
|
||||
throw osrm::util::exception("Failed to open " + turn_lane_file + " for writing." +
|
||||
SOURCE_REF);
|
||||
|
||||
if (!util::serializeVector(ofs, turn_lane_offsets))
|
||||
{
|
||||
util::SimpleLogger().Write(logWARNING) << "Error while writing.";
|
||||
return;
|
||||
throw util::exception("Error while writing to " + turn_lane_file + SOURCE_REF);
|
||||
}
|
||||
|
||||
if (!util::serializeVector(ofs, turn_lane_masks))
|
||||
{
|
||||
util::SimpleLogger().Write(logWARNING) << "Error while writing.";
|
||||
return;
|
||||
throw util::exception("Error while writing to " + turn_lane_file + SOURCE_REF);
|
||||
}
|
||||
|
||||
TIMER_STOP(turn_lane_timer);
|
||||
util::SimpleLogger().Write() << "done (" << TIMER_SEC(turn_lane_timer) << ")";
|
||||
util::Log() << "done (" << TIMER_SEC(turn_lane_timer) << ")";
|
||||
}
|
||||
|
||||
} // namespace extractor
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "util/for_each_pair.hpp"
|
||||
#include "util/guidance/turn_lanes.hpp"
|
||||
#include "util/simple_logger.hpp"
|
||||
#include "util/log.hpp"
|
||||
|
||||
#include <boost/numeric/conversion/cast.hpp>
|
||||
#include <boost/optional/optional.hpp>
|
||||
@@ -62,7 +62,7 @@ void ExtractorCallbacks::ProcessRestriction(
|
||||
if (restriction)
|
||||
{
|
||||
external_memory.restrictions_list.push_back(restriction.get());
|
||||
// util::SimpleLogger().Write() << "from: " << restriction.get().restriction.from.node <<
|
||||
// util::Log() << "from: " << restriction.get().restriction.from.node <<
|
||||
// ",via: " << restriction.get().restriction.via.node <<
|
||||
// ", to: " << restriction.get().restriction.to.node <<
|
||||
// ", only: " << (restriction.get().restriction.flags.is_only ?
|
||||
@@ -96,8 +96,8 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti
|
||||
|
||||
if (std::numeric_limits<decltype(input_way.id())>::max() == input_way.id())
|
||||
{
|
||||
util::SimpleLogger().Write(logDEBUG) << "found bogus way with id: " << input_way.id()
|
||||
<< " of size " << input_way.nodes().size();
|
||||
util::Log(logDEBUG) << "found bogus way with id: " << input_way.id() << " of size "
|
||||
<< input_way.nodes().size();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -135,8 +135,7 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti
|
||||
if (forward_weight_data.type == InternalExtractorEdge::WeightType::INVALID &&
|
||||
backward_weight_data.type == InternalExtractorEdge::WeightType::INVALID)
|
||||
{
|
||||
util::SimpleLogger().Write(logDEBUG) << "found way with bogus speed, id: "
|
||||
<< input_way.id();
|
||||
util::Log(logDEBUG) << "found way with bogus speed, id: " << input_way.id();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -196,8 +195,7 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti
|
||||
if (translated_mask == TurnLaneType::empty)
|
||||
{
|
||||
// if we have unsupported tags, don't handle them
|
||||
util::SimpleLogger().Write(logDEBUG) << "Unsupported lane tag found: \""
|
||||
<< *token_itr << "\"";
|
||||
util::Log(logDEBUG) << "Unsupported lane tag found: \"" << *token_itr << "\"";
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
+166
-158
@@ -6,7 +6,7 @@
|
||||
#include "util/node_based_graph.hpp"
|
||||
#include "util/percent.hpp"
|
||||
|
||||
#include "util/simple_logger.hpp"
|
||||
#include "util/log.hpp"
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
@@ -22,175 +22,185 @@ void GraphCompressor::Compress(const std::unordered_set<NodeID> &barrier_nodes,
|
||||
const unsigned original_number_of_nodes = graph.GetNumberOfNodes();
|
||||
const unsigned original_number_of_edges = graph.GetNumberOfEdges();
|
||||
|
||||
util::Percent progress(original_number_of_nodes);
|
||||
|
||||
for (const NodeID node_v : util::irange(0u, original_number_of_nodes))
|
||||
{
|
||||
progress.PrintStatus(node_v);
|
||||
util::UnbufferedLog log;
|
||||
util::Percent progress(log, original_number_of_nodes);
|
||||
|
||||
// only contract degree 2 vertices
|
||||
if (2 != graph.GetOutDegree(node_v))
|
||||
for (const NodeID node_v : util::irange(0u, original_number_of_nodes))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
progress.PrintStatus(node_v);
|
||||
|
||||
// don't contract barrier node
|
||||
if (barrier_nodes.end() != barrier_nodes.find(node_v))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// check if v is a via node for a turn restriction, i.e. a 'directed' barrier node
|
||||
if (restriction_map.IsViaNode(node_v))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// reverse_e2 forward_e2
|
||||
// u <---------- v -----------> w
|
||||
// ----------> <-----------
|
||||
// forward_e1 reverse_e1
|
||||
//
|
||||
// Will be compressed to:
|
||||
//
|
||||
// reverse_e1
|
||||
// u <---------- w
|
||||
// ---------->
|
||||
// forward_e1
|
||||
//
|
||||
// If the edges are compatible.
|
||||
const bool reverse_edge_order = graph.GetEdgeData(graph.BeginEdges(node_v)).reversed;
|
||||
const EdgeID forward_e2 = graph.BeginEdges(node_v) + reverse_edge_order;
|
||||
BOOST_ASSERT(SPECIAL_EDGEID != forward_e2);
|
||||
BOOST_ASSERT(forward_e2 >= graph.BeginEdges(node_v) && forward_e2 < graph.EndEdges(node_v));
|
||||
const EdgeID reverse_e2 = graph.BeginEdges(node_v) + 1 - reverse_edge_order;
|
||||
BOOST_ASSERT(SPECIAL_EDGEID != reverse_e2);
|
||||
BOOST_ASSERT(reverse_e2 >= graph.BeginEdges(node_v) && reverse_e2 < graph.EndEdges(node_v));
|
||||
|
||||
const EdgeData &fwd_edge_data2 = graph.GetEdgeData(forward_e2);
|
||||
const EdgeData &rev_edge_data2 = graph.GetEdgeData(reverse_e2);
|
||||
|
||||
const NodeID node_w = graph.GetTarget(forward_e2);
|
||||
BOOST_ASSERT(SPECIAL_NODEID != node_w);
|
||||
BOOST_ASSERT(node_v != node_w);
|
||||
const NodeID node_u = graph.GetTarget(reverse_e2);
|
||||
BOOST_ASSERT(SPECIAL_NODEID != node_u);
|
||||
BOOST_ASSERT(node_u != node_v);
|
||||
|
||||
const EdgeID forward_e1 = graph.FindEdge(node_u, node_v);
|
||||
BOOST_ASSERT(SPECIAL_EDGEID != forward_e1);
|
||||
BOOST_ASSERT(node_v == graph.GetTarget(forward_e1));
|
||||
const EdgeID reverse_e1 = graph.FindEdge(node_w, node_v);
|
||||
BOOST_ASSERT(SPECIAL_EDGEID != reverse_e1);
|
||||
BOOST_ASSERT(node_v == graph.GetTarget(reverse_e1));
|
||||
|
||||
const EdgeData &fwd_edge_data1 = graph.GetEdgeData(forward_e1);
|
||||
const EdgeData &rev_edge_data1 = graph.GetEdgeData(reverse_e1);
|
||||
|
||||
if (graph.FindEdgeInEitherDirection(node_u, node_w) != SPECIAL_EDGEID)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// this case can happen if two ways with different names overlap
|
||||
if (fwd_edge_data1.name_id != rev_edge_data1.name_id ||
|
||||
fwd_edge_data2.name_id != rev_edge_data2.name_id)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (fwd_edge_data1.CanCombineWith(fwd_edge_data2) &&
|
||||
rev_edge_data1.CanCombineWith(rev_edge_data2))
|
||||
{
|
||||
BOOST_ASSERT(graph.GetEdgeData(forward_e1).name_id ==
|
||||
graph.GetEdgeData(reverse_e1).name_id);
|
||||
BOOST_ASSERT(graph.GetEdgeData(forward_e2).name_id ==
|
||||
graph.GetEdgeData(reverse_e2).name_id);
|
||||
|
||||
// Do not compress edge if it crosses a traffic signal.
|
||||
// This can't be done in CanCombineWith, becase we only store the
|
||||
// traffic signals in the `traffic_lights` list, which EdgeData
|
||||
// doesn't have access to.
|
||||
const bool has_node_penalty = traffic_lights.find(node_v) != traffic_lights.end();
|
||||
if (has_node_penalty)
|
||||
// only contract degree 2 vertices
|
||||
if (2 != graph.GetOutDegree(node_v))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get distances before graph is modified
|
||||
const int forward_weight1 = graph.GetEdgeData(forward_e1).distance;
|
||||
const int forward_weight2 = graph.GetEdgeData(forward_e2).distance;
|
||||
// don't contract barrier node
|
||||
if (barrier_nodes.end() != barrier_nodes.find(node_v))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
BOOST_ASSERT(0 != forward_weight1);
|
||||
BOOST_ASSERT(0 != forward_weight2);
|
||||
// check if v is a via node for a turn restriction, i.e. a 'directed' barrier node
|
||||
if (restriction_map.IsViaNode(node_v))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const int reverse_weight1 = graph.GetEdgeData(reverse_e1).distance;
|
||||
const int reverse_weight2 = graph.GetEdgeData(reverse_e2).distance;
|
||||
// reverse_e2 forward_e2
|
||||
// u <---------- v -----------> w
|
||||
// ----------> <-----------
|
||||
// forward_e1 reverse_e1
|
||||
//
|
||||
// Will be compressed to:
|
||||
//
|
||||
// reverse_e1
|
||||
// u <---------- w
|
||||
// ---------->
|
||||
// forward_e1
|
||||
//
|
||||
// If the edges are compatible.
|
||||
const bool reverse_edge_order = graph.GetEdgeData(graph.BeginEdges(node_v)).reversed;
|
||||
const EdgeID forward_e2 = graph.BeginEdges(node_v) + reverse_edge_order;
|
||||
BOOST_ASSERT(SPECIAL_EDGEID != forward_e2);
|
||||
BOOST_ASSERT(forward_e2 >= graph.BeginEdges(node_v) &&
|
||||
forward_e2 < graph.EndEdges(node_v));
|
||||
const EdgeID reverse_e2 = graph.BeginEdges(node_v) + 1 - reverse_edge_order;
|
||||
BOOST_ASSERT(SPECIAL_EDGEID != reverse_e2);
|
||||
BOOST_ASSERT(reverse_e2 >= graph.BeginEdges(node_v) &&
|
||||
reverse_e2 < graph.EndEdges(node_v));
|
||||
|
||||
BOOST_ASSERT(0 != reverse_weight1);
|
||||
BOOST_ASSERT(0 != reverse_weight2);
|
||||
const EdgeData &fwd_edge_data2 = graph.GetEdgeData(forward_e2);
|
||||
const EdgeData &rev_edge_data2 = graph.GetEdgeData(reverse_e2);
|
||||
|
||||
// add weight of e2's to e1
|
||||
graph.GetEdgeData(forward_e1).distance += fwd_edge_data2.distance;
|
||||
graph.GetEdgeData(reverse_e1).distance += rev_edge_data2.distance;
|
||||
const NodeID node_w = graph.GetTarget(forward_e2);
|
||||
BOOST_ASSERT(SPECIAL_NODEID != node_w);
|
||||
BOOST_ASSERT(node_v != node_w);
|
||||
const NodeID node_u = graph.GetTarget(reverse_e2);
|
||||
BOOST_ASSERT(SPECIAL_NODEID != node_u);
|
||||
BOOST_ASSERT(node_u != node_v);
|
||||
|
||||
// extend e1's to targets of e2's
|
||||
graph.SetTarget(forward_e1, node_w);
|
||||
graph.SetTarget(reverse_e1, node_u);
|
||||
const EdgeID forward_e1 = graph.FindEdge(node_u, node_v);
|
||||
BOOST_ASSERT(SPECIAL_EDGEID != forward_e1);
|
||||
BOOST_ASSERT(node_v == graph.GetTarget(forward_e1));
|
||||
const EdgeID reverse_e1 = graph.FindEdge(node_w, node_v);
|
||||
BOOST_ASSERT(SPECIAL_EDGEID != reverse_e1);
|
||||
BOOST_ASSERT(node_v == graph.GetTarget(reverse_e1));
|
||||
|
||||
/*
|
||||
* Remember Lane Data for compressed parts. This handles scenarios where lane-data is
|
||||
* only kept up until a traffic light.
|
||||
*
|
||||
* | |
|
||||
* ---------------- |
|
||||
* -^ | |
|
||||
* ----------- |
|
||||
* -v | |
|
||||
* --------------- |
|
||||
* | |
|
||||
*
|
||||
* u ------- v ---- w
|
||||
*
|
||||
* Since the edge is compressable, we can transfer:
|
||||
* "left|right" (uv) and "" (uw) into a string with "left|right" (uw) for the compressed
|
||||
* edge.
|
||||
* Doing so, we might mess up the point from where the lanes are shown. It should be
|
||||
* reasonable, since the announcements have to come early anyhow. So there is a
|
||||
* potential danger in here, but it saves us from adding a lot of additional edges for
|
||||
* turn-lanes. Without this,we would have to treat any turn-lane beginning/ending just
|
||||
* like a barrier.
|
||||
*/
|
||||
const auto selectLaneID = [](const LaneDescriptionID front,
|
||||
const LaneDescriptionID back) {
|
||||
// A lane has tags: u - (front) - v - (back) - w
|
||||
// During contraction, we keep only one of the tags. Usually the one closer to the
|
||||
// intersection is preferred. If its empty, however, we keep the non-empty one
|
||||
if (back == INVALID_LANE_DESCRIPTIONID)
|
||||
return front;
|
||||
return back;
|
||||
};
|
||||
graph.GetEdgeData(forward_e1).lane_description_id =
|
||||
selectLaneID(graph.GetEdgeData(forward_e1).lane_description_id,
|
||||
fwd_edge_data2.lane_description_id);
|
||||
graph.GetEdgeData(reverse_e1).lane_description_id =
|
||||
selectLaneID(graph.GetEdgeData(reverse_e1).lane_description_id,
|
||||
rev_edge_data2.lane_description_id);
|
||||
const EdgeData &fwd_edge_data1 = graph.GetEdgeData(forward_e1);
|
||||
const EdgeData &rev_edge_data1 = graph.GetEdgeData(reverse_e1);
|
||||
|
||||
// remove e2's (if bidir, otherwise only one)
|
||||
graph.DeleteEdge(node_v, forward_e2);
|
||||
graph.DeleteEdge(node_v, reverse_e2);
|
||||
if (graph.FindEdgeInEitherDirection(node_u, node_w) != SPECIAL_EDGEID)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// update any involved turn restrictions
|
||||
restriction_map.FixupStartingTurnRestriction(node_u, node_v, node_w);
|
||||
restriction_map.FixupArrivingTurnRestriction(node_u, node_v, node_w, graph);
|
||||
// this case can happen if two ways with different names overlap
|
||||
if (fwd_edge_data1.name_id != rev_edge_data1.name_id ||
|
||||
fwd_edge_data2.name_id != rev_edge_data2.name_id)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
restriction_map.FixupStartingTurnRestriction(node_w, node_v, node_u);
|
||||
restriction_map.FixupArrivingTurnRestriction(node_w, node_v, node_u, graph);
|
||||
if (fwd_edge_data1.CanCombineWith(fwd_edge_data2) &&
|
||||
rev_edge_data1.CanCombineWith(rev_edge_data2))
|
||||
{
|
||||
BOOST_ASSERT(graph.GetEdgeData(forward_e1).name_id ==
|
||||
graph.GetEdgeData(reverse_e1).name_id);
|
||||
BOOST_ASSERT(graph.GetEdgeData(forward_e2).name_id ==
|
||||
graph.GetEdgeData(reverse_e2).name_id);
|
||||
|
||||
// store compressed geometry in container
|
||||
geometry_compressor.CompressEdge(
|
||||
forward_e1, forward_e2, node_v, node_w, forward_weight1, forward_weight2);
|
||||
geometry_compressor.CompressEdge(
|
||||
reverse_e1, reverse_e2, node_v, node_u, reverse_weight1, reverse_weight2);
|
||||
// Do not compress edge if it crosses a traffic signal.
|
||||
// This can't be done in CanCombineWith, becase we only store the
|
||||
// traffic signals in the `traffic_lights` list, which EdgeData
|
||||
// doesn't have access to.
|
||||
const bool has_node_penalty = traffic_lights.find(node_v) != traffic_lights.end();
|
||||
if (has_node_penalty)
|
||||
continue;
|
||||
|
||||
// Get distances before graph is modified
|
||||
const int forward_weight1 = graph.GetEdgeData(forward_e1).distance;
|
||||
const int forward_weight2 = graph.GetEdgeData(forward_e2).distance;
|
||||
|
||||
BOOST_ASSERT(0 != forward_weight1);
|
||||
BOOST_ASSERT(0 != forward_weight2);
|
||||
|
||||
const int reverse_weight1 = graph.GetEdgeData(reverse_e1).distance;
|
||||
const int reverse_weight2 = graph.GetEdgeData(reverse_e2).distance;
|
||||
|
||||
BOOST_ASSERT(0 != reverse_weight1);
|
||||
BOOST_ASSERT(0 != reverse_weight2);
|
||||
|
||||
// add weight of e2's to e1
|
||||
graph.GetEdgeData(forward_e1).distance += fwd_edge_data2.distance;
|
||||
graph.GetEdgeData(reverse_e1).distance += rev_edge_data2.distance;
|
||||
|
||||
// extend e1's to targets of e2's
|
||||
graph.SetTarget(forward_e1, node_w);
|
||||
graph.SetTarget(reverse_e1, node_u);
|
||||
|
||||
/*
|
||||
* Remember Lane Data for compressed parts. This handles scenarios where lane-data
|
||||
* is
|
||||
* only kept up until a traffic light.
|
||||
*
|
||||
* | |
|
||||
* ---------------- |
|
||||
* -^ | |
|
||||
* ----------- |
|
||||
* -v | |
|
||||
* --------------- |
|
||||
* | |
|
||||
*
|
||||
* u ------- v ---- w
|
||||
*
|
||||
* Since the edge is compressable, we can transfer:
|
||||
* "left|right" (uv) and "" (uw) into a string with "left|right" (uw) for the
|
||||
* compressed
|
||||
* edge.
|
||||
* Doing so, we might mess up the point from where the lanes are shown. It should be
|
||||
* reasonable, since the announcements have to come early anyhow. So there is a
|
||||
* potential danger in here, but it saves us from adding a lot of additional edges
|
||||
* for
|
||||
* turn-lanes. Without this,we would have to treat any turn-lane beginning/ending
|
||||
* just
|
||||
* like a barrier.
|
||||
*/
|
||||
const auto selectLaneID = [](const LaneDescriptionID front,
|
||||
const LaneDescriptionID back) {
|
||||
// A lane has tags: u - (front) - v - (back) - w
|
||||
// During contraction, we keep only one of the tags. Usually the one closer to
|
||||
// the
|
||||
// intersection is preferred. If its empty, however, we keep the non-empty one
|
||||
if (back == INVALID_LANE_DESCRIPTIONID)
|
||||
return front;
|
||||
return back;
|
||||
};
|
||||
graph.GetEdgeData(forward_e1).lane_description_id =
|
||||
selectLaneID(graph.GetEdgeData(forward_e1).lane_description_id,
|
||||
fwd_edge_data2.lane_description_id);
|
||||
graph.GetEdgeData(reverse_e1).lane_description_id =
|
||||
selectLaneID(graph.GetEdgeData(reverse_e1).lane_description_id,
|
||||
rev_edge_data2.lane_description_id);
|
||||
|
||||
// remove e2's (if bidir, otherwise only one)
|
||||
graph.DeleteEdge(node_v, forward_e2);
|
||||
graph.DeleteEdge(node_v, reverse_e2);
|
||||
|
||||
// update any involved turn restrictions
|
||||
restriction_map.FixupStartingTurnRestriction(node_u, node_v, node_w);
|
||||
restriction_map.FixupArrivingTurnRestriction(node_u, node_v, node_w, graph);
|
||||
|
||||
restriction_map.FixupStartingTurnRestriction(node_w, node_v, node_u);
|
||||
restriction_map.FixupArrivingTurnRestriction(node_w, node_v, node_u, graph);
|
||||
|
||||
// store compressed geometry in container
|
||||
geometry_compressor.CompressEdge(
|
||||
forward_e1, forward_e2, node_v, node_w, forward_weight1, forward_weight2);
|
||||
geometry_compressor.CompressEdge(
|
||||
reverse_e1, reverse_e2, node_v, node_u, reverse_weight1, reverse_weight2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,10 +236,8 @@ void GraphCompressor::PrintStatistics(unsigned original_number_of_nodes,
|
||||
new_edge_count += (graph.EndEdges(i) - graph.BeginEdges(i));
|
||||
}
|
||||
}
|
||||
util::SimpleLogger().Write() << "Node compression ratio: "
|
||||
<< new_node_count / (double)original_number_of_nodes;
|
||||
util::SimpleLogger().Write() << "Edge compression ratio: "
|
||||
<< new_edge_count / (double)original_number_of_edges;
|
||||
util::Log() << "Node compression ratio: " << new_node_count / (double)original_number_of_nodes;
|
||||
util::Log() << "Edge compression ratio: " << new_edge_count / (double)original_number_of_edges;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "util/coordinate_calculation.hpp"
|
||||
#include "util/guidance/toolkit.hpp"
|
||||
#include "util/simple_logger.hpp"
|
||||
#include "util/log.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "extractor/guidance/toolkit.hpp"
|
||||
|
||||
#include "util/guidance/toolkit.hpp"
|
||||
#include "util/simple_logger.hpp"
|
||||
#include "util/log.hpp"
|
||||
|
||||
#include <limits>
|
||||
#include <utility>
|
||||
@@ -197,9 +197,9 @@ Intersection MotorwayHandler::fromMotorway(const EdgeID via_eid, Intersection in
|
||||
else if (countValid(intersection) > 0) // check whether turns exist at all
|
||||
{
|
||||
// FALLBACK, this should hopefully never be reached
|
||||
util::SimpleLogger().Write(logDEBUG)
|
||||
<< "Fallback reached from motorway, no continue angle, " << intersection.size()
|
||||
<< " roads, " << countValid(intersection) << " valid ones.";
|
||||
util::Log(logDEBUG) << "Fallback reached from motorway, no continue angle, "
|
||||
<< intersection.size() << " roads, " << countValid(intersection)
|
||||
<< " valid ones.";
|
||||
return fallback(std::move(intersection));
|
||||
}
|
||||
}
|
||||
@@ -275,7 +275,7 @@ Intersection MotorwayHandler::fromMotorway(const EdgeID via_eid, Intersection in
|
||||
via_eid,
|
||||
isThroughStreet(1, intersection),
|
||||
intersection[1]);
|
||||
util::SimpleLogger().Write(logDEBUG) << "Disabled U-Turn on a freeway";
|
||||
util::Log(logDEBUG) << "Disabled U-Turn on a freeway";
|
||||
intersection[0].entry_allowed = false; // UTURN on the freeway
|
||||
}
|
||||
else if (exiting_motorways == 2)
|
||||
@@ -334,8 +334,8 @@ Intersection MotorwayHandler::fromMotorway(const EdgeID via_eid, Intersection in
|
||||
}
|
||||
else
|
||||
{
|
||||
util::SimpleLogger().Write(logDEBUG) << "Found motorway junction with more than "
|
||||
"2 exiting motorways or additional ramps";
|
||||
util::Log(logDEBUG) << "Found motorway junction with more than "
|
||||
"2 exiting motorways or additional ramps";
|
||||
return fallback(std::move(intersection));
|
||||
}
|
||||
} // done for more than one highway exit
|
||||
@@ -489,9 +489,8 @@ Intersection MotorwayHandler::fromRamp(const EdgeID via_eid, Intersection inters
|
||||
}
|
||||
else
|
||||
{ // FALLBACK, hopefully this should never been reached
|
||||
util::SimpleLogger().Write(logDEBUG) << "Reached fallback on motorway ramp with "
|
||||
<< intersection.size() << " roads and "
|
||||
<< countValid(intersection) << " valid turns.";
|
||||
util::Log(logDEBUG) << "Reached fallback on motorway ramp with " << intersection.size()
|
||||
<< " roads and " << countValid(intersection) << " valid turns.";
|
||||
return fallback(std::move(intersection));
|
||||
}
|
||||
return intersection;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "util/coordinate_calculation.hpp"
|
||||
#include "util/guidance/toolkit.hpp"
|
||||
#include "util/simple_logger.hpp"
|
||||
#include "util/log.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "util/coordinate.hpp"
|
||||
#include "util/coordinate_calculation.hpp"
|
||||
#include "util/guidance/toolkit.hpp"
|
||||
#include "util/simple_logger.hpp"
|
||||
#include "util/log.hpp"
|
||||
|
||||
#include <cstddef>
|
||||
#include <iomanip>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "extractor/guidance/turn_classification.hpp"
|
||||
|
||||
#include "util/simple_logger.hpp"
|
||||
#include "util/log.hpp"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "extractor/guidance/turn_lane_augmentation.hpp"
|
||||
#include "extractor/guidance/turn_lane_types.hpp"
|
||||
#include "util/simple_logger.hpp"
|
||||
#include "util/log.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <boost/assert.hpp>
|
||||
@@ -104,7 +104,7 @@ LaneDataVector augmentMultiple(const std::size_t none_index,
|
||||
}
|
||||
}
|
||||
// this should, theoretically, never be reached
|
||||
util::SimpleLogger().Write(logWARNING) << "Failed lane assignment. Reached bad situation.";
|
||||
util::Log(logWARNING) << "Failed lane assignment. Reached bad situation.";
|
||||
return std::make_pair(std::size_t{0}, std::size_t{0});
|
||||
}();
|
||||
for (auto intersection_index = range.first; intersection_index < range.second;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "extractor/guidance/turn_discovery.hpp"
|
||||
#include "extractor/guidance/turn_lane_augmentation.hpp"
|
||||
#include "extractor/guidance/turn_lane_matcher.hpp"
|
||||
#include "util/simple_logger.hpp"
|
||||
#include "util/log.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
#include <cstddef>
|
||||
@@ -46,8 +46,8 @@ TurnLaneHandler::TurnLaneHandler(const util::NodeBasedDynamicGraph &node_based_g
|
||||
|
||||
TurnLaneHandler::~TurnLaneHandler()
|
||||
{
|
||||
std::cout << "Handled: " << count_handled << " of " << count_called
|
||||
<< " lanes: " << (double)(count_handled * 100) / (count_called) << " %." << std::endl;
|
||||
util::Log() << "Handled: " << count_handled << " of " << count_called
|
||||
<< " lanes: " << (double)(count_handled * 100) / (count_called) << " %.";
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
#include "extractor/raster_source.hpp"
|
||||
|
||||
#include "util/simple_logger.hpp"
|
||||
#include "util/exception.hpp"
|
||||
#include "util/exception_utils.hpp"
|
||||
#include "util/log.hpp"
|
||||
#include "util/timing_util.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
@@ -92,20 +95,20 @@ int SourceContainer::LoadRasterSource(const std::string &path_string,
|
||||
const auto itr = LoadedSourcePaths.find(path_string);
|
||||
if (itr != LoadedSourcePaths.end())
|
||||
{
|
||||
util::SimpleLogger().Write() << "[source loader] Already loaded source '" << path_string
|
||||
<< "' at source_id " << itr->second;
|
||||
util::Log() << "[source loader] Already loaded source '" << path_string << "' at source_id "
|
||||
<< itr->second;
|
||||
return itr->second;
|
||||
}
|
||||
|
||||
int source_id = static_cast<int>(LoadedSources.size());
|
||||
|
||||
util::SimpleLogger().Write() << "[source loader] Loading from " << path_string << " ... ";
|
||||
util::Log() << "[source loader] Loading from " << path_string << " ... ";
|
||||
TIMER_START(loading_source);
|
||||
|
||||
boost::filesystem::path filepath(path_string);
|
||||
if (!boost::filesystem::exists(filepath))
|
||||
{
|
||||
throw util::exception("error reading: no such path");
|
||||
throw util::exception(path_string + " does not exist" + SOURCE_REF);
|
||||
}
|
||||
|
||||
RasterGrid rasterData{filepath, ncols, nrows};
|
||||
@@ -115,8 +118,7 @@ int SourceContainer::LoadRasterSource(const std::string &path_string,
|
||||
LoadedSourcePaths.emplace(path_string, source_id);
|
||||
LoadedSources.push_back(std::move(source));
|
||||
|
||||
util::SimpleLogger().Write() << "[source loader] ok, after " << TIMER_SEC(loading_source)
|
||||
<< "s";
|
||||
util::Log() << "[source loader] ok, after " << TIMER_SEC(loading_source) << "s";
|
||||
|
||||
return source_id;
|
||||
}
|
||||
@@ -126,7 +128,9 @@ RasterDatum SourceContainer::GetRasterDataFromSource(unsigned int source_id, dou
|
||||
{
|
||||
if (LoadedSources.size() < source_id + 1)
|
||||
{
|
||||
throw util::exception("error reading: no such loaded source");
|
||||
throw util::exception("Attempted to access source " + std::to_string(source_id) +
|
||||
", but there are only " + std::to_string(LoadedSources.size()) +
|
||||
" loaded" + SOURCE_REF);
|
||||
}
|
||||
|
||||
BOOST_ASSERT(lat < 90);
|
||||
@@ -145,7 +149,9 @@ SourceContainer::GetRasterInterpolateFromSource(unsigned int source_id, double l
|
||||
{
|
||||
if (LoadedSources.size() < source_id + 1)
|
||||
{
|
||||
throw util::exception("error reading: no such loaded source");
|
||||
throw util::exception("Attempted to access source " + std::to_string(source_id) +
|
||||
", but there are only " + std::to_string(LoadedSources.size()) +
|
||||
" loaded" + SOURCE_REF);
|
||||
}
|
||||
|
||||
BOOST_ASSERT(lat < 90);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "extractor/external_memory_node.hpp"
|
||||
|
||||
#include "util/simple_logger.hpp"
|
||||
#include "util/log.hpp"
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
@@ -33,15 +33,15 @@ RestrictionParser::RestrictionParser(ScriptingEnvironment &scripting_environment
|
||||
const unsigned count = restrictions.size();
|
||||
if (count > 0)
|
||||
{
|
||||
util::SimpleLogger().Write() << "Found " << count << " turn restriction tags:";
|
||||
util::Log() << "Found " << count << " turn restriction tags:";
|
||||
for (const std::string &str : restrictions)
|
||||
{
|
||||
util::SimpleLogger().Write() << " " << str;
|
||||
util::Log() << " " << str;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
util::SimpleLogger().Write() << "Found no turn restriction tags";
|
||||
util::Log() << "Found no turn restriction tags";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,9 @@
|
||||
#include "extractor/raster_source.hpp"
|
||||
#include "extractor/restriction_parser.hpp"
|
||||
#include "util/exception.hpp"
|
||||
#include "util/exception_utils.hpp"
|
||||
#include "util/log.hpp"
|
||||
#include "util/lua_util.hpp"
|
||||
#include "util/simple_logger.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
#include <luabind/iterator_policy.hpp>
|
||||
@@ -65,14 +66,14 @@ int luaErrorCallback(lua_State *state)
|
||||
std::string error_msg = lua_tostring(state, -1);
|
||||
std::ostringstream error_stream;
|
||||
error_stream << error_msg;
|
||||
throw util::exception("ERROR occurred in profile script:\n" + error_stream.str());
|
||||
throw util::exception("ERROR occurred in profile script:\n" + error_stream.str() + SOURCE_REF);
|
||||
}
|
||||
}
|
||||
|
||||
LuaScriptingEnvironment::LuaScriptingEnvironment(const std::string &file_name)
|
||||
: file_name(file_name)
|
||||
{
|
||||
util::SimpleLogger().Write() << "Using script " << file_name;
|
||||
util::Log() << "Using script " << file_name;
|
||||
}
|
||||
|
||||
void LuaScriptingEnvironment::InitContext(LuaScriptingContext &context)
|
||||
@@ -265,7 +266,8 @@ void LuaScriptingEnvironment::InitContext(LuaScriptingContext &context)
|
||||
luabind::object error_msg(luabind::from_stack(context.state, -1));
|
||||
std::ostringstream error_stream;
|
||||
error_stream << error_msg;
|
||||
throw util::exception("ERROR occurred in profile script:\n" + error_stream.str());
|
||||
throw util::exception("ERROR occurred in profile script:\n" + error_stream.str() +
|
||||
SOURCE_REF);
|
||||
}
|
||||
|
||||
context.has_turn_penalty_function = util::luaFunctionExists(context.state, "turn_function");
|
||||
@@ -360,7 +362,7 @@ std::vector<std::string> LuaScriptingEnvironment::GetNameSuffixList()
|
||||
}
|
||||
catch (const luabind::error &er)
|
||||
{
|
||||
util::SimpleLogger().Write(logWARNING) << er.what();
|
||||
util::Log(logWARNING) << er.what();
|
||||
}
|
||||
|
||||
return suffixes_vector;
|
||||
@@ -406,7 +408,7 @@ int32_t LuaScriptingEnvironment::GetTurnPenalty(const double angle)
|
||||
}
|
||||
catch (const luabind::error &er)
|
||||
{
|
||||
util::SimpleLogger().Write(logWARNING) << er.what();
|
||||
util::Log(logWARNING) << er.what();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user