Example #1
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);
        }
    }
 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);
     }
 }
Example #3
0
	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;
		}
		
	}
Example #4
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;
     }
 }
Example #5
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;
 }
 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());
     }
 }
Example #7
0
 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(const osmium::Node& node) {
     try {
         add_location(m_old_index.get(node.id()));
     } catch (...) {
     }
     try {
         add_location(node.location());
     } catch (...) {
     }
 }
 // - 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);
         }
     }
 }
Example #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});
}
/**
 * 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});
}
Example #12
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);
    }
}
 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;
         }
     }
 }
Example #14
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;
}
Example #15
0
    // - walk over all node-versions
    //   - walk over all bboxes
    //     - if the node-id is recorded in the bboxes node-tracker or in the extra-node-tracker
    //       - send the node to the bboxes writer
    void node(const osmium::Node& node) {
        if (debug) {
            std::cerr << "softcut node " << node.positive_id() << " v" << node.version() << "\n";
        }

        for (const auto& extract : info->extracts) {
            if (extract->node_tracker.get(node.positive_id()) ||
                extract->extra_node_tracker.get(node.positive_id())) {
                extract->write(node);
            }
        }
    }
Example #16
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.positive_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.positive_id());
            }
        }
    }
Example #17
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();
        }
            /**
             * Store the location of the node in the storage.
             */
            void node(const osmium::Node& node) {
                if (node.positive_id() < m_last_id) {
                    m_must_sort = true;
                }
                m_last_id = node.positive_id();

                const auto 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());
                }
            }
Example #19
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);
    }
}
Example #20
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;
}
Example #21
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);
        }
    }
Example #22
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());
        }
    }
}
                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";
                }
Example #24
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;
}
Example #25
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];
     }
 }
    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());
    }
Example #27
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;
}
    // 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();
    }
Example #29
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;
}
Example #30
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";
            }