summaryrefslogtreecommitdiff
path: root/include/mbgl/annotation
diff options
context:
space:
mode:
Diffstat (limited to 'include/mbgl/annotation')
-rw-r--r--include/mbgl/annotation/annotation.hpp46
-rw-r--r--include/mbgl/annotation/point_annotation.hpp18
-rw-r--r--include/mbgl/annotation/shape_annotation.hpp54
3 files changed, 46 insertions, 72 deletions
diff --git a/include/mbgl/annotation/annotation.hpp b/include/mbgl/annotation/annotation.hpp
index 52916549c9..e8ac9a2fb7 100644
--- a/include/mbgl/annotation/annotation.hpp
+++ b/include/mbgl/annotation/annotation.hpp
@@ -1,11 +1,57 @@
#pragma once
+#include <mbgl/util/geometry.hpp>
+#include <mbgl/util/variant.hpp>
+#include <mbgl/util/color.hpp>
+
#include <cstdint>
#include <vector>
+#include <string>
namespace mbgl {
using AnnotationID = uint32_t;
using AnnotationIDs = std::vector<AnnotationID>;
+class SymbolAnnotation {
+public:
+ Point<double> geometry;
+ std::string icon;
+};
+
+using ShapeAnnotationGeometry = variant<
+ LineString<double>,
+ Polygon<double>,
+ MultiLineString<double>,
+ MultiPolygon<double>>;
+
+class LineAnnotation {
+public:
+ ShapeAnnotationGeometry geometry;
+ float opacity = 1;
+ float width = 1;
+ Color color = Color::black();
+};
+
+class FillAnnotation {
+public:
+ ShapeAnnotationGeometry geometry;
+ float opacity = 1;
+ Color color = Color::black();
+ Color outlineColor = { 0, 0, 0, -1 };
+};
+
+// 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>;
+
} // namespace mbgl
diff --git a/include/mbgl/annotation/point_annotation.hpp b/include/mbgl/annotation/point_annotation.hpp
deleted file mode 100644
index c9236c3c04..0000000000
--- a/include/mbgl/annotation/point_annotation.hpp
+++ /dev/null
@@ -1,18 +0,0 @@
-#pragma once
-
-#include <mbgl/util/geo.hpp>
-
-#include <string>
-
-namespace mbgl {
-
-class PointAnnotation {
-public:
- PointAnnotation(const LatLng& position_, const std::string& icon_ = "")
- : position(position_.wrapped()), icon(icon_) {}
-
- const LatLng position;
- const std::string icon;
-};
-
-} // namespace mbgl
diff --git a/include/mbgl/annotation/shape_annotation.hpp b/include/mbgl/annotation/shape_annotation.hpp
deleted file mode 100644
index 6e3fe95dd4..0000000000
--- a/include/mbgl/annotation/shape_annotation.hpp
+++ /dev/null
@@ -1,54 +0,0 @@
-#pragma once
-
-#include <mbgl/annotation/annotation.hpp>
-#include <mbgl/style/types.hpp>
-
-#include <mbgl/util/geo.hpp>
-#include <mbgl/util/variant.hpp>
-
-namespace mbgl {
-
-using AnnotationSegment = std::vector<LatLng>;
-using AnnotationSegments = std::vector<AnnotationSegment>;
-
-struct FillAnnotationProperties {
- float opacity = 1;
- Color color = {{ 0, 0, 0, 1 }};
- Color outlineColor = {{ 0, 0, 0, -1 }};
-};
-
-struct LineAnnotationProperties {
- float opacity = 1;
- float width = 1;
- Color color = {{ 0, 0, 0, 1 }};
-};
-
-class ShapeAnnotation {
-public:
- using Properties = variant<
- FillAnnotationProperties, // creates a fill annotation
- LineAnnotationProperties, // creates a line annotation
- std::string>; // creates an annotation whose type and properties are sourced from a style layer
-
- ShapeAnnotation(const AnnotationSegments& segments_, const Properties& properties_)
- : segments(wrapCoordinates(segments_)), properties(properties_) {}
-
- const AnnotationSegments segments;
- const Properties properties;
-
-private:
- AnnotationSegments wrapCoordinates(const AnnotationSegments& segments_) {
- AnnotationSegments wrappedSegments;
- // Wrap all segments coordinates.
- for (const auto& segment_ : segments_) {
- AnnotationSegment wrappedSegment;
- for (const auto& latLng_ : segment_) {
- wrappedSegment.push_back(latLng_.wrapped());
- }
- wrappedSegments.push_back(wrappedSegment);
- }
- return wrappedSegments;
- }
-};
-
-} // namespace mbgl