예제 #1
0
void apply_with_area(osmium::io::Reader &r,
                     osmium::area::MultipolygonCollector<osmium::area::Assembler> &collector) {

    IDX index;
    osmium::handler::NodeLocationsForWays<IDX> location_handler(index);
    location_handler.ignore_errors();

    osmium::apply(r, location_handler, *this,
                  collector.handler([this](const osmium::memory::Buffer& area_buffer) {
                       osmium::apply(area_buffer, *this);
                  })
                 );
}
예제 #2
0
 explicit FlexReader(const osmium::io::File& file, TLocationHandler& location_handler, osmium::osm_entity_bits::type entities = osmium::osm_entity_bits::nwr) :
     m_with_areas((entities & osmium::osm_entity_bits::area) != 0),
     m_entities((entities & ~osmium::osm_entity_bits::area) | (m_with_areas ? osmium::osm_entity_bits::node | osmium::osm_entity_bits::way : osmium::osm_entity_bits::nothing)),
     m_location_handler(location_handler),
     m_reader(file, m_entities),
     m_assembler_config(),
     m_collector(m_assembler_config)
 {
     m_location_handler.ignore_errors();
     if (m_with_areas) {
         osmium::io::Reader reader(file, osmium::osm_entity_bits::relation);
         m_collector.read_relations(reader);
         reader.close();
     }
 }
예제 #3
0
    osmium::memory::Buffer read() {
        osmium::memory::Buffer buffer = m_reader.read();

        if (buffer) {
            if (m_with_areas) {
                std::vector<osmium::memory::Buffer> area_buffers;
                osmium::apply(buffer, m_location_handler, m_collector.handler([&area_buffers](osmium::memory::Buffer&& area_buffer) {
                    area_buffers.push_back(std::move(area_buffer));
                }));
                for (const osmium::memory::Buffer& b : area_buffers) {
                    buffer.add_buffer(b);
                    buffer.commit();
                }
            } else if (m_entities & (osmium::osm_entity_bits::node | osmium::osm_entity_bits::way)) {
                osmium::apply(buffer, m_location_handler);
            }
        }

        return buffer;
    }