1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
#ifndef MBGL_ANNOTATION_SHAPE_ANNOTATION
#define MBGL_ANNOTATION_SHAPE_ANNOTATION
#include <mbgl/annotation/annotation.hpp>
#include <mbgl/style/types.hpp>
#include <mbgl/util/geo.hpp>
#include <mapbox/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 = mapbox::util::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
#endif
|