コード例 #1
0
    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();
    }
コード例 #2
0
                std::unique_ptr<osmium::io::detail::OutputFormat> create_output(const osmium::io::File& file, data_queue_type& output_queue) {
                    file.check();

                    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 std::runtime_error(std::string("Support for output format '") + as_string(file.format()) + "' not compiled into this binary.");
                }
コード例 #3
0
ファイル: input_format.hpp プロジェクト: Gozhack/osrm-backend
                std::unique_ptr<osmium::io::detail::InputFormat> create_input(const osmium::io::File& file, osmium::osm_entity_bits::type read_which_entities, osmium::thread::Queue<std::string>& input_queue) {
                    file.check();

                    auto it = m_callbacks.find(file.format());
                    if (it != m_callbacks.end()) {
                        return std::unique_ptr<osmium::io::detail::InputFormat>((it->second)(file, read_which_entities, input_queue));
                    }

                    throw std::runtime_error(std::string("Support for input format '") + as_string(file.format()) + "' not compiled into this binary.");
                }
コード例 #4
0
ファイル: input_format.hpp プロジェクト: alex85k/osm2pgsql
 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;
 }
コード例 #5
0
ファイル: output_format.hpp プロジェクト: tomhughes/libosmium
                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."};
                }
コード例 #6
0
ファイル: output_format.hpp プロジェクト: AFDudley/osm2pgsql
                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.");
                }
コード例 #7
0
ファイル: input.hpp プロジェクト: gijs/libosmium
            std::unique_ptr<osmium::io::Input> create_input(const osmium::io::File& file) {
                encoding2create_type::iterator it = m_callbacks.find(file.encoding());

                if (it != m_callbacks.end()) {
                    return std::unique_ptr<osmium::io::Input>((it->second)(file));
                }

                throw osmium::io::File::FileEncodingNotSupported();
            }
コード例 #8
0
ファイル: reader.hpp プロジェクト: 7ute/osrm-backend
 /**
  * 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};
 }
コード例 #9
0
 OPLOutputFormat(const osmium::io::File& file, future_string_queue_type& output_queue) :
     OutputFormat(output_queue),
     m_options() {
     m_options.add_metadata = file.is_not_false("add_metadata");
 }
コード例 #10
0
ファイル: input_format.hpp プロジェクト: Gozhack/osrm-backend
 explicit InputFormat(const osmium::io::File& file, osmium::osm_entity_bits::type read_which_entities, osmium::thread::Queue<std::string>& input_queue) :
     m_file(file),
     m_read_which_entities(read_which_entities),
     m_input_queue(input_queue) {
     m_header.set_has_multiple_object_versions(m_file.has_multiple_object_versions());
 }
コード例 #11
0
ファイル: input.hpp プロジェクト: gijs/libosmium
 int fd() const {
     return m_file.fd();
 }
コード例 #12
0
ファイル: input.hpp プロジェクト: gijs/libosmium
            Input(const osmium::io::File& file) :
                m_file(file) {
                m_header.has_multiple_object_versions(m_file.has_multiple_object_versions());
                m_file.open_for_input();

            }
コード例 #13
0
 XMLOutputFormat(const osmium::io::File& file, data_queue_type& output_queue) :
     OutputFormat(file, output_queue),
     m_write_visible_flag(file.has_multiple_object_versions() || m_file.is_true("force_visible_flag")) {
 }