diff --git a/include/engine/datafacade/datafacade_base.hpp b/include/engine/datafacade/datafacade_base.hpp index 231c2a019..54ec8c847 100644 --- a/include/engine/datafacade/datafacade_base.hpp +++ b/include/engine/datafacade/datafacade_base.hpp @@ -65,8 +65,6 @@ template class BaseDataFacade // node and edge information access virtual util::FixedPointCoordinate GetCoordinateOfNode(const unsigned id) const = 0; - virtual bool EdgeIsCompressed(const unsigned id) const = 0; - virtual unsigned GetGeometryIndexForEdgeID(const unsigned id) const = 0; virtual void GetUncompressedGeometry(const EdgeID id, diff --git a/include/engine/datafacade/internal_datafacade.hpp b/include/engine/datafacade/internal_datafacade.hpp index 10c63d669..d0e131ea1 100644 --- a/include/engine/datafacade/internal_datafacade.hpp +++ b/include/engine/datafacade/internal_datafacade.hpp @@ -71,7 +71,6 @@ template class InternalDataFacade final : public BaseDataFacad util::ShM::vector m_turn_instruction_list; util::ShM::vector m_travel_mode_list; util::ShM::vector m_names_char_list; - util::ShM::vector m_edge_is_compressed; util::ShM::vector m_geometry_indices; util::ShM::vector m_geometry_list; util::ShM::vector m_is_core_node; @@ -151,9 +150,6 @@ template class InternalDataFacade final : public BaseDataFacad m_name_ID_list.resize(number_of_edges); m_turn_instruction_list.resize(number_of_edges); m_travel_mode_list.resize(number_of_edges); - m_edge_is_compressed.resize(number_of_edges); - - unsigned compressed = 0; extractor::OriginalEdgeData current_edge_data; for (unsigned i = 0; i < number_of_edges; ++i) @@ -164,11 +160,7 @@ template class InternalDataFacade final : public BaseDataFacad m_name_ID_list[i] = current_edge_data.name_id; m_turn_instruction_list[i] = current_edge_data.turn_instruction; m_travel_mode_list[i] = current_edge_data.travel_mode; - m_edge_is_compressed[i] = current_edge_data.compressed_geometry; - if (m_edge_is_compressed[i]) - { - ++compressed; - } + BOOST_ASSERT(current_edge_data.compressed_geometry); } } @@ -339,11 +331,6 @@ template class InternalDataFacade final : public BaseDataFacad return m_coordinate_list->at(id); } - bool EdgeIsCompressed(const unsigned id) const override final - { - return m_edge_is_compressed.at(id); - } - extractor::TurnInstruction GetTurnInstructionForEdgeID(const unsigned id) const override final { return m_turn_instruction_list.at(id); diff --git a/include/engine/datafacade/shared_datafacade.hpp b/include/engine/datafacade/shared_datafacade.hpp index 539b2be3a..d0567d30a 100644 --- a/include/engine/datafacade/shared_datafacade.hpp +++ b/include/engine/datafacade/shared_datafacade.hpp @@ -75,7 +75,6 @@ template class SharedDataFacade final : public BaseDataFacade< util::ShM::vector m_travel_mode_list; util::ShM::vector m_names_char_list; util::ShM::vector m_name_begin_indices; - util::ShM::vector m_edge_is_compressed; util::ShM::vector m_geometry_indices; util::ShM::vector m_geometry_list; util::ShM::vector m_is_core_node; @@ -207,13 +206,6 @@ template class SharedDataFacade final : public BaseDataFacade< void LoadGeometries() { - auto geometries_compressed_ptr = data_layout->GetBlockPtr( - shared_memory, storage::SharedDataLayout::GEOMETRIES_INDICATORS); - typename util::ShM::vector edge_is_compressed( - geometries_compressed_ptr, - data_layout->num_entries[storage::SharedDataLayout::GEOMETRIES_INDICATORS]); - m_edge_is_compressed = std::move(edge_is_compressed); - auto geometries_index_ptr = data_layout->GetBlockPtr( shared_memory, storage::SharedDataLayout::GEOMETRIES_INDEX); typename util::ShM::vector geometry_begin_indices( @@ -378,11 +370,6 @@ template class SharedDataFacade final : public BaseDataFacade< return m_coordinate_list->at(id); } - virtual bool EdgeIsCompressed(const unsigned id) const override final - { - return m_edge_is_compressed.at(id); - } - virtual void GetUncompressedGeometry(const EdgeID id, std::vector &result_nodes) const override final { diff --git a/include/engine/routing_algorithms/routing_base.hpp b/include/engine/routing_algorithms/routing_base.hpp index 942c3f646..e079d2c7c 100644 --- a/include/engine/routing_algorithms/routing_base.hpp +++ b/include/engine/routing_algorithms/routing_base.hpp @@ -243,8 +243,8 @@ template class BasicRoutingInterface edge = recursion_stack.top(); recursion_stack.pop(); - // facade->FindEdge does not suffice here in case of shortcuts. - // The above explanation unclear? Think! + // Contraction might introduce double edges by inserting shortcuts + // this searching for the smallest upwards edge found by the forward search EdgeID smaller_edge_id = SPECIAL_EDGEID; EdgeWeight edge_weight = std::numeric_limits::max(); for (const auto edge_id : facade->GetAdjacentEdgeRange(edge.first)) @@ -261,6 +261,8 @@ template class BasicRoutingInterface // edge.first edge.second // *<------------------* // edge_id + // if we don't find a forward edge, this edge must have been an downwards edge + // found by the reverse search. if (SPECIAL_EDGEID == smaller_edge_id) { for (const auto edge_id : facade->GetAdjacentEdgeRange(edge.second)) @@ -295,48 +297,40 @@ template class BasicRoutingInterface ? phantom_node_pair.source_phantom.backward_travel_mode : facade->GetTravelModeForEdgeID(ed.id); - if (!facade->EdgeIsCompressed(ed.id)) + std::vector id_vector; + facade->GetUncompressedGeometry(facade->GetGeometryIndexForEdgeID(ed.id), + id_vector); + + std::vector weight_vector; + facade->GetUncompressedWeights(facade->GetGeometryIndexForEdgeID(ed.id), + weight_vector); + + int total_weight = + std::accumulate(weight_vector.begin(), weight_vector.end(), 0); + + BOOST_ASSERT(weight_vector.size() == id_vector.size()); + // ed.distance should be total_weight + penalties (turn, stop, etc) + BOOST_ASSERT(ed.distance >= total_weight); + + const std::size_t start_index = + (unpacked_path.empty() + ? ((start_traversed_in_reverse) + ? id_vector.size() - + phantom_node_pair.source_phantom.fwd_segment_position - 1 + : phantom_node_pair.source_phantom.fwd_segment_position) + : 0); + const std::size_t end_index = id_vector.size(); + + BOOST_ASSERT(start_index >= 0); + BOOST_ASSERT(start_index <= end_index); + for (std::size_t i = start_index; i < end_index; ++i) { - BOOST_ASSERT(!facade->EdgeIsCompressed(ed.id)); - unpacked_path.emplace_back(facade->GetGeometryIndexForEdgeID(ed.id), name_index, - turn_instruction, ed.distance, travel_mode); - } - else - { - std::vector id_vector; - facade->GetUncompressedGeometry(facade->GetGeometryIndexForEdgeID(ed.id), - id_vector); - - std::vector weight_vector; - facade->GetUncompressedWeights(facade->GetGeometryIndexForEdgeID(ed.id), - weight_vector); - - int total_weight = std::accumulate(weight_vector.begin(), weight_vector.end(), 0); - - BOOST_ASSERT(weight_vector.size() == id_vector.size()); - // ed.distance should be total_weight + penalties (turn, stop, etc) - BOOST_ASSERT(ed.distance >= total_weight); - - const std::size_t start_index = - (unpacked_path.empty() - ? ((start_traversed_in_reverse) - ? id_vector.size() - - phantom_node_pair.source_phantom.fwd_segment_position - 1 - : phantom_node_pair.source_phantom.fwd_segment_position) - : 0); - const std::size_t end_index = id_vector.size(); - - BOOST_ASSERT(start_index >= 0); - BOOST_ASSERT(start_index <= end_index); - for (std::size_t i = start_index; i < end_index; ++i) - { - unpacked_path.emplace_back(id_vector[i], name_index, - extractor::TurnInstruction::NoTurn, weight_vector[i], - travel_mode); - } - unpacked_path.back().turn_instruction = turn_instruction; - unpacked_path.back().segment_duration += (ed.distance - total_weight); + unpacked_path.emplace_back(id_vector[i], name_index, + extractor::TurnInstruction::NoTurn, weight_vector[i], + travel_mode); } + unpacked_path.back().turn_instruction = turn_instruction; + unpacked_path.back().segment_duration += (ed.distance - total_weight); } } std::vector id_vector; diff --git a/include/storage/shared_datatype.hpp b/include/storage/shared_datatype.hpp index 22f7bdec2..cd97d959c 100644 --- a/include/storage/shared_datatype.hpp +++ b/include/storage/shared_datatype.hpp @@ -33,7 +33,6 @@ struct SharedDataLayout R_SEARCH_TREE, GEOMETRIES_INDEX, GEOMETRIES_LIST, - GEOMETRIES_INDICATORS, HSGR_CHECKSUM, TIMESTAMP, FILE_INDEX_PATH, @@ -55,7 +54,7 @@ struct SharedDataLayout inline uint64_t GetBlockSize(BlockID bid) const { // special bit encoding - if (bid == GEOMETRIES_INDICATORS || bid == CORE_MARKER) + if (bid == CORE_MARKER) { return (num_entries[bid] / 32 + 1) * entry_size[bid]; } diff --git a/src/storage/storage.cpp b/src/storage/storage.cpp index a9588b0b2..dbc4076fa 100644 --- a/src/storage/storage.cpp +++ b/src/storage/storage.cpp @@ -230,9 +230,6 @@ int Storage::Run() number_of_original_edges); shared_layout_ptr->SetBlockSize(SharedDataLayout::TURN_INSTRUCTION, number_of_original_edges); - // note: there are 32 geometry indicators in one unsigned block - shared_layout_ptr->SetBlockSize(SharedDataLayout::GEOMETRIES_INDICATORS, - number_of_original_edges); boost::filesystem::ifstream hsgr_input_stream(hsgr_path, std::ios::binary); @@ -400,9 +397,6 @@ int Storage::Run() shared_layout_ptr->GetBlockPtr( shared_memory_ptr, SharedDataLayout::TURN_INSTRUCTION); - unsigned *geometries_indicator_ptr = shared_layout_ptr->GetBlockPtr( - shared_memory_ptr, SharedDataLayout::GEOMETRIES_INDICATORS); - extractor::OriginalEdgeData current_edge_data; for (unsigned i = 0; i < number_of_original_edges; ++i) { @@ -411,22 +405,7 @@ int Storage::Run() name_id_ptr[i] = current_edge_data.name_id; travel_mode_ptr[i] = current_edge_data.travel_mode; turn_instructions_ptr[i] = current_edge_data.turn_instruction; - - const unsigned bucket = i / 32; - const unsigned offset = i % 32; - const unsigned value = [&] - { - unsigned return_value = 0; - if (0 != offset) - { - return_value = geometries_indicator_ptr[bucket]; - } - return return_value; - }(); - if (current_edge_data.compressed_geometry) - { - geometries_indicator_ptr[bucket] = (value | (1u << offset)); - } + BOOST_ASSERT(current_edge_data.compressed_geometry); } edges_input_stream.close();