void Strategy::run(osmium::VerboseOutput& vout, bool display_progress, const osmium::io::File& input_file) { if (input_file.filename().empty()) { throw osmium::io_error{"Can not read from STDIN when using 'complete_ways' strategy."}; } vout << "Running 'complete_ways' strategy in two passes...\n"; const std::size_t file_size = osmium::file_size(input_file.filename()); osmium::ProgressBar progress_bar{file_size * 2, display_progress}; vout << "First pass (of two)...\n"; Pass1 pass1{*this}; pass1.run(progress_bar, input_file, osmium::io::read_meta::no); progress_bar.file_done(file_size); // recursively get parents of all relations that are in an extract const auto relations_map = pass1.relations_map_stash().build_member_to_parent_index(); for (auto& e : m_extracts) { for (osmium::unsigned_object_id_type id : e.relation_ids) { e.add_relation_parents(id, relations_map); } } progress_bar.remove(); vout << "Second pass (of two)...\n"; Pass2 pass2{*this}; pass2.run(progress_bar, input_file); progress_bar.done(); }
create_parser_type get_creator_function(const osmium::io::File& file) { auto it = m_callbacks.find(file.format()); if (it == m_callbacks.end()) { throw unsupported_file_format_error( std::string("Can not open file '") + file.filename() + "' with type '" + as_string(file.format()) + "'. No support for reading this format in this program."); } return it->second; }
std::unique_ptr<osmium::io::detail::OutputFormat> create_output(osmium::thread::Pool& pool, const osmium::io::File& file, future_string_queue_type& output_queue) const { const auto func = callbacks(file.format()); if (func) { return std::unique_ptr<osmium::io::detail::OutputFormat>((func)(pool, file, output_queue)); } throw unsupported_file_format_error{ std::string{"Can not open file '"} + file.filename() + "' with type '" + as_string(file.format()) + "'. No support for writing this format in this program."}; }
std::unique_ptr<osmium::io::detail::OutputFormat> create_output(const osmium::io::File& file, future_string_queue_type& output_queue) { auto it = m_callbacks.find(file.format()); if (it != m_callbacks.end()) { return std::unique_ptr<osmium::io::detail::OutputFormat>((it->second)(file, output_queue)); } throw unsupported_file_format_error( std::string("Can not open file '") + file.filename() + "' with type '" + as_string(file.format()) + "'. No support for writing this format in this program."); }
/** * Create new Reader object. * * @param file The file we want to open. * @param read_which_entities Which OSM entities (nodes, ways, relations, and/or changesets) * should be read from the input file. It can speed the read up * significantly if objects that are not needed anyway are not * parsed. */ explicit Reader(const osmium::io::File& file, osmium::osm_entity_bits::type read_which_entities = osmium::osm_entity_bits::all) : m_file(file.check()), m_read_which_entities(read_which_entities), m_status(status::okay), m_childpid(0), m_input_queue(max_input_queue_size, "raw_input"), m_decompressor(m_file.buffer() ? osmium::io::CompressionFactory::instance().create_decompressor(file.compression(), m_file.buffer(), m_file.buffer_size()) : osmium::io::CompressionFactory::instance().create_decompressor(file.compression(), open_input_file_or_url(m_file.filename(), &m_childpid))), m_read_thread_manager(*m_decompressor, m_input_queue), m_osmdata_queue(max_osmdata_queue_size, "parser_results"), m_osmdata_queue_wrapper(m_osmdata_queue), m_header_future(), m_header(), m_thread() { std::promise<osmium::io::Header> header_promise; m_header_future = header_promise.get_future(); m_thread = osmium::thread::thread_handler{parser_thread, std::ref(m_file), std::ref(m_input_queue), std::ref(m_osmdata_queue), std::move(header_promise), read_which_entities}; }