diff --git a/src/extractor/edge_based_graph_factory.cpp b/src/extractor/edge_based_graph_factory.cpp index bbfdf8340..2b76b416e 100644 --- a/src/extractor/edge_based_graph_factory.cpp +++ b/src/extractor/edge_based_graph_factory.cpp @@ -10,6 +10,7 @@ #include "util/exception.hpp" #include +#include #include #include @@ -139,10 +140,9 @@ void EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, const NodeI // traverse arrays from start and end respectively for (const auto i : util::irange(0UL, geometry_size)) { - BOOST_ASSERT( - current_edge_source_coordinate_id == - m_compressed_edge_container.GetBucketReference(edge_id_2)[geometry_size - 1 - i] - .node_id); + BOOST_ASSERT(current_edge_source_coordinate_id == + m_compressed_edge_container.GetBucketReference( + edge_id_2)[geometry_size - 1 - i].node_id); const NodeID current_edge_target_coordinate_id = forward_geometry[i].node_id; BOOST_ASSERT(current_edge_target_coordinate_id != current_edge_source_coordinate_id); @@ -309,9 +309,10 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges( edge_penalty_file.open(edge_fixed_penalties_filename.c_str(), std::ios::binary); } - // writes a dummy value that is updated later - edge_data_file.write(reinterpret_cast(&original_edges_counter), - sizeof(original_edges_counter)); + // Writes a dummy value at the front that is updated later with the total length + const unsigned length_prefix_empty_space{0}; + edge_data_file.write(reinterpret_cast(&length_prefix_empty_space), + sizeof(length_prefix_empty_space)); std::vector original_edge_data_vector; original_edge_data_vector.reserve(1024 * 1024); @@ -475,9 +476,13 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges( FlushVectorToStream(edge_data_file, original_edge_data_vector); + // Finally jump back to the empty space at the beginning and write length prefix edge_data_file.seekp(std::ios::beg); - edge_data_file.write(reinterpret_cast(&original_edges_counter), - sizeof(original_edges_counter)); + + const auto length_prefix = boost::numeric_cast(original_edges_counter); + static_assert(sizeof(length_prefix_empty_space) == sizeof(length_prefix), "type mismatch"); + + edge_data_file.write(reinterpret_cast(&length_prefix), sizeof(length_prefix)); util::SimpleLogger().Write() << "Generated " << m_edge_based_node_list.size() << " edge based nodes"; @@ -707,8 +712,8 @@ bool EdgeBasedGraphFactory::isObviousChoice(EdgeID via_eid, const auto &candidate_to_the_right = turn_candidates[getRight(turn_index)]; - const auto hasValidRatio = [](const TurnCandidate &left, const TurnCandidate ¢er, - const TurnCandidate &right) + const auto hasValidRatio = + [](const TurnCandidate &left, const TurnCandidate ¢er, const TurnCandidate &right) { auto angle_left = (left.angle > 180) ? angularDeviation(left.angle, STRAIGHT_ANGLE) : 180; auto angle_right = @@ -1042,9 +1047,9 @@ QueryNode EdgeBasedGraphFactory::getRepresentativeCoordinate(const NodeID src, double this_dist = 0; NodeID prev_id = INVERTED ? tgt : src; - const auto selectBestCandidate = [this](const NodeID current, const double current_distance, - const NodeID previous, - const double previous_distance) + const auto selectBestCandidate = + [this](const NodeID current, const double current_distance, const NodeID previous, + const double previous_distance) { if (current_distance < DESIRED_SEGMENT_LENGTH || current_distance - DESIRED_SEGMENT_LENGTH <