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"; }
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()); } } }
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; }
/** * 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}); }
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"); } }
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); }
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); }
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; } }
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()); } }
/** 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}); }
void node(const osmium::Node& node) { try { add_location(m_old_index.get(node.id())); } catch (...) { } try { add_location(node.location()); } catch (...) { } }
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]; } }
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; }
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; }
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"; }
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())); }
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())); }
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; }
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; }
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"; } }
// 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(); }
void enode(extract_data& e, const osmium::Node& node) { if (e.contains(node.location())) { e.node_ids.set(node.positive_id()); } }
void update(const osmium::Node& node) { update(static_cast<const osmium::OSMObject&>(node)); update(node.location()); }
csomopont_adat(osmium::Node& node){ id=node.id(); loc=node.location(); }
void node(const osmium::Node& node) { *m_out += 'n'; write_meta(node); write_location(node.location(), 'x', 'y'); *m_out += '\n'; }
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()); } }
void node(const osmium::Node& node) { hash.Update(node.data(), node.byte_size()); bounds.extend(node.location()); ++nodes; }
void middle_ram_t::nodes_set(osmium::Node const &node) { cache->set(node.id(), node.location()); }