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

                    write_prefix();
                    m_out += "<relation";
                    write_meta(relation);

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

                    m_out += ">\n";

                    for (const auto& member : relation.members()) {
                        write_prefix();
                        m_out += "  <member type=\"";
                        m_out += item_type_to_name(member.type());
                        oprintf(m_out, "\" ref=\"%" PRId64 "\" role=\"", member.ref());
                        xml_string(m_out, member.role());
                        m_out += "\"/>\n";
                    }

                    write_tags(relation.tags());

                    write_prefix();
                    m_out += "</relation>\n";
                }
    // - walk over all relations-versions
    //   - walk over all relations-nodes
    //     - Adds the nodes and ways that aren't in node-tracker to a vector
    //     - if node or way is in the box hit becames true
    //   - if hit is true and the vector is not empty (it means their are nodes or ways that belong to a relation that has at least one node or way inside the box)
    //     - Records the id of node or way to outside_node_tracker or outside_way_tracker
    void relation(const osmium::Relation& relation) {
	
    	bool hit = false;

        if (debug) {
            std::cerr << "cut_administrative relation " << relation.id() << " v" << relation.version() << "\n";
        }
    	
        std::vector<const osmium::RelationMember*> members;
        std::vector<const osmium::TagList*> tags;

        for (auto& tag : relation.tags()) {
            if (strcmp(tag.key(), "boundary") == 0 && strcmp(tag.value(), "administrative") == 0)
                hit = true;
        }

    	for (const auto& extract : info->extracts) {
            if (hit){
                if(!extract->relation_tracker.get(relation.id())){
                    extract->relation_tracker.set(relation.id());
                }
                //Add only the nodes and ways that were not yet in the respective trackers if hit is true
                for (const auto& member : relation.members()) {
                    if (member.type() == osmium::item_type::way && !extract->way_tracker.get(member.ref())){
                            extract->way_tracker.set(member.ref());
                    } 
                }
            }
        }
    }
Exemplo n.º 3
0
    // - walk over all relation-versions
    //   - walk over all bboxes
    //     - if the relation-id is recorded in the bboxes relation-tracker
    //       - send the relation to the bboxes writer
    void relation(const osmium::Relation& relation) {
        if (debug) {
            std::cerr << "softcut relation " << relation.positive_id() << " v" << relation.version() << "\n";
        }

        for (const auto& extract : info->extracts) {
            if (extract->relation_tracker.get(relation.positive_id())) {
                extract->write(relation);
            }
        }
    }
 void relation(const osmium::Relation& rel) {
     ++rels;
     if (!matches_user_filter(rel)) return;
     ++urels;
     if (rel.visible()==false) {
         m_relfile <<
             rel.id() << "\t" <<
             rel.version() << "\t" <<
             rel.changeset() << "\t" <<
             rel.timestamp().to_iso() << "\t" <<
             rel.uid() << std::endl;
     }
 }
Exemplo n.º 5
0
    // - walk over all relation-versions
    //   - walk over all bboxes
    //     - walk over all relation-members
    //       - if the relation-member is recorded in the bboxes node- or way-tracker
    //         - record its id in the bboxes relation-tracker
    void relation(const osmium::Relation& relation) {
        if (first_relation) {
            write_way_extra_nodes();
            first_relation = false;
        }

        if (debug) {
            std::cerr << "softcut relation " << relation.positive_id() << " v" << relation.version() << "\n";
        }

        for (const auto& extract : info->extracts) {
            bool hit = false;

            for (const auto& member : relation.members()) {

                if (!hit && (
                    (member.type() == osmium::item_type::node && extract->node_tracker.get(member.positive_ref())) ||
                    (member.type() == osmium::item_type::way && extract->way_tracker.get(member.positive_ref())) ||
                    (member.type() == osmium::item_type::relation && extract->relation_tracker.get(member.positive_ref()))
                )) {

                    if (debug) std::cerr << "relation has a member (" << member.type() << " " << member.positive_ref() << ") inside extract, recording in relation_tracker\n";
                    hit = true;

                    extract->relation_tracker.set(relation.positive_id());
                }

                if (member.type() == osmium::item_type::relation) {
                    if (debug) {
                        std::cerr << "recording cascading-pair: " << member.positive_ref() << " -> " << relation.positive_id() << "\n";
                    }
                    info->cascading_relations_tracker.insert(std::make_pair(member.positive_ref(), relation.positive_id()));
                }
            }

            if (hit) {
                cascading_relations(extract, relation.positive_id());
            }
        }
    }