summaryrefslogtreecommitdiff
path: root/platform/darwin/src/MGLFeature.mm
diff options
context:
space:
mode:
authorFredrik Karlsson <bjorn.fredrik.karlsson@gmail.com>2016-08-17 13:38:02 +0200
committerFredrik Karlsson <bjorn.fredrik.karlsson@gmail.com>2016-09-02 22:42:05 +0200
commitd77a13eb7320722c48c8a18240adf99615c4b85f (patch)
tree1017781b310e434f943e4ad38b57f319ad7a3a58 /platform/darwin/src/MGLFeature.mm
parent6a39cf5aaece81c7a531b12321dd503004cc45b8 (diff)
downloadqtlocation-mapboxgl-d77a13eb7320722c48c8a18240adf99615c4b85f.tar.gz
[ios] Added support for filters (NSPredicate)
[ios, macos] cleaned up filters [ios] added a filter example [ios] utest filters [ios, macos] nested predicates [ios] refactored [ios] filter -> NSPredicate [ios] fixed mbgl::Any/AllFilter -> NSPredicate [ios] translate nested mbgl::NotIn filters [ios] cleanup and added more utests [ios] fixed a bug in the None filter conversion and improved utests [ios, macos] doc [macos] added missing category [ios, macos] additional utests [ios, macos] updated documentation
Diffstat (limited to 'platform/darwin/src/MGLFeature.mm')
-rw-r--r--platform/darwin/src/MGLFeature.mm51
1 files changed, 4 insertions, 47 deletions
diff --git a/platform/darwin/src/MGLFeature.mm b/platform/darwin/src/MGLFeature.mm
index 3bf1e61153..6d4f76a71d 100644
--- a/platform/darwin/src/MGLFeature.mm
+++ b/platform/darwin/src/MGLFeature.mm
@@ -3,6 +3,7 @@
#import "MGLPointAnnotation.h"
#import "MGLPolyline.h"
#import "MGLPolygon.h"
+#import "MGLValueEvaluator.h"
#import "MGLMultiPoint_Private.h"
@@ -113,51 +114,7 @@
@end
-/**
- Recursively transforms a C++ type into the corresponding Foundation type.
- */
-class PropertyValueEvaluator {
-public:
- id operator()(const mbgl::NullValue &) const {
- return [NSNull null];
- }
-
- id operator()(const bool &value) const {
- return value ? @YES : @NO;
- }
-
- id operator()(const uint64_t &value) const {
- return @(value);
- }
-
- id operator()(const int64_t &value) const {
- return @(value);
- }
-
- id operator()(const double &value) const {
- return @(value);
- }
-
- id operator()(const std::string &value) const {
- return @(value.c_str());
- }
-
- id operator()(const std::vector<mbgl::Value> &values) const {
- NSMutableArray *objects = [NSMutableArray arrayWithCapacity:values.size()];
- for (const auto &v : values) {
- [objects addObject:mbgl::Value::visit(v, *this)];
- }
- return objects;
- }
-
- id operator()(const std::unordered_map<std::string, mbgl::Value> &items) const {
- NSMutableDictionary *attributes = [NSMutableDictionary dictionaryWithCapacity:items.size()];
- for (auto &item : items) {
- attributes[@(item.first.c_str())] = mbgl::Value::visit(item.second, *this);
- }
- return attributes;
- }
-};
+
/**
Transforms an `mbgl::geometry::geometry` type into an instance of the
@@ -253,14 +210,14 @@ NS_ARRAY_OF(MGLShape <MGLFeature> *) *MGLFeaturesFromMBGLFeatures(const std::vec
NSMutableDictionary *attributes = [NSMutableDictionary dictionaryWithCapacity:feature.properties.size()];
for (auto &pair : feature.properties) {
auto &value = pair.second;
- PropertyValueEvaluator evaluator;
+ ValueEvaluator evaluator;
attributes[@(pair.first.c_str())] = mbgl::Value::visit(value, evaluator);
}
GeometryEvaluator<double> evaluator;
MGLShape <MGLFeaturePrivate> *shape = mapbox::geometry::geometry<double>::visit(feature.geometry, evaluator);
if (feature.id) {
- shape.identifier = mbgl::FeatureIdentifier::visit(*feature.id, PropertyValueEvaluator());
+ shape.identifier = mbgl::FeatureIdentifier::visit(*feature.id, ValueEvaluator());
}
shape.attributes = attributes;
[shapes addObject:shape];