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 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); }
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 node( osmium::Node& node ) { const char* value= node.tags().get_value_by_key("highway"); const char* name = node.tags().get_value_by_key("name"); if(name && value && !strcmp(value, "bus_stop")){ map[node.positive_id()] = name; } }
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()); } }
void node(const osmium::Node& node) { const char* amenity = node.tags().get_value_by_key("amenity"); if (amenity && !strcmp(amenity, "pub")) { const char* name = node.tags().get_value_by_key("name"); if (name) { std::cout << name << std::endl; } } }
void node(osmium::Node& node) { const char* type = node.tags()["highway"]; if(type) if (!strcmp(type, "bus_stop")) { const char* name = node.tags()["name"]; if (name) { nodes[node.id()] = name; } } }
void middle_pgsql_t::local_nodes_set(osmium::Node const &node, double lat, double lon) { copy_buffer.reserve(node.tags().byte_size() + 100); bool copy = node_table->copyMode; char delim = copy ? '\t' : '\0'; const char *paramValues[4] = { copy_buffer.c_str(), }; copy_buffer = std::to_string(node.id()); copy_buffer += delim; #ifdef FIXED_POINT ramNode n(lon, lat); paramValues[1] = paramValues[0] + copy_buffer.size(); copy_buffer += std::to_string(n.int_lat()); copy_buffer += delim; paramValues[2] = paramValues[0] + copy_buffer.size(); copy_buffer += std::to_string(n.int_lon()); copy_buffer += delim; #else paramValues[1] = paramValues[0] + copy_buffer.size(); copy_buffer += std::to_string(lat); copy_buffer += delim; paramValues[2] = paramValues[0] + copy_buffer.size(); copy_buffer += std::to_string(lon); copy_buffer += delim; #endif if (node.tags().empty() && !out_options->extra_attributes) { paramValues[3] = nullptr; copy_buffer += "\\N"; } else { paramValues[3] = paramValues[0] + copy_buffer.size(); buffer_store_tags(node, out_options->extra_attributes, copy); } if (copy) { copy_buffer += '\n'; pgsql_CopyData(__FUNCTION__, node_table->sql_conn, copy_buffer); } else { buffer_correct_params(paramValues, 4); pgsql_execPrepared(node_table->sql_conn, "insert_node", 4, (const char * const *)paramValues, PGRES_COMMAND_OK); } }
void node(const osmium::Node& node) { if (m_cfg.add_untagged_nodes || !node.tags().empty()) { gdalcpp::Feature feature{m_layer_point, m_factory.create_point(node)}; feature.set_field("id", double(node.id())); add_feature(feature, node); } }
void node(const osmium::Node& node) { const char* label = node.tags().get_value_by_key("label"); if (label) { OGRFeature* feature = OGRFeature::CreateFeature(m_layer_labels->GetLayerDefn()); std::unique_ptr<OGRPoint> ogr_point = m_factory.create_point(node); feature->SetGeometry(ogr_point.get()); feature->SetField("id", static_cast<double>(node.id())); feature->SetField("label", label); if (m_layer_labels->CreateFeature(feature) != OGRERR_NONE) { std::cerr << "Failed to create feature.\n"; exit(1); } OGRFeature::DestroyFeature(feature); } else { OGRFeature* feature = OGRFeature::CreateFeature(m_layer_nodes->GetLayerDefn()); std::unique_ptr<OGRPoint> ogr_point = m_factory.create_point(node); feature->SetGeometry(ogr_point.get()); feature->SetField("id", static_cast<double>(node.id())); if (m_layer_nodes->CreateFeature(feature) != OGRERR_NONE) { std::cerr << "Failed to create feature.\n"; exit(1); } OGRFeature::DestroyFeature(feature); } }
void node(const osmium::Node& node) { const char* amenity = node.tags()["amenity"]; if (amenity && !strcmp(amenity, "post_box")) { OGRFeature* feature = OGRFeature::CreateFeature(m_layer_point->GetLayerDefn()); std::unique_ptr<OGRPoint> ogr_point = m_factory.create_point(node); feature->SetGeometry(ogr_point.get()); feature->SetField("id", static_cast<double>(node.id())); feature->SetField("operator", node.tags()["operator"]); if (m_layer_point->CreateFeature(feature) != OGRERR_NONE) { std::cerr << "Failed to create feature.\n"; exit(1); } OGRFeature::DestroyFeature(feature); } }
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())); }
// 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 node(const osmium::Node& node) { const char *hno = node.tags().get_value_by_key("addr:housenumber"); if (hno) { housenumberMap[node.id()] = atoi(hno); numbers_nodes_overall ++; if (node.tags().get_value_by_key("addr:street")) numbers_nodes_withstreet ++; if (node.tags().get_value_by_key("addr:city")) numbers_nodes_withcity ++; if (node.tags().get_value_by_key("addr:country")) numbers_nodes_withcountry ++; if (node.tags().get_value_by_key("addr:postcode")) { numbers_nodes_withpostcode ++; postcode[node.tags().get_value_by_key("addr:postcode")] = true; } } }