diff options
Diffstat (limited to 'platform/darwin')
-rw-r--r-- | platform/darwin/src/MGLFeature.h | 18 | ||||
-rw-r--r-- | platform/darwin/src/MGLFeature.mm | 4 | ||||
-rw-r--r-- | platform/darwin/src/MGLMultiPoint.mm | 4 | ||||
-rw-r--r-- | platform/darwin/src/MGLPolygon.mm | 6 | ||||
-rw-r--r-- | platform/darwin/src/MGLPolyline.mm | 6 | ||||
-rw-r--r-- | platform/darwin/src/headless_view_cgl.cpp | 2 | ||||
-rw-r--r-- | platform/darwin/src/log_nslog.mm | 3 | ||||
-rw-r--r-- | platform/darwin/src/settings_nsuserdefaults.mm | 60 | ||||
-rw-r--r-- | platform/darwin/test/MGLFeatureTests.mm | 2 |
9 files changed, 28 insertions, 77 deletions
diff --git a/platform/darwin/src/MGLFeature.h b/platform/darwin/src/MGLFeature.h index 69cff6b054..1ab587ede5 100644 --- a/platform/darwin/src/MGLFeature.h +++ b/platform/darwin/src/MGLFeature.h @@ -29,13 +29,23 @@ NS_ASSUME_NONNULL_BEGIN An object that uniquely identifies the feature in its containing <a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources">tile source</a>. - The value of this property is currently always an `NSNumber` object but may in - the future be an instance of another class, such as `NSString`. - The identifier corresponds to the <a href="https://github.com/mapbox/vector-tile-spec/tree/master/2.1#42-features">feature identifier</a> (`id`) in the tile source. If the source does not specify the feature’s - identifier, the value of this property is `nil`. + identifier, the value of this property is `nil`. If specified, the identifier + may be an integer, floating-point number, or string. These data types are + mapped to instances of the following Foundation classes: + + <table> + <thead> + <tr><th>In the tile source</th><th>This property</th></tr> + </thead> + <tbody> + <tr><td>Integer</td> <td><code>NSNumber</code> (use the <code>unsignedLongLongValue</code> or <code>longLongValue</code> property)</td></tr> + <tr><td>Floating-point number</td> <td><code>NSNumber</code> (use the <code>doubleValue</code> property)</td></tr> + <tr><td>String</td> <td><code>NSString</code></td></tr> + </tbody> + </table> For details about the identifiers used in most Mapbox-provided styles, consult the diff --git a/platform/darwin/src/MGLFeature.mm b/platform/darwin/src/MGLFeature.mm index 777b296303..3bf1e61153 100644 --- a/platform/darwin/src/MGLFeature.mm +++ b/platform/darwin/src/MGLFeature.mm @@ -118,7 +118,7 @@ */ class PropertyValueEvaluator { public: - id operator()(const std::nullptr_t &) const { + id operator()(const mbgl::NullValue &) const { return [NSNull null]; } @@ -260,7 +260,7 @@ NS_ARRAY_OF(MGLShape <MGLFeature> *) *MGLFeaturesFromMBGLFeatures(const std::vec GeometryEvaluator<double> evaluator; MGLShape <MGLFeaturePrivate> *shape = mapbox::geometry::geometry<double>::visit(feature.geometry, evaluator); if (feature.id) { - shape.identifier = @(*feature.id); + shape.identifier = mbgl::FeatureIdentifier::visit(*feature.id, PropertyValueEvaluator()); } shape.attributes = attributes; [shapes addObject:shape]; diff --git a/platform/darwin/src/MGLMultiPoint.mm b/platform/darwin/src/MGLMultiPoint.mm index 6084535d05..a5b9eb8efc 100644 --- a/platform/darwin/src/MGLMultiPoint.mm +++ b/platform/darwin/src/MGLMultiPoint.mm @@ -5,11 +5,11 @@ mbgl::Color MGLColorObjectFromCGColorRef(CGColorRef cgColor) { if (!cgColor) { - return {{ 0, 0, 0, 0 }}; + return { 0, 0, 0, 0 }; } NSCAssert(CGColorGetNumberOfComponents(cgColor) >= 4, @"Color must have at least 4 components"); const CGFloat *components = CGColorGetComponents(cgColor); - return {{ (float)components[0], (float)components[1], (float)components[2], (float)components[3] }}; + return { (float)components[0], (float)components[1], (float)components[2], (float)components[3] }; } @implementation MGLMultiPoint diff --git a/platform/darwin/src/MGLPolygon.mm b/platform/darwin/src/MGLPolygon.mm index c009d9e3d6..b8f02b6406 100644 --- a/platform/darwin/src/MGLPolygon.mm +++ b/platform/darwin/src/MGLPolygon.mm @@ -44,9 +44,9 @@ } mbgl::FillAnnotation annotation { geometry }; - annotation.opacity = [delegate alphaForShapeAnnotation:self]; - annotation.outlineColor = [delegate strokeColorForShapeAnnotation:self]; - annotation.color = [delegate fillColorForPolygonAnnotation:self]; + annotation.opacity = { static_cast<float>([delegate alphaForShapeAnnotation:self]) }; + annotation.outlineColor = { [delegate strokeColorForShapeAnnotation:self] }; + annotation.color = { [delegate fillColorForPolygonAnnotation:self] }; return annotation; } diff --git a/platform/darwin/src/MGLPolyline.mm b/platform/darwin/src/MGLPolyline.mm index 15ea5a0952..b81147a3ba 100644 --- a/platform/darwin/src/MGLPolyline.mm +++ b/platform/darwin/src/MGLPolyline.mm @@ -24,9 +24,9 @@ } mbgl::LineAnnotation annotation { geometry }; - annotation.opacity = [delegate alphaForShapeAnnotation:self]; - annotation.color = [delegate strokeColorForShapeAnnotation:self]; - annotation.width = [delegate lineWidthForPolylineAnnotation:self]; + annotation.opacity = { static_cast<float>([delegate alphaForShapeAnnotation:self]) }; + annotation.color = { [delegate strokeColorForShapeAnnotation:self] }; + annotation.width = { static_cast<float>([delegate lineWidthForPolylineAnnotation:self]) }; return annotation; } diff --git a/platform/darwin/src/headless_view_cgl.cpp b/platform/darwin/src/headless_view_cgl.cpp index a4f809a250..dc58463b5d 100644 --- a/platform/darwin/src/headless_view_cgl.cpp +++ b/platform/darwin/src/headless_view_cgl.cpp @@ -19,7 +19,7 @@ gl::glProc HeadlessView::initializeExtension(const char* name) { } void HeadlessView::createContext() { - CGLError error = CGLCreateContext(display->pixelFormat, NULL, &glContext); + CGLError error = CGLCreateContext(display->pixelFormat, nullptr, &glContext); if (error != kCGLNoError) { throw std::runtime_error(std::string("Error creating GL context object:") + CGLErrorString(error) + "\n"); } diff --git a/platform/darwin/src/log_nslog.mm b/platform/darwin/src/log_nslog.mm index a2e31968ab..49583ae3c4 100644 --- a/platform/darwin/src/log_nslog.mm +++ b/platform/darwin/src/log_nslog.mm @@ -1,4 +1,5 @@ #include <mbgl/platform/log.hpp> +#include <mbgl/util/enum.hpp> #import <Foundation/Foundation.h> @@ -7,7 +8,7 @@ namespace mbgl { void Log::platformRecord(EventSeverity severity, const std::string &msg) { NSString *message = [[NSString alloc] initWithBytes:msg.data() length:msg.size() encoding:NSUTF8StringEncoding]; - NSLog(@"[%s] %@", EventSeverityClass(severity).c_str(), message); + NSLog(@"[%s] %@", Enum<EventSeverity>::toString(severity), message); } } diff --git a/platform/darwin/src/settings_nsuserdefaults.mm b/platform/darwin/src/settings_nsuserdefaults.mm deleted file mode 100644 index 548ee9b220..0000000000 --- a/platform/darwin/src/settings_nsuserdefaults.mm +++ /dev/null @@ -1,60 +0,0 @@ -#import <Foundation/Foundation.h> - -#include <mbgl/platform/darwin/settings_nsuserdefaults.hpp> - -using namespace mbgl; - -Settings_NSUserDefaults::Settings_NSUserDefaults() -{ - [[NSUserDefaults standardUserDefaults] registerDefaults:@{ - @"longitude" : @(longitude), - @"latitude" : @(latitude), - @"zoom" : @(zoom), - @"bearing" : @(bearing), - @"pitch" : @(pitch), - @"userTrackingMode" : @(userTrackingMode), - @"showsUserLocation" : @(showsUserLocation), - @"debug" : @(debug), - }]; - load(); -} - -void Settings_NSUserDefaults::load() -{ - NSDictionary *settings = [[NSUserDefaults standardUserDefaults] dictionaryRepresentation]; - - longitude = [settings[@"longitude"] doubleValue]; - latitude = [settings[@"latitude"] doubleValue]; - zoom = [settings[@"zoom"] doubleValue]; - bearing = [settings[@"bearing"] doubleValue]; - pitch = [settings[@"pitch"] doubleValue]; - debug = [settings[@"debug"] boolValue]; - - unsigned uncheckedTrackingMode = [settings[@"userTrackingMode"] unsignedIntValue]; - if (uncheckedTrackingMode > MGLUserTrackingModeNone && - uncheckedTrackingMode <= MGLUserTrackingModeFollowWithCourse) - { - userTrackingMode = (MGLUserTrackingMode)uncheckedTrackingMode; - } - showsUserLocation = [settings[@"showsUserLocation"] boolValue]; -} - -void Settings_NSUserDefaults::save() -{ - [[NSUserDefaults standardUserDefaults] setValuesForKeysWithDictionary:@{ - @"longitude" : @(longitude), - @"latitude" : @(latitude), - @"zoom" : @(zoom), - @"bearing" : @(bearing), - @"pitch" : @(pitch), - @"userTrackingMode" : @(userTrackingMode), - @"showsUserLocation" : @(showsUserLocation), - @"debug" : @(debug), - }]; - [[NSUserDefaults standardUserDefaults] synchronize]; -} - -void Settings_NSUserDefaults::clear() -{ - [NSUserDefaults resetStandardUserDefaults]; -} diff --git a/platform/darwin/test/MGLFeatureTests.mm b/platform/darwin/test/MGLFeatureTests.mm index 6cf038d4fb..13ad8759b0 100644 --- a/platform/darwin/test/MGLFeatureTests.mm +++ b/platform/darwin/test/MGLFeatureTests.mm @@ -89,7 +89,7 @@ mapbox::geometry::point<double> point = { -90.066667, 29.95 }; mbgl::Feature pointFeature(point); - pointFeature.id = UINT64_MAX; + pointFeature.id = { UINT64_MAX }; pointFeature.properties["null"] = nullptr; pointFeature.properties["bool"] = true; pointFeature.properties["unsigned int"] = UINT64_MAX; |