From a7c683a83cca9355b19bb18dfda77a3927edafbc Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Mon, 13 Oct 2014 15:51:40 +0200 Subject: [PATCH] forward way ID information properly in turn restrictions parsing --- Extractor/ExtractionContainers.cpp | 2 +- Extractor/ExtractionWay.h | 2 - Extractor/Extractor.cpp | 99 +----------------------------- Extractor/ExtractorCallbacks.cpp | 14 +++-- 4 files changed, 12 insertions(+), 105 deletions(-) diff --git a/Extractor/ExtractionContainers.cpp b/Extractor/ExtractionContainers.cpp index 204ab79c2..d934bd74e 100644 --- a/Extractor/ExtractionContainers.cpp +++ b/Extractor/ExtractionContainers.cpp @@ -102,7 +102,7 @@ void ExtractionContainers::PrepareData(const std::string &output_file_name, TIMER_STOP(sort_ways); std::cout << "ok, after " << TIMER_SEC(sort_ways) << "s" << std::endl; - std::cout << "[extractor] Sorting restrictions. by from... " << std::flush; + std::cout << "[extractor] Sorting " << restrictions_list.size() << " restrictions. by from... " << std::flush; TIMER_START(sort_restrictions); stxxl::sort(restrictions_list.begin(), restrictions_list.end(), diff --git a/Extractor/ExtractionWay.h b/Extractor/ExtractionWay.h index d42595a7b..740c4beaf 100644 --- a/Extractor/ExtractionWay.h +++ b/Extractor/ExtractionWay.h @@ -40,7 +40,6 @@ struct ExtractionWay void Clear() { - id = -1; forward_speed = -1; backward_speed = -1; duration = -1; @@ -107,7 +106,6 @@ struct ExtractionWay void set_backward_mode(const TravelMode m) { backward_travel_mode = m; } const TravelMode get_backward_mode() const { return backward_travel_mode; } - int64_t id; double forward_speed; double backward_speed; double duration; diff --git a/Extractor/Extractor.cpp b/Extractor/Extractor.cpp index 23a10f784..c5e3817cf 100644 --- a/Extractor/Extractor.cpp +++ b/Extractor/Extractor.cpp @@ -66,13 +66,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace { -struct ResultBuffer -{ - std::vector> nodes; - std::vector> ways; - std::vector> restrictions; -}; - int lua_error_callback(lua_State *L) // This is so I can use my own function as an // exception handler, pcall_log() { @@ -178,96 +171,8 @@ int Extractor::Run(int argc, char *argv[]) RestrictionParser restriction_parser(scripting_environment); - // // move to header - // std::atomic_bool parsing_done {false}; - // std::atomic_bool loading_done {false}; - - // ConcurrentQueue> parse_queue(128); - // ConcurrentQueue> result_queue(128); - - // std::thread loading_thread([&]{ - // while (osmium::memory::Buffer buffer = reader.read()) - // { - // parse_queue.push(std::make_shared(std::move(buffer))); - // } - // loading_done = true; - // }); - - // // parsing threads - // while (!loading_done || !parse_queue.empty()) - // { - // std::shared_ptr current_buffer; - // if (!parse_queue.try_pop(current_buffer)) - // { - // continue; - // } - - ExtractionNode result_node; - ExtractionWay result_way; - - // std::shared_ptr result_buffer = std::make_shared();; - // for (osmium::OSMEntity &entity : *current_buffer) - // { - // switch (entity.type()) - // { - // case osmium::item_type::node: - // ++number_of_nodes; - // result_node.Clear(); - // luabind::call_function(lua_state, - // "node_function", - // boost::cref(static_cast(entity)), - // boost::ref(result_node)); - // result_buffer->nodes.emplace_back(osmium::NodeRef{static_cast(entity).id(), static_cast(entity).location()}, result_node); - // break; - // case osmium::item_type::way: - // ++number_of_ways; - // result_way.Clear(); - // luabind::call_function(lua_state, - // "way_function", - // boost::cref(static_cast(entity)), - // boost::ref(result_way)); - // result_way.id = static_cast(entity).id(); - // result_buffer->ways.emplace_back(std::move(static_cast(entity).nodes()), result_way); - // break; - // case osmium::item_type::relation: - // ++number_of_relations; - // result_buffer->restrictions.emplace_back(restriction_parser.TryParse(static_cast(entity))); - // break; - // default: - // ++number_of_others; - // break; - // } - // } - // result_queue.push(result_buffer); - // parsing_done = true; - // } - - // while (!parsing_done || !result_queue.empty()) - // { - // std::shared_ptr current_buffer; - // if (!result_queue.try_pop(current_buffer)) - // { - // for (const auto &node : current_buffer->nodes) - // { - // extractor_callbacks->ProcessNode(node.first, - // node.second); - // } - // for (auto &way : current_buffer->ways) - // { - // extractor_callbacks->ProcessWay(way.first, - // way.second); - // } - // for (const auto &restriction : current_buffer->restrictions) - // { - // extractor_callbacks->ProcessRestriction(restriction); - // } - - // } - // } - - // loading_thread.join(); - - // // TODO: join parser threads + ExtractionNode result_node; + ExtractionWay result_way; while (osmium::memory::Buffer buffer = reader.read()) { diff --git a/Extractor/ExtractorCallbacks.cpp b/Extractor/ExtractorCallbacks.cpp index a7291faa4..df56d7fd3 100644 --- a/Extractor/ExtractorCallbacks.cpp +++ b/Extractor/ExtractorCallbacks.cpp @@ -66,6 +66,10 @@ void ExtractorCallbacks::ProcessRestriction( if (restriction) { external_memory.restrictions_list.push_back(restriction.get()); + SimpleLogger().Write() << "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 ? "y" : "n"); } } /** warning: caller needs to take care of synchronization! */ @@ -85,9 +89,9 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti return; } - if (std::numeric_limits::max() == parsed_way.id) + if (std::numeric_limits::max() == input_way.id()) { - SimpleLogger().Write(logDEBUG) << "found bogus way with id: " << parsed_way.id + SimpleLogger().Write(logDEBUG) << "found bogus way with id: " << input_way.id() << " of size " << input_way.nodes().size(); return; } @@ -101,7 +105,7 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti if (std::numeric_limits::epsilon() >= std::abs(-1. - parsed_way.forward_speed)) { - SimpleLogger().Write(logDEBUG) << "found way with bogus speed, id: " << parsed_way.id; + SimpleLogger().Write(logDEBUG) << "found way with bogus speed, id: " << input_way.id(); return; } @@ -165,7 +169,7 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti // The following information is needed to identify start and end segments of restrictions external_memory.way_start_end_id_list.push_back( - {(EdgeID)parsed_way.id, + {(EdgeID)input_way.id(), (NodeID)input_way.nodes()[0].ref(), (NodeID)input_way.nodes()[1].ref(), (NodeID)input_way.nodes()[input_way.nodes().size() - 2].ref(), @@ -210,7 +214,7 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti } external_memory.way_start_end_id_list.push_back( - {(EdgeID)parsed_way.id, + {(EdgeID)input_way.id(), (NodeID)input_way.nodes()[1].ref(), (NodeID)input_way.nodes()[0].ref(), (NodeID)input_way.nodes().back().ref(),