Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[core] Remove StyleSourcedAnnotation support
Browse files Browse the repository at this point in the history
The functionality this provided has been subsumed by the runtime styling API.
  • Loading branch information
jfirebaugh committed May 5, 2017
1 parent dd353a6 commit 69d9529
Show file tree
Hide file tree
Showing 14 changed files with 1 addition and 150 deletions.
2 changes: 0 additions & 2 deletions cmake/core-files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 1 addition & 9 deletions include/mbgl/annotation/annotation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,9 @@ class FillAnnotation {
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
15 changes: 0 additions & 15 deletions platform/qt/app/mapwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
1 change: 0 additions & 1 deletion platform/qt/app/mapwindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ protected slots:
QVariant m_symbolAnnotationId;
QVariant m_lineAnnotationId;
QVariant m_fillAnnotationId;
QVariant m_styleSourcedAnnotationId;

bool m_sourceAdded = false;
};
Expand Down
6 changes: 0 additions & 6 deletions platform/qt/include/qmapbox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
10 changes: 0 additions & 10 deletions platform/qt/src/qmapbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,6 @@ namespace QMapbox {
A fill annotation comprises of its geometry and fill properties such as opacity, color and outline color.
*/

/*!
\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
Expand Down
3 changes: 0 additions & 3 deletions platform/qt/src/qmapboxgl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
17 changes: 0 additions & 17 deletions src/mbgl/annotation/annotation_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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_) {
Expand Down
2 changes: 0 additions & 2 deletions src/mbgl/annotation/annotation_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,10 @@ class AnnotationManager : private util::noncopyable {
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);

Expand Down
43 changes: 0 additions & 43 deletions src/mbgl/annotation/style_sourced_annotation_impl.cpp

This file was deleted.

19 changes: 0 additions & 19 deletions src/mbgl/annotation/style_sourced_annotation_impl.hpp

This file was deleted.

8 changes: 0 additions & 8 deletions src/mbgl/style/layer_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
5 changes: 0 additions & 5 deletions src/mbgl/style/layer_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
10 changes: 0 additions & 10 deletions test/api/annotations.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 69d9529

Please sign in to comment.