From 597b2b48511b68c7a6494386b414da479c436bd7 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Thu, 15 Oct 2015 11:38:58 -0700 Subject: [PATCH] [core] Pull annotation typedefs to own header; add AnnotationID --- include/mbgl/annotation/annotation.hpp | 20 ++++++++++++++++++++ include/mbgl/annotation/shape_annotation.hpp | 8 +++++--- include/mbgl/map/map.hpp | 17 ++++------------- src/mbgl/annotation/annotation_manager.hpp | 2 +- src/mbgl/map/map.cpp | 12 ++++++------ 5 files changed, 36 insertions(+), 23 deletions(-) create mode 100644 include/mbgl/annotation/annotation.hpp diff --git a/include/mbgl/annotation/annotation.hpp b/include/mbgl/annotation/annotation.hpp new file mode 100644 index 000000000..fd21cd5f6 --- /dev/null +++ b/include/mbgl/annotation/annotation.hpp @@ -0,0 +1,20 @@ +#ifndef MBGL_ANNOTATION +#define MBGL_ANNOTATION + +#include +#include + +namespace mbgl { + +enum class AnnotationType : uint8_t { + Any = 0, + Point = 1 << 0, + Shape = 1 << 1, +}; + +using AnnotationID = uint32_t; +using AnnotationIDs = std::vector; + +} + +#endif diff --git a/include/mbgl/annotation/shape_annotation.hpp b/include/mbgl/annotation/shape_annotation.hpp index a35b86726..dd8bf5e4d 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 -#include +#include #include -#include +#include namespace mbgl { +using AnnotationSegment = std::vector; +using AnnotationSegments = std::vector; + 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 69499c511..8a381cda6 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -31,12 +32,6 @@ namespace util { template 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; -using AnnotationSegment = std::vector; -using AnnotationSegments = std::vector; - 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&); - uint32_t addShapeAnnotation(const ShapeAnnotation&); + AnnotationID addShapeAnnotation(const ShapeAnnotation&); AnnotationIDs addShapeAnnotations(const std::vector&); - 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 248fb798d..2173442da 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 +#include #include #include #include diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index 0e50dae67..2fce648f2 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(&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& 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& annot return result; } -void Map::removeAnnotation(uint32_t annotation) { +void Map::removeAnnotation(AnnotationID annotation) { removeAnnotations({ annotation }); } -void Map::removeAnnotations(const std::vector& annotations) { +void Map::removeAnnotations(const AnnotationIDs& annotations) { data->getAnnotationManager()->removeAnnotations(annotations, getMaxZoom()); update(Update::Annotations); } -std::vector 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& annotations) { +LatLngBounds Map::getBoundsForAnnotations(const AnnotationIDs& annotations) { return data->getAnnotationManager()->getBoundsForAnnotations(annotations); }