コード例 #1
0
AnnotationIDs AnnotationManager::getPointAnnotationsInBounds(const LatLngBounds& bounds) const {
    AnnotationIDs result;

    pointTree.query(boost::geometry::index::intersects(bounds),
        boost::make_function_output_iterator([&](const auto& val){
            result.push_back(val->id);
        }));

    return result;
}
コード例 #2
0
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);
}
コード例 #3
0
ファイル: map.cpp プロジェクト: manimaul/mapbox-gl-native
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;
}
コード例 #4
0
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;
}
コード例 #5
0
AnnotationIDs
AnnotationManager::addPointAnnotations(const std::vector<PointAnnotation>& points, const uint8_t) {
    AnnotationIDs annotationIDs;
    annotationIDs.reserve(points.size());

    for (const auto& point : points) {
        const uint32_t annotationID = nextID++;
        auto annotation = std::make_shared<PointAnnotationImpl>(annotationID, point);
        pointTree.insert(annotation);
        pointAnnotations.emplace(annotationID, annotation);
        annotationIDs.push_back(annotationID);
    }

    return annotationIDs;
}
コード例 #6
0
void QMapboxGL::removeAnnotations(const AnnotationIDs &annotationIDs)
{
    std::vector<mbgl::AnnotationID> mbglAnnotationIds;
    mbglAnnotationIds.reserve(annotationIDs.size());

    for (const AnnotationID annotationID : annotationIDs) {
        mbglAnnotationIds.emplace_back(annotationID);
    }

    d_ptr->mapObj->removeAnnotations(mbglAnnotationIds);
}
コード例 #7
0
std::pair<std::unordered_set<TileID, TileID::Hash>, AnnotationIDs>
AnnotationManager::addShapeAnnotations(const std::vector<ShapeAnnotation>& shapes,
                                       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(shapes.size());

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

    for (const ShapeAnnotation& shape : shapes) {
        const uint32_t shapeAnnotationID = nextID();

        // current shape tiles are on-the-fly, so we don't get any "affected tiles"
        // and just expire all annotation tiles for shape adds

        addTileFeature(
            shapeAnnotationID,
            shape.segments,
            {{ }},
            AnnotationType::Shape,
            shape.styleProperties,
            shape.featureProperties,
            shape.layerId,
            maxZoom
        );

        annotationIDs.push_back(shapeAnnotationID);
    }

    // Tile:IDs that need refreshed and the annotation identifiers held onto by the client.
    return std::make_pair(affectedTiles, annotationIDs);
}