forward way ID information properly in turn restrictions parsing
This commit is contained in:
		
							parent
							
								
									16631bf454
								
							
						
					
					
						commit
						a7c683a83c
					
				| @ -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(), | ||||
|  | ||||
| @ -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; | ||||
|  | ||||
| @ -66,13 +66,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
| namespace | ||||
| { | ||||
| 
 | ||||
| struct ResultBuffer | ||||
| { | ||||
|     std::vector<std::pair<osmium::NodeRef, ExtractionNode>> nodes; | ||||
|     std::vector<std::pair<osmium::WayNodeList, ExtractionWay>> ways; | ||||
|     std::vector<mapbox::util::optional<InputRestrictionContainer>> 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<std::shared_ptr<osmium::memory::Buffer>> parse_queue(128);
 | ||||
|         // ConcurrentQueue<std::shared_ptr<ResultBuffer>> result_queue(128);
 | ||||
| 
 | ||||
|         // std::thread loading_thread([&]{
 | ||||
|         //     while (osmium::memory::Buffer buffer = reader.read())
 | ||||
|         //     {
 | ||||
|         //         parse_queue.push(std::make_shared<osmium::memory::Buffer>(std::move(buffer)));
 | ||||
|         //     }
 | ||||
|         //     loading_done = true;
 | ||||
|         // });
 | ||||
| 
 | ||||
|         // // parsing threads
 | ||||
|         // while (!loading_done || !parse_queue.empty())
 | ||||
|         // {
 | ||||
|         //     std::shared_ptr<osmium::memory::Buffer> current_buffer;
 | ||||
|         //     if (!parse_queue.try_pop(current_buffer))
 | ||||
|         //     {
 | ||||
|         //         continue;
 | ||||
|         //     }
 | ||||
| 
 | ||||
|             ExtractionNode result_node; | ||||
|             ExtractionWay result_way; | ||||
| 
 | ||||
|         //     std::shared_ptr<ResultBuffer> result_buffer = std::make_shared<ResultBuffer>();;
 | ||||
|         //     for (osmium::OSMEntity &entity : *current_buffer)
 | ||||
|         //     {
 | ||||
|         //         switch (entity.type())
 | ||||
|         //         {
 | ||||
|         //         case osmium::item_type::node:
 | ||||
|         //             ++number_of_nodes;
 | ||||
|         //             result_node.Clear();
 | ||||
|         //             luabind::call_function<void>(lua_state,
 | ||||
|         //                                          "node_function",
 | ||||
|         //                                          boost::cref(static_cast<osmium::Node &>(entity)),
 | ||||
|         //                                          boost::ref(result_node));
 | ||||
|         //             result_buffer->nodes.emplace_back(osmium::NodeRef{static_cast<osmium::Node &>(entity).id(), static_cast<osmium::Node &>(entity).location()}, result_node);
 | ||||
|         //             break;
 | ||||
|         //         case osmium::item_type::way:
 | ||||
|         //             ++number_of_ways;
 | ||||
|         //             result_way.Clear();
 | ||||
|         //             luabind::call_function<void>(lua_state,
 | ||||
|         //                                          "way_function",
 | ||||
|         //                                          boost::cref(static_cast<osmium::Way &>(entity)),
 | ||||
|         //                                          boost::ref(result_way));
 | ||||
|         //             result_way.id = static_cast<osmium::Way &>(entity).id();
 | ||||
|         //             result_buffer->ways.emplace_back(std::move(static_cast<osmium::Way &>(entity).nodes()), result_way);
 | ||||
|         //             break;
 | ||||
|         //         case osmium::item_type::relation:
 | ||||
|         //             ++number_of_relations;
 | ||||
|         //             result_buffer->restrictions.emplace_back(restriction_parser.TryParse(static_cast<osmium::Relation &>(entity)));
 | ||||
|         //             break;
 | ||||
|         //         default:
 | ||||
|         //             ++number_of_others;
 | ||||
|         //             break;
 | ||||
|         //         }
 | ||||
|         //     }
 | ||||
|         //     result_queue.push(result_buffer);
 | ||||
|         //     parsing_done = true;
 | ||||
|         // }
 | ||||
| 
 | ||||
|         // while (!parsing_done || !result_queue.empty())
 | ||||
|         // {
 | ||||
|         //     std::shared_ptr<ResultBuffer> 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()) | ||||
|         { | ||||
|  | ||||
| @ -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<decltype(parsed_way.id)>::max() == parsed_way.id) | ||||
|     if (std::numeric_limits<decltype(input_way.id())>::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<double>::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(), | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user