Exemplo n.º 1
0
                void node(const osmium::Node& node) {
                    if (m_write_change_ops) {
                        open_close_op_tag(node.visible() ? (node.version() == 1 ? operation::op_create : operation::op_modify) : operation::op_delete);
                    }

                    write_prefix();
                    m_out += "<node";

                    write_meta(node);

                    if (node.location()) {
                        m_out += " lat=\"";
                        osmium::util::double2string(std::back_inserter(m_out), node.location().lat_without_check(), 7);
                        m_out += "\" lon=\"";
                        osmium::util::double2string(std::back_inserter(m_out), node.location().lon_without_check(), 7);
                        m_out += "\"";
                    }

                    if (node.tags().empty()) {
                        m_out += "/>\n";
                        return;
                    }

                    m_out += ">\n";

                    write_tags(node.tags());

                    write_prefix();
                    m_out += "</node>\n";
                }
Exemplo n.º 2
0
void parse_osmium_t::node(osmium::Node& node)
{
    if (node.deleted()) {
        m_data->node_delete(node.id());
    } else {
        // if the node is not valid, then node.location.lat/lon() can throw.
        // we probably ought to treat invalid locations as if they were
        // deleted and ignore them.
        if (!node.location().valid()) {
          fprintf(stderr, "WARNING: Node %" PRIdOSMID " (version %ud) has an invalid "
                  "location and has been ignored. This is not expected to happen with "
                  "recent planet files, so please check that your input is correct.\n",
                  node.id(), node.version());

          return;
        }

        if (!m_bbox || m_bbox->contains(node.location())) {
            if (m_append) {
                m_data->node_modify(node);
            } else {
                m_data->node_add(node);
            }
            m_stats.add_node(node.id());
        }
    }
}
Exemplo n.º 3
0
 void node(osmium::Node &n) {
     // no nodes in the history file have a zero location, and
     // no visible nodes should have an undefined location.
     if ((n.location() == zero) ||
         (n.visible() && !n.location())) {
         ++count;
     }
     ++total_count;
 }
Exemplo n.º 4
0
/**
 * Takes the node position from osmium and the filtered properties from the lua
 * profile and saves them to external memory.
 *
 * warning: caller needs to take care of synchronization!
 */
void ExtractorCallbacks::ProcessNode(const osmium::Node &input_node,
                                     const ExtractionNode &result_node)
{
    external_memory.all_nodes_list.push_back(
        {util::toFixed(util::FloatLongitude{input_node.location().lon()}),
         util::toFixed(util::FloatLatitude{input_node.location().lat()}),
         OSMNodeID{static_cast<std::uint64_t>(input_node.id())},
         result_node.barrier,
         result_node.traffic_lights});
}
Exemplo n.º 5
0
 void node(osmium::Node& node) {
     if (node.id() == 101000) {
         assert(node.version() == 1);
         assert(node.location().lon() == 1.12);
         assert(node.location().lat() == 1.02);
     } else if (node.id() == 101001) {
         assert(node.version() == 1);
         assert(node.location().lon() == 1.12);
         assert(node.location().lat() == 1.03);
     } else if (node.id() == 101002) {
     } else if (node.id() == 101003) {
     } else {
         throw std::runtime_error("Unknown ID");
     }
 }
Exemplo n.º 6
0
void check_node_2(osmium::Node& node) {
    BOOST_CHECK_EQUAL(2, node.id());
    BOOST_CHECK_EQUAL(3, node.version());
    BOOST_CHECK_EQUAL(true, node.visible());
    BOOST_CHECK_EQUAL(333, node.changeset());
    BOOST_CHECK_EQUAL(21, node.uid());
    BOOST_CHECK_EQUAL(123, node.timestamp());
    BOOST_CHECK_EQUAL(osmium::Location(3.5, 4.7), node.location());
    BOOST_CHECK_EQUAL("testuser", node.user());

    for (osmium::memory::Item& item : node) {
        BOOST_CHECK_EQUAL(osmium::item_type::tag_list, item.type());
    }

    BOOST_CHECK(!node.tags().empty());
    BOOST_CHECK_EQUAL(2, std::distance(node.tags().begin(), node.tags().end()));

    int n = 0;
    for (osmium::Tag& tag : node.tags()) {
        switch (n) {
            case 0:
                BOOST_CHECK_EQUAL("amenity", tag.key());
                BOOST_CHECK_EQUAL("bank", tag.value());
                break;
            case 1:
                BOOST_CHECK_EQUAL("name", tag.key());
                BOOST_CHECK_EQUAL("OSM Savings", tag.value());
                break;
        }
        ++n;
    }
    BOOST_CHECK_EQUAL(2, n);
}
Exemplo n.º 7
0
void check_node_2(osmium::Node& node) {
    REQUIRE(2 == node.id());
    REQUIRE(3 == node.version());
    REQUIRE(true == node.visible());
    REQUIRE(333 == node.changeset());
    REQUIRE(21 == node.uid());
    REQUIRE(123 == node.timestamp());
    REQUIRE(osmium::Location(3.5, 4.7) == node.location());
    REQUIRE(std::string("testuser") == node.user());

    for (osmium::memory::Item& item : node) {
        REQUIRE(osmium::item_type::tag_list == item.type());
    }

    REQUIRE(!node.tags().empty());
    REQUIRE(2 == std::distance(node.tags().begin(), node.tags().end()));

    int n = 0;
    for (const osmium::Tag& tag : node.tags()) {
        switch (n) {
            case 0:
                REQUIRE(std::string("amenity") == tag.key());
                REQUIRE(std::string("bank") == tag.value());
                break;
            case 1:
                REQUIRE(std::string("name") == tag.key());
                REQUIRE(std::string("OSM Savings") == tag.value());
                break;
        }
        ++n;
    }
    REQUIRE(2 == n);
}
Exemplo n.º 8
0
 point_type create_point(const osmium::Node& node) {
     try {
         return create_point(node.location());
     } catch (osmium::geometry_error& e) {
         e.set_id("node", node.id());
         throw;
     }
 }
Exemplo n.º 9
0
 void node(const osmium::Node& node) {
     // Getting a tag value can be expensive, because a list of tags has
     // to be gone through and each tag has to be checked. So we store the
     // result and reuse it.
     const char* amenity = node.tags()["amenity"];
     if (amenity) {
         print_amenity(amenity, node.tags()["name"], node.location());
     }
 }
Exemplo n.º 10
0
/** warning: caller needs to take care of synchronization! */
void ExtractorCallbacks::ProcessNode(const osmium::Node &input_node,
                                     const ExtractionNode &result_node)
{
    external_memory.all_nodes_list.push_back(
        {static_cast<int>(input_node.location().lat() * COORDINATE_PRECISION),
         static_cast<int>(input_node.location().lon() * COORDINATE_PRECISION),
         static_cast<NodeID>(input_node.id()),
         result_node.barrier,
         result_node.traffic_lights});
}
Exemplo n.º 11
0
 void node(const osmium::Node& node) {
     try {
         add_location(m_old_index.get(node.id()));
     } catch (...) {
     }
     try {
         add_location(node.location());
     } catch (...) {
     }
 }
Exemplo n.º 12
0
 void node(const osmium::Node& node) {
     int x = in_range(0, static_cast<int>((180 + node.location().lon()) * m_factor), m_xsize - 1);
     int y = in_range(0, static_cast<int>(( 90 - node.location().lat()) * m_factor), m_ysize - 1);
     int n = y * m_xsize + x;
     if (m_node_count[n] < std::numeric_limits<node_count_type>::max() - 1) {
         ++m_node_count[n];
     }
     if (m_node_count[n] > m_max_count) {
         m_max_count = m_node_count[n];
     }
 }
Exemplo n.º 13
0
int output_pgsql_t::node_add(osmium::Node const &node)
{
    taglist_t outtags;
    if (m_tagtransform->filter_tags(node, nullptr, nullptr, outtags))
        return 1;

    auto wkb = m_builder.get_wkb_node(node.location());
    expire.from_wkb(wkb.c_str(), node.id());
    m_tables[t_point]->write_row(node.id(), outtags, wkb);

    return 0;
}
Exemplo n.º 14
0
int osmdata_t::node_add(osmium::Node const &node)
{
    auto c = projection->reproject(node.location());

    mid->nodes_set(node, c.y, c.x);

    // guarantee that we use the same values as in the node cache
    ramNode n(c.x, c.y);

    int status = 0;
    for (auto& out: outs) {
        status |= out->node_add(node, n.lat(), n.lon());
    }
    return status;
}
Exemplo n.º 15
0
            void print_location(const osmium::Node& node) {
                const osmium::Location& location = node.location();

                m_out << m_prefix
                      << "  lon="
                      << std::fixed
                      << std::setprecision(7)
                      << location.lon()
                      << "\n";
                m_out << m_prefix
                      << "  lat="
                      << std::fixed
                      << std::setprecision(7)
                      << location.lat()
                      << "\n";
            }
Exemplo n.º 16
0
void check_node_1(osmium::Node& node) {
    REQUIRE(1 == node.id());
    REQUIRE(3 == node.version());
    REQUIRE(true == node.visible());
    REQUIRE(333 == node.changeset());
    REQUIRE(21 == node.uid());
    REQUIRE(123 == node.timestamp());
    REQUIRE(osmium::Location(3.5, 4.7) == node.location());
    REQUIRE(std::string("testuser") == node.user());

    for (osmium::memory::Item& item : node) {
        REQUIRE(osmium::item_type::tag_list == item.type());
    }

    REQUIRE(node.tags().begin() == node.tags().end());
    REQUIRE(node.tags().empty());
    REQUIRE(0 == std::distance(node.tags().begin(), node.tags().end()));
}
Exemplo n.º 17
0
void check_node_1(osmium::Node& node) {
    BOOST_CHECK_EQUAL(1, node.id());
    BOOST_CHECK_EQUAL(3, node.version());
    BOOST_CHECK_EQUAL(true, node.visible());
    BOOST_CHECK_EQUAL(333, node.changeset());
    BOOST_CHECK_EQUAL(21, node.uid());
    BOOST_CHECK_EQUAL(123, node.timestamp());
    BOOST_CHECK_EQUAL(osmium::Location(3.5, 4.7), node.location());
    BOOST_CHECK_EQUAL("testuser", node.user());

    for (osmium::memory::Item& item : node) {
        BOOST_CHECK_EQUAL(osmium::item_type::tag_list, item.type());
    }

    BOOST_CHECK_EQUAL(node.tags().begin(), node.tags().end());
    BOOST_CHECK(node.tags().empty());
    BOOST_CHECK_EQUAL(0, std::distance(node.tags().begin(), node.tags().end()));
}
Exemplo n.º 18
0
    bool contains(const osmium::Node& node) {
        const osmium::Location& location = node.location();

        if (!location.valid() || !bounds.contains(location)) {
            return false;
        }

        if (!locator) {
            return true;
        }

        // BOUNDARY 1
        // EXTERIOR 2
        // INTERIOR 0
        geos::geom::Coordinate c{location.lon_without_check(),
                                 location.lat_without_check()};

        return locator->locate(&c) <= 1;
    }
Exemplo n.º 19
0
int osmdata_t::node_modify(osmium::Node const &node)
{
    auto c = projection->reproject(node.location());

    slim_middle_t *slim = dynamic_cast<slim_middle_t *>(mid.get());

    slim->nodes_delete(node.id());
    slim->nodes_set(node, c.y, c.x);

    // guarantee that we use the same values as in the node cache
    ramNode n(c.x, c.y);

    int status = 0;
    for (auto& out: outs) {
        status |= out->node_modify(node, n.lat(), n.lon());
    }

    slim->node_changed(node.id());

    return status;
}
Exemplo n.º 20
0
            void print_location(const osmium::Node& node) {
                const osmium::Location& location = node.location();

                if (location) {
                    *m_out << m_prefix
                           << "  lon="
                           << std::fixed
                           << std::setprecision(7)
                           << location.lon_without_check()
                           << "\n";
                    *m_out << m_prefix
                           << "  lat="
                           << location.lat_without_check()
                           << "\n";
                } else {
                    *m_out << m_prefix
                           << "  lon=\n"
                           << m_prefix
                           << "  lat=\n";
                }
            }
Exemplo n.º 21
0
    // The node handler is called for each node in the input data.
    void node(const osmium::Node& node) {
        // Open a new scope, because the NodeBuilder we are creating has to
        // be destructed, before we can call commit() below.
        {
            // To create a node, we need a NodeBuilder object. It will create
            // the node in the given buffer.
            osmium::builder::NodeBuilder builder{m_buffer};

            // Copy common object attributes over to the new node.
            copy_attributes(builder, node);

            // Copy the location over to the new node.
            builder.set_location(node.location());

            // Copy (changed) tags.
            copy_tags(builder, node.tags());
        }

        // Once the object is written to the buffer completely, we have to call
        // commit().
        m_buffer.commit();
    }
Exemplo n.º 22
0
 void enode(extract_data& e, const osmium::Node& node) {
     if (e.contains(node.location())) {
         e.node_ids.set(node.positive_id());
     }
 }
Exemplo n.º 23
0
 void update(const osmium::Node& node) {
     update(static_cast<const osmium::OSMObject&>(node));
     update(node.location());
 }
Exemplo n.º 24
0
csomopont_adat(osmium::Node& node){
	id=node.id();
	loc=node.location();
}
Exemplo n.º 25
0
 void node(const osmium::Node& node) {
     *m_out += 'n';
     write_meta(node);
     write_location(node.location(), 'x', 'y');
     *m_out += '\n';
 }
Exemplo n.º 26
0
 point_type create_point(const osmium::Node& node) {
     return create_point(node.location());
 }
 /**
  * Store the location of the node in the storage.
  */
 void node(const osmium::Node& node) {
     m_must_sort = true;
     const osmium::object_id_type id = node.id();
     if (id >= 0) {
         m_storage_pos.set(static_cast<osmium::unsigned_object_id_type>( id), node.location());
     } else {
         m_storage_neg.set(static_cast<osmium::unsigned_object_id_type>(-id), node.location());
     }
 }
Exemplo n.º 28
0
 void node(const osmium::Node& node) {
     hash.Update(node.data(), node.byte_size());
     bounds.extend(node.location());
     ++nodes;
 }
Exemplo n.º 29
0
void middle_ram_t::nodes_set(osmium::Node const &node)
{
    cache->set(node.id(), node.location());
}