当前位置: 首页>>代码示例>>C++>>正文


C++ Relation::tags方法代码示例

本文整理汇总了C++中osmium::Relation::tags方法的典型用法代码示例。如果您正苦于以下问题:C++ Relation::tags方法的具体用法?C++ Relation::tags怎么用?C++ Relation::tags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在osmium::Relation的用法示例。


在下文中一共展示了Relation::tags方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: relation

	void relation( osmium::Relation& relation ) {
		const char* bus = relation.tags()["route"];
		if(bus && !strcmp(bus, "bus")) {
			const char* name = relation.tags().get_value_by_key("ref");
			if(!name) name = relation.tags().get_value_by_key("name");
			
			std::cout << name;
			
			osmium::unsigned_object_id_type temp1, temp2;
			int db = 0;
			for( auto &member : relation.members()){
				if(db == 0 && member.type() == osmium::item_type::node) {
					temp1 = member.positive_ref();
					db++;
				} else if(db !=0 && member.type() == osmium::item_type::node){
					temp2 = member.positive_ref();
				}				
			}
			
			std::cout << " (" << map[temp1] << " - " << map[temp2] << ")" << std::endl;
			
			for ( auto &member : relation.members()) {
				if( member.type() == osmium::item_type::node){
					std::cout << " " << locations.get(member.positive_ref()).lat() << ", " << locations.get(member.positive_ref()).lon() << " " << map[member.positive_ref()] << std::endl;
				}
				
			}
			std::cout << std::endl;
		}
	}
开发者ID:djjoe,项目名称:University-projects,代码行数:30,代码来源:malvin.cpp

示例2: create_area

            bool create_area(osmium::memory::Buffer& out_buffer, const osmium::Relation& relation, const std::vector<const osmium::Way*>& members) {
                set_num_members(members.size());
                osmium::builder::AreaBuilder builder{out_buffer};
                builder.initialize_from_object(relation);

                const bool area_okay = create_rings();
                if (area_okay || config().create_empty_areas) {
                    if (config().keep_type_tag) {
                        builder.add_item(relation.tags());
                    } else {
                        copy_tags_without_type(builder, relation.tags());
                    }
                }
                if (area_okay) {
                    add_rings_to_area(builder);
                }

                if (report_ways()) {
                    for (const osmium::Way* way : members) {
                        config().problem_reporter->report_way(*way);
                    }
                }

                return area_okay || config().create_empty_areas;
            }
开发者ID:Project-OSRM,项目名称:osrm-backend,代码行数:25,代码来源:assembler.hpp

示例3: relation

    void relation(osmium::Relation& rel) {
        const char* bus = rel.tags() ["route"];
        if (bus && !strcmp(bus, "bus")) {
            const char* busRef = rel.tags()["ref"];
            if (busRef) {
                buses.push_back(Bus(busRef, id));
                id++;

                osmium::RelationMemberList& rml = rel.members();
                for (osmium::RelationMember& rm : rml) {
                    if (rm.type() == osmium::item_type::way) {
                        std::vector<osmium::Location> tmpVec;
                        for (auto& nd : ways[rm.ref()]) {
                            osmium::Location loc = locations.get(nd);
                            tmpVec.push_back(loc);
                        }
                        buses.at(id - 1).locs.push_back(tmpVec);
                    } else if(rm.type() == osmium::item_type::node && 
                                !strcmp(rm.role(), "stop")) {
                        buses.at(id - 1).busStopNames[rm.ref()] = nodes[rm.ref()];
                    }
                }
            }
        }
    }
开发者ID:harpbold,项目名称:prog2vedes4_fp_hpba,代码行数:25,代码来源:malvin_details.cpp

示例4: relation

                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";
                }
开发者ID:Gozhack,项目名称:osrm-backend,代码行数:30,代码来源:xml_output_format.hpp

示例5: relation

 void relation(const osmium::Relation& rel)
 {
     const char *bdy = rel.tags().get_value_by_key("boundary");
     if (bdy && !strcmp(bdy, "postal_code")) 
     {
         postcode_boundaries++;
         const char *ref = rel.tags().get_value_by_key("ref");
         if (ref) postcode[ref]=true;
     }
 }
开发者ID:woodpeck,项目名称:osmium_based_utils,代码行数:10,代码来源:count_addresses.cpp

示例6: relation

    // - 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());
                    } 
                }
            }
        }
    }
开发者ID:NDrive,项目名称:osm-history-splitter,代码行数:36,代码来源:cut_administrative.hpp

示例7: relation

     void relation ( osmium::Relation& rel ) {
          const char* bus = rel.tags() ["route"];
          const char* nev;
          if ( bus && !strcmp ( bus, "bus" ) ) {
               if( rel.tags()["name"])
               {
                    nev = rel.tags()["name"];
               }
               else
               {
                    nev = rel.tags()["ref"];
               }
               ++stops;
               //TODO asdasd


               int i {1};
               osmium::RelationMemberList& rml = rel.members();
               int szam=0;
               for ( osmium::RelationMember& rm : rml ) {
                    i = 1;
                    if (rm.type() == osmium::item_type::way ) {

                         for( auto it : way_node_map[rm.ref()] )
                         {
                              try {
                                   osmium::Location loc = locations.get ( it );

                                   if ( i++>1 ) {
                                        osmium::geom::Coordinates coords {loc};
                                        szam++;
                                        printf("%.8f %.8f\n",double(coords.y),double(coords.x) );

                                   }
                              } catch ( std::exception& e ) {
                                   std::cout << "No such node on the map. "<< e.what() << std::endl;
                              }
                         }
                    std::cout << "way\n";
                    }
               }
               //std::cout << "way\n";
               std::cout << nev << " busz\n";
          }

     }
开发者ID:szabob94,项目名称:vedes4,代码行数:46,代码来源:bus-stops.cpp

示例8: relation

    // The relation handler is called for each node in the input data.
    void relation(const osmium::Relation& relation) {
        {
            osmium::builder::RelationBuilder builder{m_buffer};
            copy_attributes(builder, relation);
            copy_tags(builder, relation.tags());

            // Copy the relation member list over to the new way.
            builder.add_item(relation.members());
        }
        m_buffer.commit();
    }
开发者ID:hydrays,项目名称:osrm-backend,代码行数:12,代码来源:osmium_change_tags.cpp

示例9: relation

  void relation ( osmium::Relation& rel )
  {

    ++nOSM_relations;

    const char* bus = rel.tags() ["route"];
    if ( bus && !strcmp ( bus, "bus" ) )
      {

        ++nbuses;

        std::string ref_key;

        try
          {
            const char* ref = rel.tags() ["ref"];
            if ( ref )
              ref_key.append ( ref );
            else
              ref_key.append ( "Not specified" );

          }
        catch ( std::exception& e )
          {
            std::cout << "There is no bus number."<< e.what() << std::endl;
          }

        osmium::RelationMemberList& rml = rel.members();
        for ( osmium::RelationMember& rm : rml )
          {

            if ( rm.type() == osmium::item_type::way )
              {

                busWayNodesMap[ref_key].push_back ( rm.ref() );

              }
          }

      }
  }
开发者ID:halopeter,项目名称:robocar-emulator,代码行数:41,代码来源:osmreader.hpp

示例10: keep_relation

            /**
             * We are interested in all relations tagged with type=multipolygon
             * or type=boundary.
             *
             * Overwritten from the base class.
             */
            bool keep_relation(const osmium::Relation& relation) const {
                const char* type = relation.tags().get_value_by_key("type");

                // ignore relations without "type" tag
                if (!type) {
                    return false;
                }

                if ((!strcmp(type, "multipolygon")) || (!strcmp(type, "boundary"))) {
                    return true;
                }

                return false;
            }
开发者ID:dforsi,项目名称:libosmium,代码行数:20,代码来源:multipolygon_collector.hpp

示例11: new_relation

            /**
             * We are interested in all relations tagged with type=multipolygon
             * or type=boundary with at least one way member.
             */
            bool new_relation(const osmium::Relation& relation) const {
                const char* type = relation.tags().get_value_by_key("type");

                // ignore relations without "type" tag
                if (!type) {
                    return false;
                }

                if ((!std::strcmp(type, "multipolygon")) || (!std::strcmp(type, "boundary"))) {
                    return std::any_of(relation.members().cbegin(), relation.members().cend(), [](const RelationMember& member) {
                        return member.type() == osmium::item_type::way;
                    });
                }

                return false;
            }
开发者ID:tomhughes,项目名称:libosmium,代码行数:20,代码来源:multipolygon_manager_legacy.hpp

示例12: relation_add

int output_pgsql_t::relation_add(osmium::Relation const &rel)
{
    char const *type = rel.tags()["type"];

    /* Must have a type field or we ignore it */
    if (!type)
        return 0;

    /* Only a limited subset of type= is supported, ignore other */
    if (strcmp(type, "route") != 0 && strcmp(type, "multipolygon") != 0
        && strcmp(type, "boundary") != 0) {
        return 0;
    }

    return pgsql_process_relation(rel);
}
开发者ID:openstreetmap,项目名称:osm2pgsql,代码行数:16,代码来源:output-pgsql.cpp

示例13: relation

            void relation(const osmium::Relation& relation) {
                m_out << "r";
                write_meta(relation);

                m_out << " M";
                int n=0;
                for (const auto& member : relation.members()) {
                    if (n++ != 0) {
                        m_out << ",";
                    }
                    m_out << item_type_to_char(member.type())
                          << member.ref()
                          << "!"
                          << member.role();
                }

                write_tags(relation.tags());
                m_out << "\n";
                ::write(this->fd(), m_out.str().c_str(), m_out.str().size());
                m_out.str("");
            }
开发者ID:jokoala,项目名称:libosmium,代码行数:21,代码来源:opl_output.hpp

示例14: if

/**
 * Tries to parse a relation as a turn restriction. This can fail for a number of
 * reasons. The return type is a boost::optional<T>.
 *
 * Some restrictions can also be ignored: See the ```get_restrictions``` function
 * in the corresponding profile. We use it for both namespacing restrictions, as in
 * restriction:motorcar as well as whitelisting if its in except:motorcar.
 */
std::vector<InputRestrictionContainer>
RestrictionParser::TryParse(const osmium::Relation &relation) const
{
    std::vector<InputRestrictionContainer> parsed_restrictions;
    // return if turn restrictions should be ignored
    if (!use_turn_restrictions)
    {
        return {};
    }

    osmium::tags::KeyFilter filter(false);
    filter.add(true, "restriction");
    if (parse_conditionals)
    {
        filter.add(true, "restriction:conditional");
        for (const auto &namespaced : restrictions)
        {
            filter.add(true, "restriction:" + namespaced + ":conditional");
        }
    }

    // Not only use restriction= but also e.g. restriction:motorcar=
    // Include restriction:{mode}:conditional if flagged
    for (const auto &namespaced : restrictions)
    {
        filter.add(true, "restriction:" + namespaced);
    }

    const osmium::TagList &tag_list = relation.tags();

    osmium::tags::KeyFilter::iterator fi_begin(filter, tag_list.begin(), tag_list.end());
    osmium::tags::KeyFilter::iterator fi_end(filter, tag_list.end(), tag_list.end());

    // if it's not a restriction, continue;
    if (std::distance(fi_begin, fi_end) == 0)
    {
        return {};
    }

    // check if the restriction should be ignored
    const char *except = relation.get_value_by_key("except");
    if (except != nullptr && ShouldIgnoreRestriction(except))
    {
        return {};
    }

    bool is_only_restriction = false;

    for (; fi_begin != fi_end; ++fi_begin)
    {
        const std::string key(fi_begin->key());
        const std::string value(fi_begin->value());

        // documented OSM restriction tags start either with only_* or no_*;
        // check and return on these values, and ignore unrecognized values
        if (value.find("only_") == 0)
        {
            is_only_restriction = true;
        }
        else if (value.find("no_") == 0)
        {
            is_only_restriction = false;
        }
        else // unrecognized value type
        {
            return {};
        }
    }

    InputRestrictionContainer restriction_container(is_only_restriction);

    for (const auto &member : relation.members())
    {
        const char *role = member.role();
        if (strcmp("from", role) != 0 && strcmp("to", role) != 0 && strcmp("via", role) != 0)
        {
            continue;
        }

        switch (member.type())
        {
        case osmium::item_type::node:
            // Make sure nodes appear only in the role if a via node
            if (0 == strcmp("from", role) || 0 == strcmp("to", role))
            {
                continue;
            }
            BOOST_ASSERT(0 == strcmp("via", role));

            // set via node id
            restriction_container.restriction.via.node = member.ref();
            break;
//.........这里部分代码省略.........
开发者ID:yiqingj,项目名称:osrm-backend,代码行数:101,代码来源:restriction_parser.cpp

示例15: if

/**
 * Tries to parse a relation as a turn restriction. This can fail for a number of
 * reasons. The return type is a boost::optional<T>.
 *
 * Some restrictions can also be ignored: See the ```get_restrictions``` function
 * in the corresponding profile. We use it for both namespacing restrictions, as in
 * restriction:motorcar as well as whitelisting if its in except:motorcar.
 */
boost::optional<InputRestrictionContainer>
RestrictionParser::TryParse(const osmium::Relation &relation) const
{
    // return if turn restrictions should be ignored
    if (!use_turn_restrictions)
    {
        return {};
    }

    osmium::tags::KeyFilter filter(false);
    filter.add(true, "restriction");

    // Not only use restriction= but also e.g. restriction:motorcar=
    for (const auto &namespaced : restrictions)
        filter.add(true, "restriction:" + namespaced);

    const osmium::TagList &tag_list = relation.tags();

    osmium::tags::KeyFilter::iterator fi_begin(filter, tag_list.begin(), tag_list.end());
    osmium::tags::KeyFilter::iterator fi_end(filter, tag_list.end(), tag_list.end());

    // if it's not a restriction, continue;
    if (std::distance(fi_begin, fi_end) == 0)
    {
        return {};
    }

    // check if the restriction should be ignored
    const char *except = relation.get_value_by_key("except");
    if (except != nullptr && ShouldIgnoreRestriction(except))
    {
        return {};
    }

    bool is_only_restriction = false;

    for (; fi_begin != fi_end; ++fi_begin)
    {
        const std::string key(fi_begin->key());
        const std::string value(fi_begin->value());

        // documented OSM restriction tags start either with only_* or no_*;
        // check and return on these values, and ignore unrecognized values
        if (value.find("only_") == 0)
        {
            is_only_restriction = true;
        }
        else if (value.find("no_") == 0)
        {
            is_only_restriction = false;
        }
        else // unrecognized value type
        {
            return {};
        }
    }

    InputRestrictionContainer restriction_container(is_only_restriction);

    for (const auto &member : relation.members())
    {
        const char *role = member.role();
        if (strcmp("from", role) != 0 && strcmp("to", role) != 0 && strcmp("via", role) != 0)
        {
            continue;
        }

        switch (member.type())
        {
        case osmium::item_type::node:
            // Make sure nodes appear only in the role if a via node
            if (0 == strcmp("from", role) || 0 == strcmp("to", role))
            {
                continue;
            }
            BOOST_ASSERT(0 == strcmp("via", role));

            // set via node id
            restriction_container.restriction.via.node = member.ref();
            break;

        case osmium::item_type::way:
            BOOST_ASSERT(0 == strcmp("from", role) || 0 == strcmp("to", role) ||
                         0 == strcmp("via", role));
            if (0 == strcmp("from", role))
            {
                restriction_container.restriction.from.way = member.ref();
            }
            else if (0 == strcmp("to", role))
            {
                restriction_container.restriction.to.way = member.ref();
            }
//.........这里部分代码省略.........
开发者ID:Mapotempo,项目名称:osrm-backend,代码行数:101,代码来源:restriction_parser.cpp


注:本文中的osmium::Relation::tags方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。