diff options
-rw-r--r-- | cmake/core-files.cmake | 2 | ||||
-rw-r--r-- | include/mbgl/annotation/annotation.hpp | 10 | ||||
-rw-r--r-- | platform/qt/app/mapwindow.cpp | 15 | ||||
-rw-r--r-- | platform/qt/app/mapwindow.hpp | 1 | ||||
-rw-r--r-- | platform/qt/include/qmapbox.hpp | 6 | ||||
-rw-r--r-- | platform/qt/src/qmapbox.cpp | 10 | ||||
-rw-r--r-- | platform/qt/src/qmapboxgl.cpp | 3 | ||||
-rw-r--r-- | src/mbgl/annotation/annotation_manager.cpp | 17 | ||||
-rw-r--r-- | src/mbgl/annotation/annotation_manager.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/annotation/style_sourced_annotation_impl.cpp | 43 | ||||
-rw-r--r-- | src/mbgl/annotation/style_sourced_annotation_impl.hpp | 19 | ||||
-rw-r--r-- | src/mbgl/style/layer_impl.cpp | 8 | ||||
-rw-r--r-- | src/mbgl/style/layer_impl.hpp | 5 | ||||
-rw-r--r-- | test/api/annotations.test.cpp | 10 |
14 files changed, 1 insertions, 150 deletions
diff --git a/cmake/core-files.cmake b/cmake/core-files.cmake index e9d7442e5d..5383f0ed7b 100644 --- a/cmake/core-files.cmake +++ b/cmake/core-files.cmake @@ -32,8 +32,6 @@ set(MBGL_CORE_FILES src/mbgl/annotation/render_annotation_source.hpp src/mbgl/annotation/shape_annotation_impl.cpp src/mbgl/annotation/shape_annotation_impl.hpp - src/mbgl/annotation/style_sourced_annotation_impl.cpp - src/mbgl/annotation/style_sourced_annotation_impl.hpp src/mbgl/annotation/symbol_annotation_impl.cpp src/mbgl/annotation/symbol_annotation_impl.hpp diff --git a/include/mbgl/annotation/annotation.hpp b/include/mbgl/annotation/annotation.hpp index de83d24712..2a938fb755 100644 --- a/include/mbgl/annotation/annotation.hpp +++ b/include/mbgl/annotation/annotation.hpp @@ -43,17 +43,9 @@ public: style::DataDrivenPropertyValue<Color> outlineColor {}; }; -// An annotation whose type and properties are sourced from a style layer. -class StyleSourcedAnnotation { -public: - ShapeAnnotationGeometry geometry; - std::string layerID; -}; - using Annotation = variant< SymbolAnnotation, LineAnnotation, - FillAnnotation, - StyleSourcedAnnotation>; + FillAnnotation>; } // namespace mbgl diff --git a/platform/qt/app/mapwindow.cpp b/platform/qt/app/mapwindow.cpp index a72faf005e..5bb9ad1261 100644 --- a/platform/qt/app/mapwindow.cpp +++ b/platform/qt/app/mapwindow.cpp @@ -277,21 +277,6 @@ void MapWindow::keyPressEvent(QKeyEvent *ev) } } break; - case Qt::Key_4: { - if (m_styleSourcedAnnotationId.isNull()) { - QMapbox::Coordinate topLeft = m_map->coordinateForPixel({ 0, 0 }); - QMapbox::Coordinate topRight = m_map->coordinateForPixel({ 0, qreal(size().height()) }); - QMapbox::Coordinate bottomLeft = m_map->coordinateForPixel({ qreal(size().width()), 0 }); - QMapbox::Coordinate bottomRight = m_map->coordinateForPixel({ qreal(size().width()), qreal(size().height()) }); - QMapbox::CoordinatesCollections geometry { { { bottomLeft, bottomRight, topRight, topLeft, bottomLeft } } }; - QMapbox::StyleSourcedAnnotation styleSourced { { QMapbox::ShapeAnnotationGeometry::PolygonType, geometry }, "water" }; - m_styleSourcedAnnotationId = m_map->addAnnotation(QVariant::fromValue<QMapbox::StyleSourcedAnnotation>(styleSourced)); - } else { - m_map->removeAnnotation(m_styleSourcedAnnotationId.toUInt()); - m_styleSourcedAnnotationId.clear(); - } - } - break; case Qt::Key_5: { if (m_map->layerExists("circleLayer")) { m_map->removeLayer("circleLayer"); diff --git a/platform/qt/app/mapwindow.hpp b/platform/qt/app/mapwindow.hpp index 6b4b7fd1cc..c484114ec0 100644 --- a/platform/qt/app/mapwindow.hpp +++ b/platform/qt/app/mapwindow.hpp @@ -64,7 +64,6 @@ private: QVariant m_symbolAnnotationId; QVariant m_lineAnnotationId; QVariant m_fillAnnotationId; - QVariant m_styleSourcedAnnotationId; bool m_sourceAdded = false; }; diff --git a/platform/qt/include/qmapbox.hpp b/platform/qt/include/qmapbox.hpp index e69b37108d..1b61d3270f 100644 --- a/platform/qt/include/qmapbox.hpp +++ b/platform/qt/include/qmapbox.hpp @@ -62,11 +62,6 @@ struct Q_DECL_EXPORT FillAnnotation { QVariant outlineColor; }; -struct Q_DECL_EXPORT StyleSourcedAnnotation { - ShapeAnnotationGeometry geometry; - QString layerID; -}; - typedef QVariant Annotation; typedef quint32 AnnotationID; typedef QList<AnnotationID> AnnotationIDs; @@ -109,6 +104,5 @@ Q_DECLARE_METATYPE(QMapbox::SymbolAnnotation); Q_DECLARE_METATYPE(QMapbox::ShapeAnnotationGeometry); Q_DECLARE_METATYPE(QMapbox::LineAnnotation); Q_DECLARE_METATYPE(QMapbox::FillAnnotation); -Q_DECLARE_METATYPE(QMapbox::StyleSourcedAnnotation); #endif // QMAPBOX_H diff --git a/platform/qt/src/qmapbox.cpp b/platform/qt/src/qmapbox.cpp index 410e114690..751b16f9db 100644 --- a/platform/qt/src/qmapbox.cpp +++ b/platform/qt/src/qmapbox.cpp @@ -139,16 +139,6 @@ namespace QMapbox { */ /*! - \class QMapbox::StyleSourcedAnnotation - - \inmodule Mapbox Qt SDK - - Represents a style sourced annotation object, along with its properties. - - A style sourced annotation comprises of its geometry and a layer identifier. -*/ - -/*! \typedef QMapbox::Annotation Alias for QVariant. diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp index ce7e237afb..e1b8889603 100644 --- a/platform/qt/src/qmapboxgl.cpp +++ b/platform/qt/src/qmapboxgl.cpp @@ -866,9 +866,6 @@ mbgl::Annotation asMapboxGLAnnotation(const QMapbox::Annotation & annotation) { } else { return mbgl::FillAnnotation { asMapboxGLGeometry(fillAnnotation.geometry), fillAnnotation.opacity, { *color }, {} }; } - } else if (annotation.canConvert<QMapbox::StyleSourcedAnnotation>()) { - QMapbox::StyleSourcedAnnotation styleSourcedAnnotation = annotation.value<QMapbox::StyleSourcedAnnotation>(); - return mbgl::StyleSourcedAnnotation { asMapboxGLGeometry(styleSourcedAnnotation.geometry), styleSourcedAnnotation.layerID.toStdString() }; } qWarning() << "Unable to convert annotation:" << annotation; diff --git a/src/mbgl/annotation/annotation_manager.cpp b/src/mbgl/annotation/annotation_manager.cpp index 88153f5fb7..e11ecff30c 100644 --- a/src/mbgl/annotation/annotation_manager.cpp +++ b/src/mbgl/annotation/annotation_manager.cpp @@ -4,7 +4,6 @@ #include <mbgl/annotation/symbol_annotation_impl.hpp> #include <mbgl/annotation/line_annotation_impl.hpp> #include <mbgl/annotation/fill_annotation_impl.hpp> -#include <mbgl/annotation/style_sourced_annotation_impl.hpp> #include <mbgl/style/style.hpp> #include <mbgl/style/layers/symbol_layer.hpp> #include <mbgl/style/layers/symbol_layer_impl.hpp> @@ -72,12 +71,6 @@ void AnnotationManager::add(const AnnotationID& id, const FillAnnotation& annota obsoleteShapeAnnotationLayers.erase(impl.layerID); } -void AnnotationManager::add(const AnnotationID& id, const StyleSourcedAnnotation& annotation, const uint8_t maxZoom) { - ShapeAnnotationImpl& impl = *shapeAnnotations.emplace(id, - std::make_unique<StyleSourcedAnnotationImpl>(id, annotation, maxZoom)).first->second; - obsoleteShapeAnnotationLayers.erase(impl.layerID); -} - Update AnnotationManager::update(const AnnotationID& id, const SymbolAnnotation& annotation, const uint8_t maxZoom) { Update result = Update::Nothing; @@ -124,16 +117,6 @@ Update AnnotationManager::update(const AnnotationID& id, const FillAnnotation& a return Update::AnnotationData | Update::AnnotationStyle; } -Update AnnotationManager::update(const AnnotationID& id, const StyleSourcedAnnotation& annotation, const uint8_t maxZoom) { - auto it = shapeAnnotations.find(id); - if (it == shapeAnnotations.end()) { - assert(false); // Attempt to update a non-existent shape annotation - return Update::Nothing; - } - removeAndAdd(id, annotation, maxZoom); - return Update::AnnotationData | Update::AnnotationStyle; -} - void AnnotationManager::removeAndAdd(const AnnotationID& id, const Annotation& annotation, const uint8_t maxZoom) { removeAnnotation(id); Annotation::visit(annotation, [&] (const auto& annotation_) { diff --git a/src/mbgl/annotation/annotation_manager.hpp b/src/mbgl/annotation/annotation_manager.hpp index 0ab43bec15..de213c830d 100644 --- a/src/mbgl/annotation/annotation_manager.hpp +++ b/src/mbgl/annotation/annotation_manager.hpp @@ -50,12 +50,10 @@ private: void add(const AnnotationID&, const SymbolAnnotation&, const uint8_t); void add(const AnnotationID&, const LineAnnotation&, const uint8_t); void add(const AnnotationID&, const FillAnnotation&, const uint8_t); - void add(const AnnotationID&, const StyleSourcedAnnotation&, const uint8_t); Update update(const AnnotationID&, const SymbolAnnotation&, const uint8_t); Update update(const AnnotationID&, const LineAnnotation&, const uint8_t); Update update(const AnnotationID&, const FillAnnotation&, const uint8_t); - Update update(const AnnotationID&, const StyleSourcedAnnotation&, const uint8_t); void removeAndAdd(const AnnotationID&, const Annotation&, const uint8_t); diff --git a/src/mbgl/annotation/style_sourced_annotation_impl.cpp b/src/mbgl/annotation/style_sourced_annotation_impl.cpp deleted file mode 100644 index cb664cf15d..0000000000 --- a/src/mbgl/annotation/style_sourced_annotation_impl.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include <mbgl/annotation/style_sourced_annotation_impl.hpp> -#include <mbgl/annotation/annotation_manager.hpp> -#include <mbgl/style/style.hpp> -#include <mbgl/style/layer.hpp> -#include <mbgl/style/layer_impl.hpp> -#include <mbgl/style/layers/line_layer.hpp> -#include <mbgl/style/layers/fill_layer.hpp> - -namespace mbgl { - -using namespace style; - -StyleSourcedAnnotationImpl::StyleSourcedAnnotationImpl(AnnotationID id_, StyleSourcedAnnotation annotation_, uint8_t maxZoom_) - : ShapeAnnotationImpl(id_, maxZoom_), - annotation(std::move(annotation_)) { -} - -void StyleSourcedAnnotationImpl::updateStyle(Style& style) const { - if (style.getLayer(layerID)) - return; - - const Layer* sourceLayer = style.getLayer(annotation.layerID); - if (!sourceLayer) - return; - - if (sourceLayer->is<LineLayer>()) { - std::unique_ptr<Layer> layer = sourceLayer->baseImpl->copy(layerID, AnnotationManager::SourceID); - layer->as<LineLayer>()->setSourceLayer(layerID); - layer->as<LineLayer>()->setVisibility(VisibilityType::Visible); - style.addLayer(std::move(layer), sourceLayer->getID()); - } else if (sourceLayer->is<FillLayer>()) { - std::unique_ptr<Layer> layer = sourceLayer->baseImpl->copy(layerID, AnnotationManager::SourceID); - layer->as<FillLayer>()->setSourceLayer(layerID); - layer->as<FillLayer>()->setVisibility(VisibilityType::Visible); - style.addLayer(std::move(layer), sourceLayer->getID()); - } -} - -const ShapeAnnotationGeometry& StyleSourcedAnnotationImpl::geometry() const { - return annotation.geometry; -} - -} // namespace mbgl diff --git a/src/mbgl/annotation/style_sourced_annotation_impl.hpp b/src/mbgl/annotation/style_sourced_annotation_impl.hpp deleted file mode 100644 index 82b947302d..0000000000 --- a/src/mbgl/annotation/style_sourced_annotation_impl.hpp +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -#include <mbgl/annotation/shape_annotation_impl.hpp> -#include <mbgl/annotation/annotation.hpp> - -namespace mbgl { - -class StyleSourcedAnnotationImpl : public ShapeAnnotationImpl { -public: - StyleSourcedAnnotationImpl(AnnotationID, StyleSourcedAnnotation, uint8_t maxZoom); - - void updateStyle(style::Style&) const final; - const ShapeAnnotationGeometry& geometry() const final; - -private: - const StyleSourcedAnnotation annotation; -}; - -} // namespace mbgl diff --git a/src/mbgl/style/layer_impl.cpp b/src/mbgl/style/layer_impl.cpp index b8eb01fe77..725064a9a2 100644 --- a/src/mbgl/style/layer_impl.cpp +++ b/src/mbgl/style/layer_impl.cpp @@ -3,14 +3,6 @@ namespace mbgl { namespace style { -std::unique_ptr<Layer> Layer::Impl::copy(const std::string& id_, - const std::string& source_) const { - std::unique_ptr<Layer> result = clone(); - result->baseImpl->id = id_; - result->baseImpl->source = source_; - return result; -} - void Layer::Impl::setObserver(LayerObserver* observer_) { observer = observer_ ? observer_ : &nullObserver; } diff --git a/src/mbgl/style/layer_impl.hpp b/src/mbgl/style/layer_impl.hpp index 6aa8fccaf0..914203f804 100644 --- a/src/mbgl/style/layer_impl.hpp +++ b/src/mbgl/style/layer_impl.hpp @@ -34,11 +34,6 @@ class Layer::Impl { public: virtual ~Impl() = default; - // Create a new layer with the specified `id` and `sourceID`. All other properties - // are copied from this layer. - std::unique_ptr<Layer> copy(const std::string& id, - const std::string& sourceID) const; - // Create an identical copy of this layer. virtual std::unique_ptr<Layer> clone() const = 0; diff --git a/test/api/annotations.test.cpp b/test/api/annotations.test.cpp index 97ccaae684..100187c587 100644 --- a/test/api/annotations.test.cpp +++ b/test/api/annotations.test.cpp @@ -144,16 +144,6 @@ TEST(Annotations, OverlappingFillAnnotation) { test.checkRendering("overlapping_fill_annotation"); } -TEST(Annotations, StyleSourcedShapeAnnotation) { - AnnotationTest test; - - Polygon<double> polygon = { {{ { 0, 0 }, { 0, 45 }, { 45, 45 }, { 45, 0 } }} }; - - test.map.setStyleJSON(util::read_file("test/fixtures/api/annotation.json")); - test.map.addAnnotation(StyleSourcedAnnotation { polygon, "annotation" }); - test.checkRendering("style_sourced_shape_annotation"); -} - TEST(Annotations, AddMultiple) { AnnotationTest test; |