Example #1
0
 osmium::item_type operator()(osmium::memory::Buffer& buffer) {
     return operator()(buffer.begin(), buffer.end());
 }
Example #2
0
 osmium::item_type operator()(osmium::memory::Buffer& buffer, const osmium::item_type type) {
     return operator()(buffer.begin(), buffer.end(), type);
 }
Example #3
0
 inline void apply_diff(osmium::memory::Buffer& buffer, THandlers&... handlers) {
     apply_diff(buffer.begin(), buffer.end(), handlers...);
 }
#include <osmium/io/xml_input.hpp>

TEST_CASE("Single relation") {
  SECTION("Should extract the relation because it uses a node in the bounding box") {
    using id_set = std_id_set;

    osmium::io::File file(test_data_file("test_single_relation.osm"));
    osmium::Box box(osmium::Location(double(-1), double(-1)),
                    osmium::Location(double( 1), double( 1)));

    hsplitter::HistoryExtractReader<id_set> reader =
      hsplitter::read_extract<id_set>(file, box);

    REQUIRE(!reader.eof());
    osmium::memory::Buffer buffer = reader.read();
    REQUIRE(std::distance(buffer.begin(), buffer.end()) == 2);
    osmium::memory::Buffer::iterator itr = buffer.begin();
    {
      REQUIRE(itr->type() == osmium::item_type::node);
      auto &node = static_cast<const osmium::Node &>(*itr++);
      REQUIRE(node.id() == 1);
    }
    {
      REQUIRE(itr->type() == osmium::item_type::relation);
      auto &rel = static_cast<const osmium::Relation &>(*itr++);
      REQUIRE(rel.id() == 1);
    }
  }

  SECTION("Should extract the relation because it uses a way which uses a node in the bbox") {
    using id_set = std_id_set;
Example #5
0
            // XXX
            void operator()(const osmium::memory::Buffer& buffer) {
                osmium::io::detail::reliable_write(m_data_fd, buffer.data(), buffer.committed());

                osmium::apply(buffer.begin(), buffer.end(), *this);
            }
Example #6
0
 buffer_iterator_pair get_next_iter() {
     m_buffer = read();
     return std::make_pair(m_buffer.begin(), m_buffer.end());
 }
    constexpr size_t buffer_size = 10000;
    unsigned char data[buffer_size];

    map_t node_tiles, way_tiles, extra_node_tiles;
    node_tiles.m_map[1] = std::set<hsplitter::tile_t>({1});
    node_tiles.m_map[2] = std::set<hsplitter::tile_t>({1});
    node_tiles.m_map[3] = std::set<hsplitter::tile_t>({1});
    node_tiles.freeze();
    way_tiles.freeze();
    extra_node_tiles.freeze();

    osmium::memory::Buffer rels(data, buffer_size, 0);

    push_back_rel(rels, 1, 1, true, 1, 1, {1, 2, 3}, {}, {});

    REQUIRE(std::distance(rels.begin(), rels.end()) == 1);

    auto it = rels.begin();
    auto pair = hsplitter::tiles_for_relations<map_t>(it, rels.end(), node_tiles, way_tiles, extra_node_tiles);
    map_t rel_tiles = std::move(pair.first);
    map_t extra_rel_tiles = std::move(pair.second);

    REQUIRE(rel_tiles.m_map.size() == 1);
    REQUIRE(rel_tiles.m_map.count(1) == 1);
    REQUIRE(rel_tiles.m_map[1].size() == 1);
    REQUIRE(rel_tiles.m_map[1].count(1) == 1);
    REQUIRE(extra_rel_tiles.m_map.empty());
  }

  SECTION("should account for ways.") {
    using map_t = tileset;