Exemplo n.º 1
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.º 2
0
    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);
        }
    }
 // - walk over all node-versions
 //   - walk over all bboxes
 //     - if the node-id is recorded in the bboxes node-trackers
 //       - send the node to the bboxes writer
 void node(const osmium::Node& node) {
     if (debug) {
         std::cerr << "cut_administrative node " << node.id() << " v" << node.version() << "\n";
     }
     for (const auto& extract : info->extracts) {
         if (extract->node_tracker.get(node.id())){
             extract->write(node);
         }
     }
 }
Exemplo n.º 4
0
void middle_pgsql_t::nodes_set(osmium::Node const &node, double lat, double lon)
{
    cache->set(node.id(), lat, lon);

    if (out_options->flat_node_cache_enabled) {
        persistent_cache->set(node.id(), lat, lon);
    } else {
        local_nodes_set(node, lat, lon);
    }
}
Exemplo n.º 5
0
        void node(const osmium::Node& node) {
            if (m_max_way_id > 0) {
                throw std::runtime_error("Found a node after a way.");
            }
            if (m_max_relation_id > 0) {
                throw std::runtime_error("Found a node after a relation.");
            }

            if (m_max_node_id >= node.id()) {
                throw std::runtime_error("Node IDs out of order.");
            }
            m_max_node_id = node.id();
        }
Exemplo n.º 6
0
    // - walk over all node-versions
    //   - walk over all bboxes
    //     - if the current node-version is inside the bbox
    //       - record its id in the bboxes node-tracker
    void node(const osmium::Node& node) {
        if (debug) {
            std::cerr << "softcut node " << node.id() << " v" << node.version() << "\n";
        }

        for (const auto& extract : info->extracts) {
            if (extract->contains(node)) {
                if (debug) std::cerr << "node is in extract, recording in node_tracker\n";

                extract->node_tracker.set(node.id());
            }
        }
    }
Exemplo n.º 7
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.º 8
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.º 9
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.º 10
0
int osmdata_t::node_modify(osmium::Node const &node)
{
    slim_middle_t *slim = dynamic_cast<slim_middle_t *>(mid.get());

    slim->nodes_delete(node.id());
    slim->nodes_set(node);

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

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

    return status;
}
 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);
     }
 }
Exemplo n.º 12
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;
     }
 }
 /**
  * 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.º 14
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.º 15
0
/* Modify is slightly trickier. The basic idea is we simply delete the
 * object and create it with the new parameters. Then we need to mark the
 * objects that depend on this one */
int output_pgsql_t::node_modify(osmium::Node const &node)
{
    if (!m_options.slim) {
        fprintf(stderr, "Cannot apply diffs unless in slim mode\n");
        util::exit_nicely();
    }
    node_delete(node.id());
    node_add(node);
    return 0;
}
Exemplo n.º 16
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.º 17
0
 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;
         }
     }
 }
Exemplo n.º 18
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.º 19
0
    void node(const osmium::Node& node) {
        m_check_order.node(node);

        if (m_node_count == 0) {
            m_progress_bar.remove();
            m_vout << "Reading nodes...\n";
        }
        ++m_node_count;

        set(osmium::item_type::node, node.id());
    }
Exemplo n.º 20
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.º 21
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;
}
 void node(const osmium::Node& node) {
     ++nodes;
     if (!matches_user_filter(node)) return;
     ++unodes;
     if (node.visible()==false) {
         m_nodefile <<
             node.id() << "\t" <<
             node.version() << "\t" <<
             node.changeset() << "\t" <<
             node.timestamp().to_iso() << "\t" <<
             node.uid() << std::endl;
     }
 }
Exemplo n.º 23
0
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);
    }
}
Exemplo n.º 24
0
    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);
        }
    }
Exemplo n.º 25
0
 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;
         }
     }
 }
Exemplo n.º 26
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.º 27
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.º 28
0
            void node(const osmium::Node& node) {
                if (m_max_way_id > std::numeric_limits<osmium::object_id_type>::min()) {
                    throw out_of_order_error{"Found a node after a way.", node.id()};
                }
                if (m_max_relation_id > std::numeric_limits<osmium::object_id_type>::min()) {
                    throw out_of_order_error{"Found a node after a relation.", node.id()};
                }

                if (m_max_node_id == node.id()) {
                    throw out_of_order_error{"Node ID twice in input. Maybe you are using a history or change file?", node.id()};
                }
                if (id_order{}(node.id(), m_max_node_id)) {
                    throw out_of_order_error{"Node IDs out of order.", node.id()};
                }
                m_max_node_id = node.id();
            }
Exemplo n.º 29
0
csomopont_adat(osmium::Node& node){
	id=node.id();
	loc=node.location();
}
Exemplo n.º 30
0
void middle_ram_t::nodes_set(osmium::Node const &node)
{
    cache->set(node.id(), node.location());
}