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


C++ Buffer::commit方法代码示例

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


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

示例1: add_relation

            /**
             * Tell the Collector that you are interested in this relation
             * and want it kept until all members have been assembled and
             * it is handed back to you.
             *
             * The relation is copied and stored in a buffer inside the
             * collector.
             */
            void add_relation(const osmium::Relation& relation) {
                const size_t offset = m_relations_buffer.committed();
                m_relations_buffer.add_item(relation);

                RelationMeta relation_meta(offset);

                int n = 0;
                for (auto& member : m_relations_buffer.get<osmium::Relation>(offset).members()) {
                    if (static_cast<TCollector*>(this)->keep_member(relation_meta, member)) {
                        member_meta(member.type()).emplace_back(member.ref(), m_relations.size(), n);
                        relation_meta.increment_need_members();
                    } else {
                        member.ref(0); // set member id to zero to indicate we are not interested
                    }
                    ++n;
                }

                assert(offset == m_relations_buffer.committed());
                if (relation_meta.has_all_members()) {
                    m_relations_buffer.rollback();
                } else {
                    m_relations_buffer.commit();
                    m_relations.push_back(std::move(relation_meta));
//                    std::cerr << "added relation id=" << relation.id() << "\n";
                }
            }
开发者ID:AFDudley,项目名称:osm2pgsql,代码行数:34,代码来源:collector.hpp

示例2: parse_polygon_array

std::size_t parse_polygon_array(const rapidjson::Value& value, osmium::memory::Buffer& buffer) {
    {
        osmium::builder::AreaBuilder builder{buffer};
        parse_rings(value, builder);
    }

    return buffer.commit();
}
开发者ID:tomhughes,项目名称:osmium-tool,代码行数:8,代码来源:geojson_file_parser.cpp

示例3: opl_parse

 /**
  * Parses one line in OPL format. The line must not have a newline
  * character at the end. Buffer.commit() is called automatically if the
  * write succeeded.
  *
  * @param data Line must be in this zero-delimited string.
  * @param buffer Result will be written to this buffer.
  *
  * @returns true if an entity was parsed, false otherwise (for instance
  *          when the line is empty).
  * @throws osmium::opl_error If the parsing fails.
  */
 inline bool opl_parse(const char* data, osmium::memory::Buffer& buffer) {
     try {
         const bool wrote_something = osmium::io::detail::opl_parse_line(0, data, buffer);
         buffer.commit();
         return wrote_something;
     } catch (const osmium::opl_error&) {
         buffer.rollback();
         throw;
     }
 }
开发者ID:Project-OSRM,项目名称:osrm-backend,代码行数:22,代码来源:opl.hpp

示例4: operator

            /**
             * Assemble an area from the given way.
             * The resulting area is put into the out_buffer.
             *
             * @returns false if there was some kind of error building the
             *          area, true otherwise.
             */
            bool operator()(const osmium::Way& way, osmium::memory::Buffer& out_buffer) {
                if (!config().create_way_polygons) {
                    return true;
                }

                if (config().problem_reporter) {
                    config().problem_reporter->set_object(osmium::item_type::way, way.id());
                    config().problem_reporter->set_nodes(way.nodes().size());
                }

                // Ignore (but count) ways without segments.
                if (way.nodes().size() < 2) {
                    ++stats().short_ways;
                    return false;
                }

                if (!way.ends_have_same_id()) {
                    ++stats().duplicate_nodes;
                    if (config().problem_reporter) {
                        config().problem_reporter->report_duplicate_node(way.nodes().front().ref(), way.nodes().back().ref(), way.nodes().front().location());
                    }
                }

                ++stats().from_ways;
                stats().invalid_locations = segment_list().extract_segments_from_way(config().problem_reporter,
                                                                                     stats().duplicate_nodes,
                                                                                     way);
                if (!config().ignore_invalid_locations && stats().invalid_locations > 0) {
                    return false;
                }

                if (config().debug_level > 0) {
                    std::cerr << "\nAssembling way " << way.id() << " containing " << segment_list().size() << " nodes\n";
                }

                // Now create the Area object and add the attributes and tags
                // from the way.
                const bool okay = create_area(out_buffer, way);
                if (okay) {
                    out_buffer.commit();
                } else {
                    out_buffer.rollback();
                }

                if (debug()) {
                    std::cerr << "Done: " << stats() << "\n";
                }

                return okay;
            }
开发者ID:Project-OSRM,项目名称:osrm-backend,代码行数:57,代码来源:assembler.hpp

示例5: operator

            /**
             * Assemble an area from the given way.
             *
             * The resulting area is put into the out_buffer.
             *
             * @returns false if there was some kind of error building the
             *          area, true otherwise.
             */
            bool operator()(const osmium::Way& way, osmium::memory::Buffer& out_buffer) {
                segment_list().extract_segments_from_way(config().problem_reporter, stats().duplicate_nodes, way);

                if (!create_rings()) {
                    return false;
                }

                {
                    osmium::builder::AreaBuilder builder{out_buffer};
                    builder.initialize_from_object(way);
                    add_rings_to_area(builder);
                }
                out_buffer.commit();

                return true;
            }
开发者ID:KnockSoftware,项目名称:osrm-backend,代码行数:24,代码来源:geom_assembler.hpp

示例6: parse_multipolygon_array

std::size_t parse_multipolygon_array(const rapidjson::Value& value, osmium::memory::Buffer& buffer) {
    assert(value.IsArray());
    const auto array = value.GetArray();
    if (array.Empty()) {
        throw config_error{"Multipolygon must contain at least one polygon array."};
    }

    {
        osmium::builder::AreaBuilder builder{buffer};
        for (const auto& polygon : array) {
            if (!polygon.IsArray()) {
                throw config_error{"Polygon must be an array."};
            }
            parse_rings(polygon, builder);
        }
    }

    return buffer.commit();
}
开发者ID:tomhughes,项目名称:osmium-tool,代码行数:19,代码来源:geojson_file_parser.cpp


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