summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2015-06-26 18:49:06 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2015-06-29 10:54:17 -0700
commit42c06e70392941a9c07b842f019c4b060f716ff7 (patch)
tree18dfc09adcabc7239a738a416d7bac98b0ef50f9 /platform
parentf675d233142bbbfbe77c0145128c3eedfb18e824 (diff)
downloadqtlocation-mapboxgl-42c06e70392941a9c07b842f019c4b060f716ff7.tar.gz
Use array of structs rather than parallel arrays for annotations
Diffstat (limited to 'platform')
-rw-r--r--platform/default/glfw_view.cpp18
-rw-r--r--platform/ios/MGLMapView.mm27
2 files changed, 19 insertions, 26 deletions
diff --git a/platform/default/glfw_view.cpp b/platform/default/glfw_view.cpp
index 756b842695..fe37b398d2 100644
--- a/platform/default/glfw_view.cpp
+++ b/platform/default/glfw_view.cpp
@@ -1,3 +1,5 @@
+#include <mbgl/annotation/point_annotation.hpp>
+#include <mbgl/annotation/shape_annotation.hpp>
#include <mbgl/platform/default/glfw_view.hpp>
#include <mbgl/platform/gl.hpp>
#include <mbgl/platform/log.hpp>
@@ -149,21 +151,18 @@ mbgl::LatLng GLFWView::makeRandomPoint() const {
void GLFWView::addRandomPointAnnotations(int count) {
- std::vector<mbgl::LatLng> points;
- std::vector<std::string> markers;
+ std::vector<mbgl::PointAnnotation> points;
for (int i = 0; i < count; i++) {
- points.push_back(makeRandomPoint());
- markers.push_back("default_marker");
+ points.emplace_back(makeRandomPoint(), "default_marker");
}
- auto newIDs = map->addPointAnnotations(points, markers);
+ auto newIDs = map->addPointAnnotations(points);
annotationIDs.insert(annotationIDs.end(), newIDs.begin(), newIDs.end());
}
void GLFWView::addRandomShapeAnnotations(int count) {
- std::vector<mbgl::AnnotationSegments> shapes;
- std::vector<mbgl::StyleProperties> shapesProperties;
+ std::vector<mbgl::ShapeAnnotation> shapes;
mbgl::FillProperties fillProperties;
fillProperties.opacity = .1;
@@ -180,11 +179,10 @@ void GLFWView::addRandomShapeAnnotations(int count) {
mbgl::AnnotationSegments segments;
segments.push_back(triangle);
- shapes.push_back(segments);
- shapesProperties.push_back(properties);
+ shapes.emplace_back(segments, properties);
}
- auto newIDs = map->addShapeAnnotations(shapes, shapesProperties);
+ auto newIDs = map->addShapeAnnotations(shapes);
annotationIDs.insert(annotationIDs.end(), newIDs.begin(), newIDs.end());
}
diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm
index 07822dd03e..5395964314 100644
--- a/platform/ios/MGLMapView.mm
+++ b/platform/ios/MGLMapView.mm
@@ -8,6 +8,8 @@
#import <OpenGLES/EAGL.h>
#include <mbgl/mbgl.hpp>
+#include <mbgl/annotation/point_annotation.hpp>
+#include <mbgl/annotation/shape_annotation.hpp>
#include <mbgl/platform/platform.hpp>
#include <mbgl/platform/darwin/reachability.h>
#include <mbgl/storage/default_file_source.hpp>
@@ -1780,11 +1782,8 @@ CLLocationCoordinate2D MGLLocationCoordinate2DFromLatLng(mbgl::LatLng latLng)
{
if ( ! annotations) return;
- std::vector<mbgl::LatLng> points;
- std::vector<std::string> symbols;
-
- std::vector<mbgl::AnnotationSegments> shapes;
- std::vector<mbgl::StyleProperties> shapesProperties;
+ std::vector<mbgl::PointAnnotation> points;
+ std::vector<mbgl::ShapeAnnotation> shapes;
BOOL delegateImplementsSymbolLookup = [self.delegate respondsToSelector:@selector(mapView:symbolNameForAnnotation:)];
BOOL delegateImplementsAlphaForShape = [self.delegate respondsToSelector:@selector(mapView:alphaForShapeAnnotation:)];
@@ -1851,29 +1850,25 @@ CLLocationCoordinate2D MGLLocationCoordinate2DFromLatLng(mbgl::LatLng latLng)
userInfo:nil] raise];
}
- shapesProperties.push_back(shapeProperties);
-
NSUInteger count = [(MGLMultiPoint *)annotation pointCount];
CLLocationCoordinate2D *coordinates = (CLLocationCoordinate2D *)malloc(count * sizeof(CLLocationCoordinate2D));
[(MGLMultiPoint *)annotation getCoordinates:coordinates range:NSMakeRange(0, count)];
- mbgl::AnnotationSegment shape;
- shape.reserve(count);
+ mbgl::AnnotationSegment segment;
+ segment.reserve(count);
for (NSUInteger i = 0; i < count; i++)
{
- shape.push_back(mbgl::LatLng(coordinates[i].latitude, coordinates[i].longitude));
+ segment.push_back(mbgl::LatLng(coordinates[i].latitude, coordinates[i].longitude));
}
free(coordinates);
- shapes.push_back({{ shape }});
+ shapes.emplace_back(mbgl::AnnotationSegments {{ segment }}, shapeProperties);
}
else
{
- points.push_back(MGLLatLngFromLocationCoordinate2D(annotation.coordinate));
-
NSString *symbolName = nil;
if (delegateImplementsSymbolLookup)
@@ -1881,13 +1876,13 @@ CLLocationCoordinate2D MGLLocationCoordinate2DFromLatLng(mbgl::LatLng latLng)
symbolName = [self.delegate mapView:self symbolNameForAnnotation:annotation];
}
- symbols.push_back((symbolName ? [symbolName UTF8String] : ""));
+ points.emplace_back(MGLLatLngFromLocationCoordinate2D(annotation.coordinate), symbolName ? [symbolName UTF8String] : "");
}
}
if (points.size())
{
- std::vector<uint32_t> pointAnnotationIDs = _mbglMap->addPointAnnotations(points, symbols);
+ std::vector<uint32_t> pointAnnotationIDs = _mbglMap->addPointAnnotations(points);
for (size_t i = 0; i < pointAnnotationIDs.size(); ++i)
{
@@ -1898,7 +1893,7 @@ CLLocationCoordinate2D MGLLocationCoordinate2DFromLatLng(mbgl::LatLng latLng)
if (shapes.size())
{
- std::vector<uint32_t> shapeAnnotationIDs = _mbglMap->addShapeAnnotations(shapes, shapesProperties);
+ std::vector<uint32_t> shapeAnnotationIDs = _mbglMap->addShapeAnnotations(shapes);
for (size_t i = 0; i < shapeAnnotationIDs.size(); ++i)
{