summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2017-04-25 12:56:59 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-05-02 08:45:09 -0700
commitc2b00378b78b55d50968a9b11ed75bb4edf62ec9 (patch)
tree12a164d821dcdeb84d8a88dc231b3f2f9bef8ffd /platform
parenta2350320988bd881e261f92930b2d3359ff2071e (diff)
downloadqtlocation-mapboxgl-c2b00378b78b55d50968a9b11ed75bb4edf62ec9.tar.gz
[all] Push querySourceFeatures back out to Map
Once Source and RendererSource are split, Source will no longer have access to tiles.
Diffstat (limited to 'platform')
-rw-r--r--platform/android/src/style/sources/geojson_source.cpp6
-rw-r--r--platform/android/src/style/sources/vector_source.cpp7
-rw-r--r--platform/darwin/src/MGLShapeSource.mm5
-rw-r--r--platform/darwin/src/MGLSource.mm4
-rw-r--r--platform/darwin/src/MGLSource_Private.h8
-rw-r--r--platform/darwin/src/MGLVectorSource.mm7
6 files changed, 30 insertions, 7 deletions
diff --git a/platform/android/src/style/sources/geojson_source.cpp b/platform/android/src/style/sources/geojson_source.cpp
index c201cdade1..9b56446e31 100644
--- a/platform/android/src/style/sources/geojson_source.cpp
+++ b/platform/android/src/style/sources/geojson_source.cpp
@@ -102,8 +102,10 @@ namespace android {
using namespace mbgl::android::conversion;
using namespace mbgl::android::geojson;
- auto filter = toFilter(env, jfilter);
- auto features = source.querySourceFeatures({ {}, filter });
+ std::vector<mbgl::Feature> features;
+ if (map) {
+ features = map->querySourceFeatures(source.getID(), { {}, toFilter(env, jfilter) });
+ }
return *convert<jni::Array<jni::Object<Feature>>, std::vector<mbgl::Feature>>(env, features);
}
diff --git a/platform/android/src/style/sources/vector_source.cpp b/platform/android/src/style/sources/vector_source.cpp
index 53aa144450..a8f74df142 100644
--- a/platform/android/src/style/sources/vector_source.cpp
+++ b/platform/android/src/style/sources/vector_source.cpp
@@ -40,9 +40,10 @@ namespace android {
using namespace mbgl::android::conversion;
using namespace mbgl::android::geojson;
- mbgl::optional<std::vector<std::string>> sourceLayerIds = { toVector(env, jSourceLayerIds) };
- auto filter = toFilter(env, jfilter);
- auto features = source.querySourceFeatures({ sourceLayerIds, filter });
+ std::vector<mbgl::Feature> features;
+ if (map) {
+ features = map->querySourceFeatures(source.getID(), { toVector(env, jSourceLayerIds), toFilter(env, jfilter) });
+ }
return *convert<jni::Array<jni::Object<Feature>>, std::vector<mbgl::Feature>>(env, features);
}
diff --git a/platform/darwin/src/MGLShapeSource.mm b/platform/darwin/src/MGLShapeSource.mm
index 15437ebedb..023a81bba8 100644
--- a/platform/darwin/src/MGLShapeSource.mm
+++ b/platform/darwin/src/MGLShapeSource.mm
@@ -95,7 +95,10 @@ const MGLShapeSourceOption MGLShapeSourceOptionSimplificationTolerance = @"MGLSh
optionalFilter = predicate.mgl_filter;
}
- std::vector<mbgl::Feature> features = self.rawSource->querySourceFeatures({ {}, optionalFilter });
+ std::vector<mbgl::Feature> features;
+ if (self.mapView) {
+ features = self.mapView.mbglMap->querySourceFeatures(self.rawSource->getID(), { {}, optionalFilter });
+ }
return MGLFeaturesFromMBGLFeatures(features);
}
diff --git a/platform/darwin/src/MGLSource.mm b/platform/darwin/src/MGLSource.mm
index 59c2ae13e6..eb859ba2c0 100644
--- a/platform/darwin/src/MGLSource.mm
+++ b/platform/darwin/src/MGLSource.mm
@@ -10,6 +10,8 @@
// special internal source types like mbgl::AnnotationSource.
@property (nonatomic, readonly) mbgl::style::Source *rawSource;
+@property (nonatomic, readonly, weak) MGLMapView *mapView;
+
@end
@implementation MGLSource {
@@ -48,12 +50,14 @@
"to the style more than once is invalid.", self, mapView.style];
}
+ _mapView = mapView;
mapView.mbglMap->addSource(std::move(_pendingSource));
}
- (void)removeFromMapView:(MGLMapView *)mapView {
if (self.rawSource == mapView.mbglMap->getSource(self.identifier.UTF8String)) {
_pendingSource = mapView.mbglMap->removeSource(self.identifier.UTF8String);
+ _mapView = nil;
}
}
diff --git a/platform/darwin/src/MGLSource_Private.h b/platform/darwin/src/MGLSource_Private.h
index 6f86e4800b..91bfac6390 100644
--- a/platform/darwin/src/MGLSource_Private.h
+++ b/platform/darwin/src/MGLSource_Private.h
@@ -44,6 +44,14 @@ struct SourceWrapper {
@property (nonatomic, readonly) mbgl::style::Source *rawSource;
/**
+ The map view whose style currently contains the source.
+
+ If the source is not currently part of any map view’s style, this property is
+ set to `nil`.
+ */
+@property (nonatomic, readonly, weak) MGLMapView *mapView;
+
+/**
Adds the mbgl source that this object represents to the mbgl map.
Once a mbgl source is added, ownership of the object is transferred to the
diff --git a/platform/darwin/src/MGLVectorSource.mm b/platform/darwin/src/MGLVectorSource.mm
index afce3bad46..5e9f4f4a6e 100644
--- a/platform/darwin/src/MGLVectorSource.mm
+++ b/platform/darwin/src/MGLVectorSource.mm
@@ -3,9 +3,11 @@
#import "MGLFeature_Private.h"
#import "MGLSource_Private.h"
#import "MGLTileSource_Private.h"
+#import "MGLMapView_Private.h"
#import "NSPredicate+MGLAdditions.h"
#import "NSURL+MGLAdditions.h"
+#include <mbgl/map/map.hpp>
#include <mbgl/style/sources/vector_source.hpp>
@interface MGLVectorSource ()
@@ -59,7 +61,10 @@
optionalFilter = predicate.mgl_filter;
}
- std::vector<mbgl::Feature> features = self.rawSource->querySourceFeatures({ optionalSourceLayerIDs, optionalFilter });
+ std::vector<mbgl::Feature> features;
+ if (self.mapView) {
+ features = self.mapView.mbglMap->querySourceFeatures(self.rawSource->getID(), { optionalSourceLayerIDs, optionalFilter });
+ }
return MGLFeaturesFromMBGLFeatures(features);
}