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


C++ AnnotationIDs::reserve方法代码示例

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


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

示例1: make_pair

std::pair<std::unordered_set<TileID, TileID::Hash>, AnnotationIDs>
AnnotationManager::addPointAnnotations(const std::vector<PointAnnotation>& points,
                                       const uint8_t maxZoom) {
    // We pre-generate tiles to contain each annotation up to the map's max zoom.
    // We do this for fast rendering without projection conversions on the fly, as well as
    // to simplify bounding box queries of annotations later. Tiles get invalidated when
    // annotations are added or removed in order to refresh the map render without
    // touching the base map underneath.

    AnnotationIDs annotationIDs;
    annotationIDs.reserve(points.size());

    std::unordered_set<TileID, TileID::Hash> affectedTiles;

    for (const PointAnnotation& point : points) {
        // projection conversion into unit space
        const auto pp = projectPoint(point.position);
        const uint32_t pointAnnotationID = nextID();

        // at render time we style the point according to its {sprite} field
        std::unordered_map<std::string, std::string> pointFeatureProperties;
        if (point.icon.length()) {
            pointFeatureProperties.emplace("sprite", point.icon);
        }
        if (point.text.length()) {
            pointFeatureProperties.emplace("marker-text", point.text);
        } else {
            pointFeatureProperties.emplace("sprite", defaultPointAnnotationSymbol);
        }
        if (point.type.length()) {
            pointFeatureProperties.emplace("type", point.type);
        }

        // add individual point tile feature
        auto featureAffectedTiles = addTileFeature(
            pointAnnotationID,
            AnnotationSegments({{ point.position }}),
            std::vector<std::vector<vec2<double>>>({{ pp }}),
            AnnotationType::Point,
            {{ }},
            pointFeatureProperties,
            "",
            maxZoom
        );

        std::copy(featureAffectedTiles.begin(), featureAffectedTiles.end(), std::inserter(affectedTiles, affectedTiles.begin()));

        annotationIDs.push_back(pointAnnotationID);
    }

    // Tile:IDs that need refreshed and the annotation identifiers held onto by the client.
    return std::make_pair(affectedTiles, annotationIDs);
}
开发者ID:TrueFlow,项目名称:mapbox-gl-native,代码行数:53,代码来源:annotation.cpp

示例2: queryPointAnnotations

AnnotationIDs Map::queryPointAnnotations(const ScreenBox& box) {
    auto features = queryRenderedFeatures(box, {{ AnnotationManager::PointLayerID }});
    std::set<AnnotationID> set;
    for (auto &feature : features) {
        assert(feature.id);
        assert(*feature.id <= std::numeric_limits<AnnotationID>::max());
        set.insert(static_cast<AnnotationID>(feature.id->get<uint64_t>()));
    }
    AnnotationIDs ids;
    ids.reserve(set.size());
    std::move(set.begin(), set.end(), std::back_inserter(ids));
    return ids;
}
开发者ID:manimaul,项目名称:mapbox-gl-native,代码行数:13,代码来源:map.cpp

示例3:

AnnotationIDs
AnnotationManager::addShapeAnnotations(const std::vector<ShapeAnnotation>& shapes, const uint8_t maxZoom) {
    AnnotationIDs annotationIDs;
    annotationIDs.reserve(shapes.size());

    for (const auto& shape : shapes) {
        const uint32_t annotationID = nextID++;
        shapeAnnotations.emplace(annotationID,
            std::make_unique<ShapeAnnotationImpl>(annotationID, shape, maxZoom));
        annotationIDs.push_back(annotationID);
    }

    return annotationIDs;
}
开发者ID:jormon,项目名称:mapbox-gl-native,代码行数:14,代码来源:annotation_manager.cpp


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