diff options
-rw-r--r-- | include/mbgl/annotation/annotation.hpp | 20 | ||||
-rw-r--r-- | include/mbgl/annotation/shape_annotation.hpp | 8 | ||||
-rw-r--r-- | include/mbgl/map/map.hpp | 17 | ||||
-rw-r--r-- | src/mbgl/annotation/annotation_manager.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/map/map.cpp | 12 |
5 files changed, 36 insertions, 23 deletions
diff --git a/include/mbgl/annotation/annotation.hpp b/include/mbgl/annotation/annotation.hpp new file mode 100644 index 0000000000..fd21cd5f6a --- /dev/null +++ b/include/mbgl/annotation/annotation.hpp @@ -0,0 +1,20 @@ +#ifndef MBGL_ANNOTATION +#define MBGL_ANNOTATION + +#include <cstdint> +#include <vector> + +namespace mbgl { + +enum class AnnotationType : uint8_t { + Any = 0, + Point = 1 << 0, + Shape = 1 << 1, +}; + +using AnnotationID = uint32_t; +using AnnotationIDs = std::vector<AnnotationID>; + +} + +#endif diff --git a/include/mbgl/annotation/shape_annotation.hpp b/include/mbgl/annotation/shape_annotation.hpp index a35b867266..dd8bf5e4d5 100644 --- a/include/mbgl/annotation/shape_annotation.hpp +++ b/include/mbgl/annotation/shape_annotation.hpp @@ -1,14 +1,16 @@ #ifndef MBGL_ANNOTATION_SHAPE_ANNOTATION #define MBGL_ANNOTATION_SHAPE_ANNOTATION -#include <mbgl/util/geo.hpp> -#include <mbgl/map/map.hpp> +#include <mbgl/annotation/annotation.hpp> #include <mbgl/style/style_properties.hpp> -#include <string> +#include <mbgl/util/geo.hpp> namespace mbgl { +using AnnotationSegment = std::vector<LatLng>; +using AnnotationSegments = std::vector<AnnotationSegment>; + class ShapeAnnotation { public: inline ShapeAnnotation(const AnnotationSegments& segments_, const StyleProperties& styleProperties_) diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index 69499c5110..8a381cda65 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -7,6 +7,7 @@ #include <mbgl/util/geo.hpp> #include <mbgl/util/noncopyable.hpp> #include <mbgl/util/vec.hpp> +#include <mbgl/annotation/annotation.hpp> #include <cstdint> #include <string> @@ -31,12 +32,6 @@ namespace util { template <class T> class Thread; } -enum class AnnotationType : uint8_t { - Any = 0, - Point = 1 << 0, - Shape = 1 << 1, -}; - struct EdgeInsets { double top = 0; double left = 0; @@ -44,10 +39,6 @@ struct EdgeInsets { double right = 0; }; -using AnnotationIDs = std::vector<uint32_t>; -using AnnotationSegment = std::vector<LatLng>; -using AnnotationSegments = std::vector<AnnotationSegment>; - class Map : private util::noncopyable { friend class View; @@ -147,13 +138,13 @@ public: void setDefaultPointAnnotationSymbol(const std::string&); double getTopOffsetPixelsForAnnotationSymbol(const std::string&); - uint32_t addPointAnnotation(const PointAnnotation&); + AnnotationID addPointAnnotation(const PointAnnotation&); AnnotationIDs addPointAnnotations(const std::vector<PointAnnotation>&); - uint32_t addShapeAnnotation(const ShapeAnnotation&); + AnnotationID addShapeAnnotation(const ShapeAnnotation&); AnnotationIDs addShapeAnnotations(const std::vector<ShapeAnnotation>&); - void removeAnnotation(uint32_t); + void removeAnnotation(AnnotationID); void removeAnnotations(const AnnotationIDs&); AnnotationIDs getAnnotationsInBounds(const LatLngBounds&, const AnnotationType& = AnnotationType::Any); diff --git a/src/mbgl/annotation/annotation_manager.hpp b/src/mbgl/annotation/annotation_manager.hpp index 248fb798d6..2173442da8 100644 --- a/src/mbgl/annotation/annotation_manager.hpp +++ b/src/mbgl/annotation/annotation_manager.hpp @@ -1,7 +1,7 @@ #ifndef MBGL_MAP_ANNOTATIONS #define MBGL_MAP_ANNOTATIONS -#include <mbgl/map/map.hpp> +#include <mbgl/annotation/annotation.hpp> #include <mbgl/map/geometry_tile.hpp> #include <mbgl/map/tile_id.hpp> #include <mbgl/style/style_properties.hpp> diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index 0e50dae673..2fce648f2e 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -349,7 +349,7 @@ double Map::getTopOffsetPixelsForAnnotationSymbol(const std::string& symbol) { return context->invokeSync<double>(&MapContext::getTopOffsetPixelsForAnnotationSymbol, symbol); } -uint32_t Map::addPointAnnotation(const PointAnnotation& annotation) { +AnnotationID Map::addPointAnnotation(const PointAnnotation& annotation) { return addPointAnnotations({ annotation }).front(); } @@ -359,7 +359,7 @@ AnnotationIDs Map::addPointAnnotations(const std::vector<PointAnnotation>& annot return result; } -uint32_t Map::addShapeAnnotation(const ShapeAnnotation& annotation) { +AnnotationID Map::addShapeAnnotation(const ShapeAnnotation& annotation) { return addShapeAnnotations({ annotation }).front(); } @@ -369,20 +369,20 @@ AnnotationIDs Map::addShapeAnnotations(const std::vector<ShapeAnnotation>& annot return result; } -void Map::removeAnnotation(uint32_t annotation) { +void Map::removeAnnotation(AnnotationID annotation) { removeAnnotations({ annotation }); } -void Map::removeAnnotations(const std::vector<uint32_t>& annotations) { +void Map::removeAnnotations(const AnnotationIDs& annotations) { data->getAnnotationManager()->removeAnnotations(annotations, getMaxZoom()); update(Update::Annotations); } -std::vector<uint32_t> Map::getAnnotationsInBounds(const LatLngBounds& bounds, const AnnotationType& type) { +AnnotationIDs Map::getAnnotationsInBounds(const LatLngBounds& bounds, const AnnotationType& type) { return data->getAnnotationManager()->getAnnotationsInBounds(bounds, getMaxZoom(), type); } -LatLngBounds Map::getBoundsForAnnotations(const std::vector<uint32_t>& annotations) { +LatLngBounds Map::getBoundsForAnnotations(const AnnotationIDs& annotations) { return data->getAnnotationManager()->getBoundsForAnnotations(annotations); } |