Esempio n. 1
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.");
                }
Esempio n. 2
0
                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.");
                }
Esempio n. 3
0
 /**
  * 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};
 }