summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2016-12-13 17:36:15 -0800
committerGitHub <noreply@github.com>2016-12-13 17:36:15 -0800
commitef71597932820fa09426d43a4e86e025d0628738 (patch)
treef8e0af2fc235859eb75bc00d97ea180ee68c9d73 /platform
parentb221b6c5fb8ed3360c74a38266b4321e94c10659 (diff)
downloadqtlocation-mapboxgl-ef71597932820fa09426d43a4e86e025d0628738.tar.gz
[ios, macos] Simplify MGLSource and subclasses (#7377)
* [ios, macos] Audited source headers for nullability * [macos] Made MGLTileSet public * [ios, macos] Replaced MGLTileSet with MGLTileSource MGLRasterSource and MGLVectorSource now share a common abstract superclass, MGLTileSource. MGLTileSet has been removed. MGLTileSource is modeled after mbgl::style::RasterSource and mbgl::style::VectorSource. It has initializers that incorporate the parameters of MGLTileSet’s initializers, but it lacks getters for everything but the attribution string. MGLTileSet’s properties have been converted into options that can be passed into MGLTileSource’s initializers in a dictionary. Properly implement rawSource as a covariant property so that it doesn’t end up getting autosynthesized as a shadow ivar. This prevents concrete subclasses of MGLSource from setting _rawSource directly but getting a different value out of self.rawSource. Marked -[MGLSource init] as unavailable and ensured that concrete subclasses of MGLSource have the right set of initializers marked as designated initializers. Documentation comments for each concrete source class identify the corresponding source type in the style specification. Clarified the purpose of MGLTileSetScheme, now known as MGLTileCoordinateSystem. * [ios, macos] Clarified tile size interpretation Sticking to a default value of 256 for mapbox: URLs, but other URLs get the standard 512 value. * [ios, macos] rawSource is always set * [ios, macos] Cleaned up MGLShapeSource initialization rawSource is never nil, so there’s no need for a -commonInit method. Extracted -geoJSONOptions from MGLShapeSource into a standalone function for easier testing. * [ios, macos] Synchronized headers in project Realphabetized headers in groups. Added headers missing from one project or the other. * [ios, macos] Added MGLShape methods to (de)serialize GeoJSON data Added a class initializer and instance method to MGLShape that deserialize and serialize the shape as GeoJSON data, respectively. The new initializer handles parsing errors gracefully. Removed methods specific to GeoJSON data from MGLShapeSource, in an effort to reduce parallel state. Developers are now expected to go through the new MGLShape initializer to get an MGLShape representation. Alternatively, a local file URL can be passed into the other MGLShapeSource initializer. * [ios, macos] Typo in assertion message * [ios, macos] Simplified GeoJSON serialization Every MGLShape now knows its most specific mbgl::GeoJSON representation. * [ios, macos] Reremoved MGLFeaturePrivate mbgl::GeoJSON, which is a variant, allows a single GeoJSON representation method to traffic in whatever type is needed for a particular shape class. This change removes some hidden private protocols, which are a bug waiting to happen. * [ios, macos] Fixed covariant rawLayer property Properly implement rawLayer as a covariant property so that it doesn’t end up getting autosynthesized as a shadow ivar. This prevents concrete subclasses of MGLStyleLayer from setting _rawLayer directly but getting a different value out of self.rawLayer. * [ios, macos] Use MGLAttributionInfo for source attribution Made MGLAttributionInfo public. Replaced MGLTileSource’s attribution property with an attributionInfos property set to an array of MGLAttributionInfo objects. Added an MGLTileSourceOption for specifying an array of MGLAttributionInfo objects instead of an HTML string (either is acceptable when creating an MGLTileSource). * [ios, macos] Corrected method references in documentation
Diffstat (limited to 'platform')
-rw-r--r--platform/darwin/src/MGLAttributionInfo.h54
-rw-r--r--platform/darwin/src/MGLAttributionInfo.mm21
-rw-r--r--platform/darwin/src/MGLAttributionInfo_Private.h48
-rw-r--r--platform/darwin/src/MGLBackgroundStyleLayer.mm28
-rw-r--r--platform/darwin/src/MGLCircleStyleLayer.mm54
-rw-r--r--platform/darwin/src/MGLFeature.mm71
-rw-r--r--platform/darwin/src/MGLFeature_Private.h6
-rw-r--r--platform/darwin/src/MGLFillStyleLayer.mm54
-rw-r--r--platform/darwin/src/MGLLineStyleLayer.mm82
-rw-r--r--platform/darwin/src/MGLOpenGLStyleLayer.mm13
-rw-r--r--platform/darwin/src/MGLPointCollection.mm2
-rw-r--r--platform/darwin/src/MGLPolygon.mm2
-rw-r--r--platform/darwin/src/MGLPolyline.mm2
-rw-r--r--platform/darwin/src/MGLRasterSource.h115
-rw-r--r--platform/darwin/src/MGLRasterSource.mm107
-rw-r--r--platform/darwin/src/MGLRasterSource_Private.h4
-rw-r--r--platform/darwin/src/MGLRasterStyleLayer.mm45
-rw-r--r--platform/darwin/src/MGLShape.h35
-rw-r--r--platform/darwin/src/MGLShape.mm52
-rw-r--r--platform/darwin/src/MGLShapeCollectionFeature_Private.h13
-rw-r--r--platform/darwin/src/MGLShapeSource.h63
-rw-r--r--platform/darwin/src/MGLShapeSource.mm223
-rw-r--r--platform/darwin/src/MGLShapeSource_Private.h15
-rw-r--r--platform/darwin/src/MGLShape_Private.h6
-rw-r--r--platform/darwin/src/MGLSource.h10
-rw-r--r--platform/darwin/src/MGLSource_Private.h4
-rw-r--r--platform/darwin/src/MGLStyle.mm13
-rw-r--r--platform/darwin/src/MGLStyleLayer.mm.ejs42
-rw-r--r--platform/darwin/src/MGLStyleLayer_Private.h2
-rw-r--r--platform/darwin/src/MGLSymbolStyleLayer.mm218
-rw-r--r--platform/darwin/src/MGLTileSet.h82
-rw-r--r--platform/darwin/src/MGLTileSet.mm101
-rw-r--r--platform/darwin/src/MGLTileSet_Private.h24
-rw-r--r--platform/darwin/src/MGLTileSource.h179
-rw-r--r--platform/darwin/src/MGLTileSource.mm123
-rw-r--r--platform/darwin/src/MGLTileSource_Private.h36
-rw-r--r--platform/darwin/src/MGLVectorSource.h77
-rw-r--r--platform/darwin/src/MGLVectorSource.mm78
-rw-r--r--platform/darwin/src/MGLVectorSource_Private.h4
-rw-r--r--platform/darwin/src/NSArray+MGLAdditions.h3
-rw-r--r--platform/darwin/src/NSArray+MGLAdditions.mm15
-rw-r--r--platform/darwin/test/MGLAttributionInfoTests.m2
-rw-r--r--platform/darwin/test/MGLFeatureTests.mm2
-rw-r--r--platform/darwin/test/MGLFilterTests.mm6
-rw-r--r--platform/darwin/test/MGLGeometryTests.mm45
-rw-r--r--platform/darwin/test/MGLShapeSourceTests.mm37
-rw-r--r--platform/darwin/test/MGLStyleTests.mm10
-rw-r--r--platform/darwin/test/MGLTileSetTests.mm103
-rw-r--r--platform/ios/app/MBXViewController.m20
-rw-r--r--platform/ios/ios.xcodeproj/project.pbxproj76
-rw-r--r--platform/ios/jazzy.yml10
-rw-r--r--platform/ios/src/Mapbox.h3
-rw-r--r--platform/macos/jazzy.yml10
-rw-r--r--platform/macos/macos.xcodeproj/project.pbxproj58
-rw-r--r--platform/macos/src/Mapbox.h2
55 files changed, 1443 insertions, 1067 deletions
diff --git a/platform/darwin/src/MGLAttributionInfo.h b/platform/darwin/src/MGLAttributionInfo.h
index 84552722c9..7395e3f346 100644
--- a/platform/darwin/src/MGLAttributionInfo.h
+++ b/platform/darwin/src/MGLAttributionInfo.h
@@ -13,45 +13,49 @@ NS_ASSUME_NONNULL_BEGIN
@interface MGLAttributionInfo : NSObject
/**
- Parses and returns the attribution infos contained in the given HTML source
- code string.
+ Returns an initialized attribution info object with the given title and URL.
- @param htmlString The HTML source code to parse.
- @param fontSize The default text size in points.
- @param linkColor The default link color.
+ @param title The attribution statement’s title.
+ @param URL A URL to more information about the entity named in the attribution.
+ @return An initialized attribution info object.
*/
-+ (NS_ARRAY_OF(MGLAttributionInfo *) *)attributionInfosFromHTMLString:(NSString *)htmlString fontSize:(CGFloat)fontSize linkColor:(nullable MGLColor *)linkColor;
-
- (instancetype)initWithTitle:(NSAttributedString *)title URL:(nullable NSURL *)URL;
+/**
+ The attribution statement’s attributed title text.
+ */
@property (nonatomic) NSAttributedString *title;
-@property (nonatomic, nullable) NSURL *URL;
-@property (nonatomic, getter=isFeedbackLink) BOOL feedbackLink;
-
-- (nullable NSURL *)feedbackURLAtCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate zoomLevel:(double)zoomLevel;
-@end
-
-@interface NSMutableArray (MGLAttributionInfoAdditions)
+/**
+ The URL to more information about the entity named in the attribution.
+
+ If this property is set, the attribution statement should be displayed as a
+ hyperlink or action button. Otherwise, if it is `nil`, the attribution
+ statement should be displayed as plain text.
+ */
+@property (nonatomic, nullable) NSURL *URL;
/**
- Adds the given attribution info object to the receiver as long as it isn’t
- redundant to any object already in the receiver. Any existing object that is
- redundant to the given object is replaced by the given object.
+ A Boolean value indicating whether the attribution statement is a shortcut to a
+ feedback tool.
- @param info The info object to add to the receiver.
- @return True if the given info object was added to the receiver.
+ If this property is set, the statement should be treated as a way for the user
+ to provide feedback rather than an attribution statement.
*/
-- (void)growArrayByAddingAttributionInfo:(MGLAttributionInfo *)info;
+@property (nonatomic, getter=isFeedbackLink) BOOL feedbackLink;
/**
- Adds each of the given attribution info objects to the receiver as long as it
- isn’t redundant to any object already in the receiver. Any existing object that
- is redundant to the given object is replaced by the given object.
+ Returns a copy of the `URL` property modified to account for the given center
+ coordinate and zoom level.
- @param infos An array of info objects to add to the receiver.
+ @param centerCoordinate The map’s center coordinate.
+ @param zoomLevel The map’s zoom level. See `MGLMapView`’s `zoomLevel` property
+ for more information.
+ @return A modified URL containing a fragment that points to the specified
+ viewport. If the `feedbackLink` property is set to `NO`, this method returns
+ `nil`.
*/
-- (void)growArrayByAddingAttributionInfosFromArray:(NS_ARRAY_OF(MGLAttributionInfo *) *)infos;
+- (nullable NSURL *)feedbackURLAtCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate zoomLevel:(double)zoomLevel;
@end
diff --git a/platform/darwin/src/MGLAttributionInfo.mm b/platform/darwin/src/MGLAttributionInfo.mm
index 2719aef7ca..cf7b3cb22f 100644
--- a/platform/darwin/src/MGLAttributionInfo.mm
+++ b/platform/darwin/src/MGLAttributionInfo.mm
@@ -1,4 +1,4 @@
-#import "MGLAttributionInfo.h"
+#import "MGLAttributionInfo_Private.h"
#if TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
@@ -7,13 +7,18 @@
#endif
#import "MGLMapCamera.h"
+#import "NSArray+MGLAdditions.h"
#import "NSString+MGLAdditions.h"
#include <string>
@implementation MGLAttributionInfo
-+ (NS_ARRAY_OF(MGLAttributionInfo *) *)attributionInfosFromHTMLString:(NSString *)htmlString fontSize:(CGFloat)fontSize linkColor:(nullable MGLColor *)linkColor {
++ (NS_ARRAY_OF(MGLAttributionInfo *) *)attributionInfosFromHTMLString:(nullable NSString *)htmlString fontSize:(CGFloat)fontSize linkColor:(nullable MGLColor *)linkColor {
+ if (!htmlString) {
+ return @[];
+ }
+
NSDictionary *options = @{
NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType,
NSCharacterEncodingDocumentAttribute: @(NSUTF8StringEncoding),
@@ -84,6 +89,18 @@
return infos;
}
++ (NSAttributedString *)attributedStringForAttributionInfos:(NS_ARRAY_OF(MGLAttributionInfo *) *)attributionInfos {
+ NSMutableArray *titles = [NSMutableArray arrayWithCapacity:attributionInfos.count];
+ for (MGLAttributionInfo *info in attributionInfos) {
+ NSMutableAttributedString *title = info.title.mutableCopy;
+ if (info.URL) {
+ [title addAttribute:NSLinkAttributeName value:info.URL range:title.mgl_wholeRange];
+ }
+ [titles addObject:title];
+ }
+ return [titles mgl_attributedComponentsJoinedByString:@" "];
+}
+
- (instancetype)initWithTitle:(NSAttributedString *)title URL:(NSURL *)URL {
if (self = [super init]) {
_title = title;
diff --git a/platform/darwin/src/MGLAttributionInfo_Private.h b/platform/darwin/src/MGLAttributionInfo_Private.h
new file mode 100644
index 0000000000..c9a428b571
--- /dev/null
+++ b/platform/darwin/src/MGLAttributionInfo_Private.h
@@ -0,0 +1,48 @@
+#import <Foundation/Foundation.h>
+#import <CoreGraphics/CoreGraphics.h>
+#import <CoreLocation/CoreLocation.h>
+
+#import "MGLAttributionInfo.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface MGLAttributionInfo (Private)
+
+/**
+ Parses and returns the attribution infos contained in the given HTML source
+ code string.
+
+ @param htmlString The HTML source code to parse.
+ @param fontSize The default text size in points.
+ @param linkColor The default link color.
+ */
++ (NS_ARRAY_OF(MGLAttributionInfo *) *)attributionInfosFromHTMLString:(nullable NSString *)htmlString fontSize:(CGFloat)fontSize linkColor:(nullable MGLColor *)linkColor;
+
++ (NSAttributedString *)attributedStringForAttributionInfos:(NS_ARRAY_OF(MGLAttributionInfo *) *)attributionInfos;
+
+@end
+
+@interface NSMutableArray (MGLAttributionInfoAdditions)
+
+/**
+ Adds the given attribution info object to the receiver as long as it isn’t
+ redundant to any object already in the receiver. Any existing object that is
+ redundant to the given object is replaced by the given object.
+
+ @param info The info object to add to the receiver.
+ @return True if the given info object was added to the receiver.
+ */
+- (void)growArrayByAddingAttributionInfo:(MGLAttributionInfo *)info;
+
+/**
+ Adds each of the given attribution info objects to the receiver as long as it
+ isn’t redundant to any object already in the receiver. Any existing object that
+ is redundant to the given object is replaced by the given object.
+
+ @param infos An array of info objects to add to the receiver.
+ */
+- (void)growArrayByAddingAttributionInfosFromArray:(NS_ARRAY_OF(MGLAttributionInfo *) *)infos;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/platform/darwin/src/MGLBackgroundStyleLayer.mm b/platform/darwin/src/MGLBackgroundStyleLayer.mm
index 0ac25c39fe..6a76f6072e 100644
--- a/platform/darwin/src/MGLBackgroundStyleLayer.mm
+++ b/platform/darwin/src/MGLBackgroundStyleLayer.mm
@@ -26,11 +26,21 @@
if (self = [super initWithIdentifier:identifier]) {
auto layer = std::make_unique<mbgl::style::BackgroundLayer>(identifier.UTF8String);
_pendingLayer = std::move(layer);
- _rawLayer = _pendingLayer.get();
+ self.rawLayer = _pendingLayer.get();
}
return self;
}
+- (mbgl::style::BackgroundLayer *)rawLayer
+{
+ return (mbgl::style::BackgroundLayer *)super.rawLayer;
+}
+
+- (void)setRawLayer:(mbgl::style::BackgroundLayer *)rawLayer
+{
+ super.rawLayer = rawLayer;
+}
+
#pragma mark - Adding to and removing from a map view
- (void)addToMapView:(MGLMapView *)mapView belowLayer:(MGLStyleLayer *)otherLayer
@@ -52,7 +62,7 @@
- (void)removeFromMapView:(MGLMapView *)mapView
{
_pendingLayer = nullptr;
- _rawLayer = nullptr;
+ self.rawLayer = nullptr;
auto removedLayer = mapView.mbglMap->removeLayer(self.identifier.UTF8String);
if (!removedLayer) {
@@ -67,7 +77,7 @@
removedLayer.release();
_pendingLayer = std::unique_ptr<mbgl::style::BackgroundLayer>(layer);
- _rawLayer = _pendingLayer.get();
+ self.rawLayer = _pendingLayer.get();
}
#pragma mark - Accessing the Paint Attributes
@@ -76,13 +86,13 @@
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue(backgroundColor);
- _rawLayer->setBackgroundColor(mbglValue);
+ self.rawLayer->setBackgroundColor(mbglValue);
}
- (MGLStyleValue<MGLColor *> *)backgroundColor {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getBackgroundColor() ?: _rawLayer->getDefaultBackgroundColor();
+ auto propertyValue = self.rawLayer->getBackgroundColor() ?: self.rawLayer->getDefaultBackgroundColor();
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toStyleValue(propertyValue);
}
@@ -90,13 +100,13 @@
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(backgroundOpacity);
- _rawLayer->setBackgroundOpacity(mbglValue);
+ self.rawLayer->setBackgroundOpacity(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)backgroundOpacity {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getBackgroundOpacity() ?: _rawLayer->getDefaultBackgroundOpacity();
+ auto propertyValue = self.rawLayer->getBackgroundOpacity() ?: self.rawLayer->getDefaultBackgroundOpacity();
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}
@@ -104,13 +114,13 @@
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<std::string, NSString *>().toPropertyValue(backgroundPattern);
- _rawLayer->setBackgroundPattern(mbglValue);
+ self.rawLayer->setBackgroundPattern(mbglValue);
}
- (MGLStyleValue<NSString *> *)backgroundPattern {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getBackgroundPattern() ?: _rawLayer->getDefaultBackgroundPattern();
+ auto propertyValue = self.rawLayer->getBackgroundPattern() ?: self.rawLayer->getDefaultBackgroundPattern();
return MGLStyleValueTransformer<std::string, NSString *>().toStyleValue(propertyValue);
}
diff --git a/platform/darwin/src/MGLCircleStyleLayer.mm b/platform/darwin/src/MGLCircleStyleLayer.mm
index 90026490a6..0cd84453a2 100644
--- a/platform/darwin/src/MGLCircleStyleLayer.mm
+++ b/platform/darwin/src/MGLCircleStyleLayer.mm
@@ -39,15 +39,26 @@ namespace mbgl {
if (self = [super initWithIdentifier:identifier source:source]) {
auto layer = std::make_unique<mbgl::style::CircleLayer>(identifier.UTF8String, source.identifier.UTF8String);
_pendingLayer = std::move(layer);
- _rawLayer = _pendingLayer.get();
+ self.rawLayer = _pendingLayer.get();
}
return self;
}
+
+- (mbgl::style::CircleLayer *)rawLayer
+{
+ return (mbgl::style::CircleLayer *)super.rawLayer;
+}
+
+- (void)setRawLayer:(mbgl::style::CircleLayer *)rawLayer
+{
+ super.rawLayer = rawLayer;
+}
+
- (NSString *)sourceLayerIdentifier
{
MGLAssertStyleLayerIsValid();
- auto layerID = _rawLayer->getSourceLayer();
+ auto layerID = self.rawLayer->getSourceLayer();
return layerID.empty() ? nil : @(layerID.c_str());
}
@@ -55,22 +66,23 @@ namespace mbgl {
{
MGLAssertStyleLayerIsValid();
- _rawLayer->setSourceLayer(sourceLayerIdentifier.UTF8String ?: "");
+ self.rawLayer->setSourceLayer(sourceLayerIdentifier.UTF8String ?: "");
}
- (void)setPredicate:(NSPredicate *)predicate
{
MGLAssertStyleLayerIsValid();
- _rawLayer->setFilter(predicate.mgl_filter);
+ self.rawLayer->setFilter(predicate.mgl_filter);
}
- (NSPredicate *)predicate
{
MGLAssertStyleLayerIsValid();
- return [NSPredicate mgl_predicateWithFilter:_rawLayer->getFilter()];
+ return [NSPredicate mgl_predicateWithFilter:self.rawLayer->getFilter()];
}
+
#pragma mark - Adding to and removing from a map view
- (void)addToMapView:(MGLMapView *)mapView belowLayer:(MGLStyleLayer *)otherLayer
@@ -92,7 +104,7 @@ namespace mbgl {
- (void)removeFromMapView:(MGLMapView *)mapView
{
_pendingLayer = nullptr;
- _rawLayer = nullptr;
+ self.rawLayer = nullptr;
auto removedLayer = mapView.mbglMap->removeLayer(self.identifier.UTF8String);
if (!removedLayer) {
@@ -107,7 +119,7 @@ namespace mbgl {
removedLayer.release();
_pendingLayer = std::unique_ptr<mbgl::style::CircleLayer>(layer);
- _rawLayer = _pendingLayer.get();
+ self.rawLayer = _pendingLayer.get();
}
#pragma mark - Accessing the Paint Attributes
@@ -116,13 +128,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(circleBlur);
- _rawLayer->setCircleBlur(mbglValue);
+ self.rawLayer->setCircleBlur(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)circleBlur {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getCircleBlur() ?: _rawLayer->getDefaultCircleBlur();
+ auto propertyValue = self.rawLayer->getCircleBlur() ?: self.rawLayer->getDefaultCircleBlur();
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}
@@ -130,13 +142,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue(circleColor);
- _rawLayer->setCircleColor(mbglValue);
+ self.rawLayer->setCircleColor(mbglValue);
}
- (MGLStyleValue<MGLColor *> *)circleColor {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getCircleColor() ?: _rawLayer->getDefaultCircleColor();
+ auto propertyValue = self.rawLayer->getCircleColor() ?: self.rawLayer->getDefaultCircleColor();
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toStyleValue(propertyValue);
}
@@ -144,13 +156,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(circleOpacity);
- _rawLayer->setCircleOpacity(mbglValue);
+ self.rawLayer->setCircleOpacity(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)circleOpacity {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getCircleOpacity() ?: _rawLayer->getDefaultCircleOpacity();
+ auto propertyValue = self.rawLayer->getCircleOpacity() ?: self.rawLayer->getDefaultCircleOpacity();
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}
@@ -158,13 +170,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<mbgl::style::CirclePitchScaleType, NSValue *, mbgl::style::CirclePitchScaleType, MGLCirclePitchScale>().toEnumPropertyValue(circlePitchScale);
- _rawLayer->setCirclePitchScale(mbglValue);
+ self.rawLayer->setCirclePitchScale(mbglValue);
}
- (MGLStyleValue<NSValue *> *)circlePitchScale {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getCirclePitchScale() ?: _rawLayer->getDefaultCirclePitchScale();
+ auto propertyValue = self.rawLayer->getCirclePitchScale() ?: self.rawLayer->getDefaultCirclePitchScale();
return MGLStyleValueTransformer<mbgl::style::CirclePitchScaleType, NSValue *, mbgl::style::CirclePitchScaleType, MGLCirclePitchScale>().toEnumStyleValue(propertyValue);
}
@@ -172,13 +184,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(circleRadius);
- _rawLayer->setCircleRadius(mbglValue);
+ self.rawLayer->setCircleRadius(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)circleRadius {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getCircleRadius() ?: _rawLayer->getDefaultCircleRadius();
+ auto propertyValue = self.rawLayer->getCircleRadius() ?: self.rawLayer->getDefaultCircleRadius();
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}
@@ -186,13 +198,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toPropertyValue(circleTranslate);
- _rawLayer->setCircleTranslate(mbglValue);
+ self.rawLayer->setCircleTranslate(mbglValue);
}
- (MGLStyleValue<NSValue *> *)circleTranslate {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getCircleTranslate() ?: _rawLayer->getDefaultCircleTranslate();
+ auto propertyValue = self.rawLayer->getCircleTranslate() ?: self.rawLayer->getDefaultCircleTranslate();
return MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toStyleValue(propertyValue);
}
@@ -200,13 +212,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLCircleTranslateAnchor>().toEnumPropertyValue(circleTranslateAnchor);
- _rawLayer->setCircleTranslateAnchor(mbglValue);
+ self.rawLayer->setCircleTranslateAnchor(mbglValue);
}
- (MGLStyleValue<NSValue *> *)circleTranslateAnchor {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getCircleTranslateAnchor() ?: _rawLayer->getDefaultCircleTranslateAnchor();
+ auto propertyValue = self.rawLayer->getCircleTranslateAnchor() ?: self.rawLayer->getDefaultCircleTranslateAnchor();
return MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLCircleTranslateAnchor>().toEnumStyleValue(propertyValue);
}
diff --git a/platform/darwin/src/MGLFeature.mm b/platform/darwin/src/MGLFeature.mm
index ba2ea6e605..c1e0c312a0 100644
--- a/platform/darwin/src/MGLFeature.mm
+++ b/platform/darwin/src/MGLFeature.mm
@@ -1,5 +1,4 @@
#import "MGLFeature_Private.h"
-#import "MGLShapeCollectionFeature_Private.h"
#import "MGLPointAnnotation.h"
#import "MGLPolyline.h"
@@ -18,7 +17,7 @@
#import <mbgl/style/conversion/geojson.hpp>
#import <mapbox/geometry/feature.hpp>
-@interface MGLPointFeature () <MGLFeaturePrivate>
+@interface MGLPointFeature ()
@end
@implementation MGLPointFeature
@@ -34,13 +33,13 @@
return NSDictionaryFeatureForGeometry([super geoJSONDictionary], self.attributes, self.identifier);
}
-- (mbgl::Feature)mbglFeature {
+- (mbgl::GeoJSON)geoJSONObject {
return mbglFeature({[self geometryObject]}, identifier, self.attributes);
}
@end
-@interface MGLPolylineFeature () <MGLFeaturePrivate>
+@interface MGLPolylineFeature ()
@end
@implementation MGLPolylineFeature
@@ -56,13 +55,13 @@
return NSDictionaryFeatureForGeometry([super geoJSONDictionary], self.attributes, self.identifier);
}
-- (mbgl::Feature)mbglFeature {
+- (mbgl::GeoJSON)geoJSONObject {
return mbglFeature({[self geometryObject]}, identifier, self.attributes);
}
@end
-@interface MGLPolygonFeature () <MGLFeaturePrivate>
+@interface MGLPolygonFeature ()
@end
@implementation MGLPolygonFeature
@@ -78,13 +77,13 @@
return NSDictionaryFeatureForGeometry([super geoJSONDictionary], self.attributes, self.identifier);
}
-- (mbgl::Feature)mbglFeature {
+- (mbgl::GeoJSON)geoJSONObject {
return mbglFeature({[self geometryObject]}, identifier, self.attributes);
}
@end
-@interface MGLPointCollectionFeature () <MGLFeaturePrivate>
+@interface MGLPointCollectionFeature ()
@end
@implementation MGLPointCollectionFeature
@@ -100,13 +99,13 @@
return NSDictionaryFeatureForGeometry([super geoJSONDictionary], self.attributes, self.identifier);
}
-- (mbgl::Feature)mbglFeature {
+- (mbgl::GeoJSON)geoJSONObject {
return mbglFeature({[self geometryObject]}, identifier, self.attributes);
}
@end
-@interface MGLMultiPolylineFeature () <MGLFeaturePrivate>
+@interface MGLMultiPolylineFeature ()
@end
@implementation MGLMultiPolylineFeature
@@ -122,13 +121,13 @@
return NSDictionaryFeatureForGeometry([super geoJSONDictionary], self.attributes, self.identifier);
}
-- (mbgl::Feature)mbglFeature {
+- (mbgl::GeoJSON)geoJSONObject {
return mbglFeature({[self geometryObject]}, identifier, self.attributes);
}
@end
-@interface MGLMultiPolygonFeature () <MGLFeaturePrivate>
+@interface MGLMultiPolygonFeature ()
@end
@implementation MGLMultiPolygonFeature
@@ -144,13 +143,13 @@
return NSDictionaryFeatureForGeometry([super geoJSONDictionary], self.attributes, self.identifier);
}
-- (mbgl::Feature)mbglFeature {
+- (mbgl::GeoJSON)geoJSONObject {
return mbglFeature({[self geometryObject]}, identifier, self.attributes);
}
@end
-@interface MGLShapeCollectionFeature () <MGLFeaturePrivate>
+@interface MGLShapeCollectionFeature ()
@end
@implementation MGLShapeCollectionFeature
@@ -172,17 +171,13 @@
return NSDictionaryFeatureForGeometry([super geoJSONDictionary], self.attributes, self.identifier);
}
-- (mbgl::Feature)mbglFeature {
- [NSException raise:@"Method unavailable" format:@"%s is not available on %@.", __PRETTY_FUNCTION__, [self class]];
- mbgl::Polygon<double> geometry;
- return mbgl::Feature{geometry};
-}
-
-- (mbgl::FeatureCollection)mbglFeatureCollection {
+- (mbgl::GeoJSON)geoJSONObject {
mbgl::FeatureCollection featureCollection;
featureCollection.reserve(self.shapes.count);
- for (id <MGLFeaturePrivate> feature in self.shapes) {
- featureCollection.push_back([feature mbglFeature]);
+ for (MGLShape <MGLFeature> *feature in self.shapes) {
+ auto geoJSONObject = feature.geoJSONObject;
+ NSAssert(geoJSONObject.is<mbgl::Feature>(), @"Feature collection must only contain features.");
+ featureCollection.push_back(geoJSONObject.get<mbgl::Feature>());
}
return featureCollection;
}
@@ -196,27 +191,27 @@
template <typename T>
class GeometryEvaluator {
public:
- MGLShape <MGLFeaturePrivate> * operator()(const mbgl::Point<T> &geometry) const {
+ MGLShape <MGLFeature> * operator()(const mbgl::Point<T> &geometry) const {
MGLPointFeature *feature = [[MGLPointFeature alloc] init];
feature.coordinate = toLocationCoordinate2D(geometry);
return feature;
}
- MGLShape <MGLFeaturePrivate> * operator()(const mbgl::LineString<T> &geometry) const {
+ MGLShape <MGLFeature> * operator()(const mbgl::LineString<T> &geometry) const {
std::vector<CLLocationCoordinate2D> coordinates = toLocationCoordinates2D(geometry);
return [MGLPolylineFeature polylineWithCoordinates:&coordinates[0] count:coordinates.size()];
}
- MGLShape <MGLFeaturePrivate> * operator()(const mbgl::Polygon<T> &geometry) const {
+ MGLShape <MGLFeature> * operator()(const mbgl::Polygon<T> &geometry) const {
return toShape<MGLPolygonFeature>(geometry);
}
- MGLShape <MGLFeaturePrivate> * operator()(const mbgl::MultiPoint<T> &geometry) const {
+ MGLShape <MGLFeature> * operator()(const mbgl::MultiPoint<T> &geometry) const {
std::vector<CLLocationCoordinate2D> coordinates = toLocationCoordinates2D(geometry);
return [[MGLPointCollectionFeature alloc] initWithCoordinates:&coordinates[0] count:coordinates.size()];
}
- MGLShape <MGLFeaturePrivate> * operator()(const mbgl::MultiLineString<T> &geometry) const {
+ MGLShape <MGLFeature> * operator()(const mbgl::MultiLineString<T> &geometry) const {
NSMutableArray *polylines = [NSMutableArray arrayWithCapacity:geometry.size()];
for (auto &lineString : geometry) {
std::vector<CLLocationCoordinate2D> coordinates = toLocationCoordinates2D(lineString);
@@ -227,7 +222,7 @@ public:
return [MGLMultiPolylineFeature multiPolylineWithPolylines:polylines];
}
- MGLShape <MGLFeaturePrivate> * operator()(const mbgl::MultiPolygon<T> &geometry) const {
+ MGLShape <MGLFeature> * operator()(const mbgl::MultiPolygon<T> &geometry) const {
NSMutableArray *polygons = [NSMutableArray arrayWithCapacity:geometry.size()];
for (auto &polygon : geometry) {
[polygons addObject:toShape(polygon)];
@@ -236,11 +231,11 @@ public:
return [MGLMultiPolygonFeature multiPolygonWithPolygons:polygons];
}
- MGLShape <MGLFeaturePrivate> * operator()(const mapbox::geometry::geometry_collection<T> &collection) const {
+ MGLShape <MGLFeature> * operator()(const mapbox::geometry::geometry_collection<T> &collection) const {
NSMutableArray *shapes = [NSMutableArray arrayWithCapacity:collection.size()];
for (auto &geometry : collection) {
// This is very much like the transformation that happens in MGLFeaturesFromMBGLFeatures(), but these are raw geometries with no associated feature IDs or attributes.
- MGLShape <MGLFeaturePrivate> *shape = mapbox::geometry::geometry<T>::visit(geometry, *this);
+ MGLShape <MGLFeature> *shape = mapbox::geometry::geometry<T>::visit(geometry, *this);
[shapes addObject:shape];
}
return [MGLShapeCollectionFeature shapeCollectionWithShapes:shapes];
@@ -280,23 +275,23 @@ private:
template <typename T>
class GeoJSONEvaluator {
public:
- MGLShape <MGLFeaturePrivate> * operator()(const mbgl::Geometry<T> &geometry) const {
+ MGLShape <MGLFeature> * operator()(const mbgl::Geometry<T> &geometry) const {
GeometryEvaluator<T> evaluator;
- MGLShape <MGLFeaturePrivate> *shape = mapbox::geometry::geometry<T>::visit(geometry, evaluator);
+ MGLShape <MGLFeature> *shape = mapbox::geometry::geometry<T>::visit(geometry, evaluator);
return shape;
}
- MGLShape <MGLFeaturePrivate> * operator()(const mbgl::Feature &feature) const {
- MGLShape <MGLFeaturePrivate> *shape = (MGLShape <MGLFeaturePrivate> *)MGLFeatureFromMBGLFeature(feature);
+ MGLShape <MGLFeature> * operator()(const mbgl::Feature &feature) const {
+ MGLShape <MGLFeature> *shape = (MGLShape <MGLFeature> *)MGLFeatureFromMBGLFeature(feature);
return shape;
}
- MGLShape <MGLFeaturePrivate> * operator()(const mbgl::FeatureCollection &collection) const {
+ MGLShape <MGLFeature> * operator()(const mbgl::FeatureCollection &collection) const {
NSMutableArray *shapes = [NSMutableArray arrayWithCapacity:collection.size()];
for (const auto &feature : collection) {
[shapes addObject:MGLFeatureFromMBGLFeature(feature)];
}
- return [MGLShapeCollection<MGLFeaturePrivate> shapeCollectionWithShapes:shapes];
+ return [MGLShapeCollectionFeature shapeCollectionWithShapes:shapes];
}
};
@@ -316,7 +311,7 @@ id <MGLFeature> MGLFeatureFromMBGLFeature(const mbgl::Feature &feature) {
attributes[@(pair.first.c_str())] = mbgl::Value::visit(value, evaluator);
}
GeometryEvaluator<double> evaluator;
- MGLShape <MGLFeaturePrivate> *shape = mapbox::geometry::geometry<double>::visit(feature.geometry, evaluator);
+ MGLShape <MGLFeature> *shape = mapbox::geometry::geometry<double>::visit(feature.geometry, evaluator);
if (feature.id) {
shape.identifier = mbgl::FeatureIdentifier::visit(*feature.id, ValueEvaluator());
}
diff --git a/platform/darwin/src/MGLFeature_Private.h b/platform/darwin/src/MGLFeature_Private.h
index a3c7432f4a..97af509893 100644
--- a/platform/darwin/src/MGLFeature_Private.h
+++ b/platform/darwin/src/MGLFeature_Private.h
@@ -36,10 +36,4 @@ mbgl::Feature mbglFeature(mbgl::Feature feature, id identifier, NSDictionary *at
*/
NS_DICTIONARY_OF(NSString *, id) *NSDictionaryFeatureForGeometry(NSDictionary *geometry, NSDictionary *attributes, id identifier);
-@protocol MGLFeaturePrivate <MGLFeature>
-
-- (mbgl::Feature)mbglFeature;
-
-@end
-
NS_ASSUME_NONNULL_END
diff --git a/platform/darwin/src/MGLFillStyleLayer.mm b/platform/darwin/src/MGLFillStyleLayer.mm
index e2808ddc19..47bd84fde7 100644
--- a/platform/darwin/src/MGLFillStyleLayer.mm
+++ b/platform/darwin/src/MGLFillStyleLayer.mm
@@ -34,15 +34,26 @@ namespace mbgl {
if (self = [super initWithIdentifier:identifier source:source]) {
auto layer = std::make_unique<mbgl::style::FillLayer>(identifier.UTF8String, source.identifier.UTF8String);
_pendingLayer = std::move(layer);
- _rawLayer = _pendingLayer.get();
+ self.rawLayer = _pendingLayer.get();
}
return self;
}
+
+- (mbgl::style::FillLayer *)rawLayer
+{
+ return (mbgl::style::FillLayer *)super.rawLayer;
+}
+
+- (void)setRawLayer:(mbgl::style::FillLayer *)rawLayer
+{
+ super.rawLayer = rawLayer;
+}
+
- (NSString *)sourceLayerIdentifier
{
MGLAssertStyleLayerIsValid();
- auto layerID = _rawLayer->getSourceLayer();
+ auto layerID = self.rawLayer->getSourceLayer();
return layerID.empty() ? nil : @(layerID.c_str());
}
@@ -50,22 +61,23 @@ namespace mbgl {
{
MGLAssertStyleLayerIsValid();
- _rawLayer->setSourceLayer(sourceLayerIdentifier.UTF8String ?: "");
+ self.rawLayer->setSourceLayer(sourceLayerIdentifier.UTF8String ?: "");
}
- (void)setPredicate:(NSPredicate *)predicate
{
MGLAssertStyleLayerIsValid();
- _rawLayer->setFilter(predicate.mgl_filter);
+ self.rawLayer->setFilter(predicate.mgl_filter);
}
- (NSPredicate *)predicate
{
MGLAssertStyleLayerIsValid();
- return [NSPredicate mgl_predicateWithFilter:_rawLayer->getFilter()];
+ return [NSPredicate mgl_predicateWithFilter:self.rawLayer->getFilter()];
}
+
#pragma mark - Adding to and removing from a map view
- (void)addToMapView:(MGLMapView *)mapView belowLayer:(MGLStyleLayer *)otherLayer
@@ -87,7 +99,7 @@ namespace mbgl {
- (void)removeFromMapView:(MGLMapView *)mapView
{
_pendingLayer = nullptr;
- _rawLayer = nullptr;
+ self.rawLayer = nullptr;
auto removedLayer = mapView.mbglMap->removeLayer(self.identifier.UTF8String);
if (!removedLayer) {
@@ -102,7 +114,7 @@ namespace mbgl {
removedLayer.release();
_pendingLayer = std::unique_ptr<mbgl::style::FillLayer>(layer);
- _rawLayer = _pendingLayer.get();
+ self.rawLayer = _pendingLayer.get();
}
#pragma mark - Accessing the Paint Attributes
@@ -111,13 +123,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<bool, NSNumber *>().toPropertyValue(fillAntialias);
- _rawLayer->setFillAntialias(mbglValue);
+ self.rawLayer->setFillAntialias(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)fillAntialias {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getFillAntialias() ?: _rawLayer->getDefaultFillAntialias();
+ auto propertyValue = self.rawLayer->getFillAntialias() ?: self.rawLayer->getDefaultFillAntialias();
return MGLStyleValueTransformer<bool, NSNumber *>().toStyleValue(propertyValue);
}
@@ -125,13 +137,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue(fillColor);
- _rawLayer->setFillColor(mbglValue);
+ self.rawLayer->setFillColor(mbglValue);
}
- (MGLStyleValue<MGLColor *> *)fillColor {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getFillColor() ?: _rawLayer->getDefaultFillColor();
+ auto propertyValue = self.rawLayer->getFillColor() ?: self.rawLayer->getDefaultFillColor();
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toStyleValue(propertyValue);
}
@@ -139,13 +151,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(fillOpacity);
- _rawLayer->setFillOpacity(mbglValue);
+ self.rawLayer->setFillOpacity(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)fillOpacity {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getFillOpacity() ?: _rawLayer->getDefaultFillOpacity();
+ auto propertyValue = self.rawLayer->getFillOpacity() ?: self.rawLayer->getDefaultFillOpacity();
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}
@@ -153,13 +165,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue(fillOutlineColor);
- _rawLayer->setFillOutlineColor(mbglValue);
+ self.rawLayer->setFillOutlineColor(mbglValue);
}
- (MGLStyleValue<MGLColor *> *)fillOutlineColor {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getFillOutlineColor() ?: _rawLayer->getDefaultFillOutlineColor();
+ auto propertyValue = self.rawLayer->getFillOutlineColor() ?: self.rawLayer->getDefaultFillOutlineColor();
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toStyleValue(propertyValue);
}
@@ -167,13 +179,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<std::string, NSString *>().toPropertyValue(fillPattern);
- _rawLayer->setFillPattern(mbglValue);
+ self.rawLayer->setFillPattern(mbglValue);
}
- (MGLStyleValue<NSString *> *)fillPattern {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getFillPattern() ?: _rawLayer->getDefaultFillPattern();
+ auto propertyValue = self.rawLayer->getFillPattern() ?: self.rawLayer->getDefaultFillPattern();
return MGLStyleValueTransformer<std::string, NSString *>().toStyleValue(propertyValue);
}
@@ -181,13 +193,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toPropertyValue(fillTranslate);
- _rawLayer->setFillTranslate(mbglValue);
+ self.rawLayer->setFillTranslate(mbglValue);
}
- (MGLStyleValue<NSValue *> *)fillTranslate {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getFillTranslate() ?: _rawLayer->getDefaultFillTranslate();
+ auto propertyValue = self.rawLayer->getFillTranslate() ?: self.rawLayer->getDefaultFillTranslate();
return MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toStyleValue(propertyValue);
}
@@ -195,13 +207,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLFillTranslateAnchor>().toEnumPropertyValue(fillTranslateAnchor);
- _rawLayer->setFillTranslateAnchor(mbglValue);
+ self.rawLayer->setFillTranslateAnchor(mbglValue);
}
- (MGLStyleValue<NSValue *> *)fillTranslateAnchor {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getFillTranslateAnchor() ?: _rawLayer->getDefaultFillTranslateAnchor();
+ auto propertyValue = self.rawLayer->getFillTranslateAnchor() ?: self.rawLayer->getDefaultFillTranslateAnchor();
return MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLFillTranslateAnchor>().toEnumStyleValue(propertyValue);
}
diff --git a/platform/darwin/src/MGLLineStyleLayer.mm b/platform/darwin/src/MGLLineStyleLayer.mm
index 2fc9d9e695..a23441c664 100644
--- a/platform/darwin/src/MGLLineStyleLayer.mm
+++ b/platform/darwin/src/MGLLineStyleLayer.mm
@@ -46,15 +46,26 @@ namespace mbgl {
if (self = [super initWithIdentifier:identifier source:source]) {
auto layer = std::make_unique<mbgl::style::LineLayer>(identifier.UTF8String, source.identifier.UTF8String);
_pendingLayer = std::move(layer);
- _rawLayer = _pendingLayer.get();
+ self.rawLayer = _pendingLayer.get();
}
return self;
}
+
+- (mbgl::style::LineLayer *)rawLayer
+{
+ return (mbgl::style::LineLayer *)super.rawLayer;
+}
+
+- (void)setRawLayer:(mbgl::style::LineLayer *)rawLayer
+{
+ super.rawLayer = rawLayer;
+}
+
- (NSString *)sourceLayerIdentifier
{
MGLAssertStyleLayerIsValid();
- auto layerID = _rawLayer->getSourceLayer();
+ auto layerID = self.rawLayer->getSourceLayer();
return layerID.empty() ? nil : @(layerID.c_str());
}
@@ -62,22 +73,23 @@ namespace mbgl {
{
MGLAssertStyleLayerIsValid();
- _rawLayer->setSourceLayer(sourceLayerIdentifier.UTF8String ?: "");
+ self.rawLayer->setSourceLayer(sourceLayerIdentifier.UTF8String ?: "");
}
- (void)setPredicate:(NSPredicate *)predicate
{
MGLAssertStyleLayerIsValid();
- _rawLayer->setFilter(predicate.mgl_filter);
+ self.rawLayer->setFilter(predicate.mgl_filter);
}
- (NSPredicate *)predicate
{
MGLAssertStyleLayerIsValid();
- return [NSPredicate mgl_predicateWithFilter:_rawLayer->getFilter()];
+ return [NSPredicate mgl_predicateWithFilter:self.rawLayer->getFilter()];
}
+
#pragma mark - Adding to and removing from a map view
- (void)addToMapView:(MGLMapView *)mapView belowLayer:(MGLStyleLayer *)otherLayer
@@ -99,7 +111,7 @@ namespace mbgl {
- (void)removeFromMapView:(MGLMapView *)mapView
{
_pendingLayer = nullptr;
- _rawLayer = nullptr;
+ self.rawLayer = nullptr;
auto removedLayer = mapView.mbglMap->removeLayer(self.identifier.UTF8String);
if (!removedLayer) {
@@ -114,7 +126,7 @@ namespace mbgl {
removedLayer.release();
_pendingLayer = std::unique_ptr<mbgl::style::LineLayer>(layer);
- _rawLayer = _pendingLayer.get();
+ self.rawLayer = _pendingLayer.get();
}
#pragma mark - Accessing the Layout Attributes
@@ -123,13 +135,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<mbgl::style::LineCapType, NSValue *, mbgl::style::LineCapType, MGLLineCap>().toEnumPropertyValue(lineCap);
- _rawLayer->setLineCap(mbglValue);
+ self.rawLayer->setLineCap(mbglValue);
}
- (MGLStyleValue<NSValue *> *)lineCap {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getLineCap() ?: _rawLayer->getDefaultLineCap();
+ auto propertyValue = self.rawLayer->getLineCap() ?: self.rawLayer->getDefaultLineCap();
return MGLStyleValueTransformer<mbgl::style::LineCapType, NSValue *, mbgl::style::LineCapType, MGLLineCap>().toEnumStyleValue(propertyValue);
}
@@ -137,13 +149,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<mbgl::style::LineJoinType, NSValue *, mbgl::style::LineJoinType, MGLLineJoin>().toEnumPropertyValue(lineJoin);
- _rawLayer->setLineJoin(mbglValue);
+ self.rawLayer->setLineJoin(mbglValue);
}
- (MGLStyleValue<NSValue *> *)lineJoin {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getLineJoin() ?: _rawLayer->getDefaultLineJoin();
+ auto propertyValue = self.rawLayer->getLineJoin() ?: self.rawLayer->getDefaultLineJoin();
return MGLStyleValueTransformer<mbgl::style::LineJoinType, NSValue *, mbgl::style::LineJoinType, MGLLineJoin>().toEnumStyleValue(propertyValue);
}
@@ -151,13 +163,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(lineMiterLimit);
- _rawLayer->setLineMiterLimit(mbglValue);
+ self.rawLayer->setLineMiterLimit(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)lineMiterLimit {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getLineMiterLimit() ?: _rawLayer->getDefaultLineMiterLimit();
+ auto propertyValue = self.rawLayer->getLineMiterLimit() ?: self.rawLayer->getDefaultLineMiterLimit();
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}
@@ -165,13 +177,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(lineRoundLimit);
- _rawLayer->setLineRoundLimit(mbglValue);
+ self.rawLayer->setLineRoundLimit(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)lineRoundLimit {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getLineRoundLimit() ?: _rawLayer->getDefaultLineRoundLimit();
+ auto propertyValue = self.rawLayer->getLineRoundLimit() ?: self.rawLayer->getDefaultLineRoundLimit();
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}
@@ -181,13 +193,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(lineBlur);
- _rawLayer->setLineBlur(mbglValue);
+ self.rawLayer->setLineBlur(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)lineBlur {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getLineBlur() ?: _rawLayer->getDefaultLineBlur();
+ auto propertyValue = self.rawLayer->getLineBlur() ?: self.rawLayer->getDefaultLineBlur();
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}
@@ -195,13 +207,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue(lineColor);
- _rawLayer->setLineColor(mbglValue);
+ self.rawLayer->setLineColor(mbglValue);
}
- (MGLStyleValue<MGLColor *> *)lineColor {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getLineColor() ?: _rawLayer->getDefaultLineColor();
+ auto propertyValue = self.rawLayer->getLineColor() ?: self.rawLayer->getDefaultLineColor();
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toStyleValue(propertyValue);
}
@@ -209,13 +221,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<std::vector<float>, NSArray<NSNumber *> *, float>().toPropertyValue(lineDashPattern);
- _rawLayer->setLineDasharray(mbglValue);
+ self.rawLayer->setLineDasharray(mbglValue);
}
- (MGLStyleValue<NSArray<NSNumber *> *> *)lineDashPattern {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getLineDasharray() ?: _rawLayer->getDefaultLineDasharray();
+ auto propertyValue = self.rawLayer->getLineDasharray() ?: self.rawLayer->getDefaultLineDasharray();
return MGLStyleValueTransformer<std::vector<float>, NSArray<NSNumber *> *, float>().toStyleValue(propertyValue);
}
@@ -223,13 +235,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(lineGapWidth);
- _rawLayer->setLineGapWidth(mbglValue);
+ self.rawLayer->setLineGapWidth(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)lineGapWidth {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getLineGapWidth() ?: _rawLayer->getDefaultLineGapWidth();
+ auto propertyValue = self.rawLayer->getLineGapWidth() ?: self.rawLayer->getDefaultLineGapWidth();
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}
@@ -237,13 +249,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(lineOffset);
- _rawLayer->setLineOffset(mbglValue);
+ self.rawLayer->setLineOffset(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)lineOffset {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getLineOffset() ?: _rawLayer->getDefaultLineOffset();
+ auto propertyValue = self.rawLayer->getLineOffset() ?: self.rawLayer->getDefaultLineOffset();
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}
@@ -251,13 +263,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(lineOpacity);
- _rawLayer->setLineOpacity(mbglValue);
+ self.rawLayer->setLineOpacity(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)lineOpacity {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getLineOpacity() ?: _rawLayer->getDefaultLineOpacity();
+ auto propertyValue = self.rawLayer->getLineOpacity() ?: self.rawLayer->getDefaultLineOpacity();
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}
@@ -265,13 +277,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<std::string, NSString *>().toPropertyValue(linePattern);
- _rawLayer->setLinePattern(mbglValue);
+ self.rawLayer->setLinePattern(mbglValue);
}
- (MGLStyleValue<NSString *> *)linePattern {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getLinePattern() ?: _rawLayer->getDefaultLinePattern();
+ auto propertyValue = self.rawLayer->getLinePattern() ?: self.rawLayer->getDefaultLinePattern();
return MGLStyleValueTransformer<std::string, NSString *>().toStyleValue(propertyValue);
}
@@ -279,13 +291,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toPropertyValue(lineTranslate);
- _rawLayer->setLineTranslate(mbglValue);
+ self.rawLayer->setLineTranslate(mbglValue);
}
- (MGLStyleValue<NSValue *> *)lineTranslate {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getLineTranslate() ?: _rawLayer->getDefaultLineTranslate();
+ auto propertyValue = self.rawLayer->getLineTranslate() ?: self.rawLayer->getDefaultLineTranslate();
return MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toStyleValue(propertyValue);
}
@@ -293,13 +305,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLLineTranslateAnchor>().toEnumPropertyValue(lineTranslateAnchor);
- _rawLayer->setLineTranslateAnchor(mbglValue);
+ self.rawLayer->setLineTranslateAnchor(mbglValue);
}
- (MGLStyleValue<NSValue *> *)lineTranslateAnchor {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getLineTranslateAnchor() ?: _rawLayer->getDefaultLineTranslateAnchor();
+ auto propertyValue = self.rawLayer->getLineTranslateAnchor() ?: self.rawLayer->getDefaultLineTranslateAnchor();
return MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLLineTranslateAnchor>().toEnumStyleValue(propertyValue);
}
@@ -307,13 +319,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(lineWidth);
- _rawLayer->setLineWidth(mbglValue);
+ self.rawLayer->setLineWidth(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)lineWidth {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getLineWidth() ?: _rawLayer->getDefaultLineWidth();
+ auto propertyValue = self.rawLayer->getLineWidth() ?: self.rawLayer->getDefaultLineWidth();
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}
diff --git a/platform/darwin/src/MGLOpenGLStyleLayer.mm b/platform/darwin/src/MGLOpenGLStyleLayer.mm
index c72b844447..f109ea85b0 100644
--- a/platform/darwin/src/MGLOpenGLStyleLayer.mm
+++ b/platform/darwin/src/MGLOpenGLStyleLayer.mm
@@ -2,6 +2,7 @@
#import "MGLMapView_Private.h"
#import "MGLStyle_Private.h"
+#import "MGLStyleLayer_Private.h"
#include <mbgl/style/layers/custom_layer.hpp>
#include <mbgl/math/wrap.hpp>
@@ -96,11 +97,19 @@ void MGLFinishCustomStyleLayer(void *context) {
MGLFinishCustomStyleLayer,
(__bridge void *)self);
_pendingLayer = std::move(layer);
- _rawLayer = _pendingLayer.get();
+ self.rawLayer = _pendingLayer.get();
}
return self;
}
+- (mbgl::style::CustomLayer *)rawLayer {
+ return (mbgl::style::CustomLayer *)super.rawLayer;
+}
+
+- (void)setRawLayer:(mbgl::style::CustomLayer *)rawLayer {
+ super.rawLayer = rawLayer;
+}
+
#pragma mark - Adding to and removing from a map view
- (void)setMapView:(MGLMapView *)mapView {
@@ -130,7 +139,7 @@ void MGLFinishCustomStyleLayer(void *context) {
return;
}
_pendingLayer = std::move(reinterpret_cast<std::unique_ptr<mbgl::style::CustomLayer> &>(removedLayer));
- _rawLayer = _pendingLayer.get();
+ self.rawLayer = _pendingLayer.get();
}
/**
diff --git a/platform/darwin/src/MGLPointCollection.mm b/platform/darwin/src/MGLPointCollection.mm
index 46b00b9a4d..387a575b2d 100644
--- a/platform/darwin/src/MGLPointCollection.mm
+++ b/platform/darwin/src/MGLPointCollection.mm
@@ -1,8 +1,8 @@
#import "MGLPointCollection_Private.h"
#import "MGLGeometry_Private.h"
+#import <mbgl/util/geojson.hpp>
#import <mbgl/util/geometry.hpp>
-#import <mbgl/util/feature.hpp>
NS_ASSUME_NONNULL_BEGIN
diff --git a/platform/darwin/src/MGLPolygon.mm b/platform/darwin/src/MGLPolygon.mm
index e5bb977863..393bd31d0d 100644
--- a/platform/darwin/src/MGLPolygon.mm
+++ b/platform/darwin/src/MGLPolygon.mm
@@ -5,6 +5,8 @@
#import "MGLPolygon+MGLAdditions.h"
+#import <mbgl/util/geojson.hpp>
+
@implementation MGLPolygon
@dynamic overlayBounds;
diff --git a/platform/darwin/src/MGLPolyline.mm b/platform/darwin/src/MGLPolyline.mm
index ae6abc5280..0baeb68e1a 100644
--- a/platform/darwin/src/MGLPolyline.mm
+++ b/platform/darwin/src/MGLPolyline.mm
@@ -5,6 +5,8 @@
#import "MGLPolyline+MGLAdditions.h"
+#import <mbgl/util/geojson.hpp>
+
@implementation MGLPolyline
@dynamic overlayBounds;
diff --git a/platform/darwin/src/MGLRasterSource.h b/platform/darwin/src/MGLRasterSource.h
index 2940f05371..262e8f2ce1 100644
--- a/platform/darwin/src/MGLRasterSource.h
+++ b/platform/darwin/src/MGLRasterSource.h
@@ -1,93 +1,94 @@
-#import "MGLSource.h"
-#import "MGLTypes.h"
+#import "MGLTileSource.h"
#import <CoreGraphics/CoreGraphics.h>
-@class MGLTileSet;
-
NS_ASSUME_NONNULL_BEGIN
/**
+ An `NSNumber` object containing a floating-point number that specifies the
+ width and height (measured in points) at which the map displays each raster
+ image tile when the map’s zoom level is an integer. The raster source scales
+ its images up or down when the map’s zoom level falls between two integers.
+
+ The default value for this option is 512. Version 4 of the
+ <a href="https://www.mapbox.com/api-documentation/#maps">Mapbox Maps API</a>
+ requires a value of 256, as do many third-party tile servers, so consult your
+ provider’s documentation for the correct value.
+
+ This option is only applicable to `MGLRasterSource` objects; it is ignored when
+ initializing `MGLVectorSource` objects.
+ */
+extern const MGLTileSourceOption MGLTileSourceOptionTileSize;
+
+/**
`MGLRasterSource` is a map content source that supplies raster image tiles to
- be shown on the map. The location of and metadata about the raster tiles are
- defined by either an `MGLTileSet` object or an external TileJSON resource. A
- raster source is added to an `MGLStyle` object along with an
- `MGLRasterStyleLayer` object. Use a raster style layer to control the
+ be shown on the map. The location of and metadata about the tiles are defined
+ either by an option dictionary or by an external file that conforms to the
+ <a href="https://github.com/mapbox/tilejson-spec/">TileJSON specification</a>.
+ A raster source is added to an `MGLStyle` object along with one or more
+ `MGLRasterStyleLayer` objects. Use a raster style layer to control the
appearance of content supplied by the raster source.
+
+ Each
+ <a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources-raster"><code>raster</code></a>
+ source defined by the style JSON file is represented at runtime by an
+ `MGLRasterSource` object that you can use to initialize new style layers. You
+ can also add and remove sources dynamically using methods such as
+ `-[MGLStyle addSource:]` and `-[MGLStyle sourceWithIdentifier:]`.
*/
-@interface MGLRasterSource : MGLSource
+@interface MGLRasterSource : MGLTileSource
#pragma mark Initializing a Source
/**
- Returns a raster source initialized with an identifier, TileJSON configuration
- URL, and tile size.
+ Returns a raster source initialized with an identifier and configuration URL.
After initializing and configuring the source, add it to a map view’s style
using the `-[MGLStyle addSource:]` method.
The URL may be a full HTTP or HTTPS URL or, for tile sets hosted by Mapbox, a
- Mapbox URL indicating a map identifier (`mapbox://<mapid>`).
+ Mapbox URL indicating a map identifier (`mapbox://<mapid>`). The URL should
+ point to a JSON file that conforms to the
+ <a href="https://github.com/mapbox/tilejson-spec/">TileJSON specification</a>.
+
+ If a Mapbox URL is specified, this source uses a tile size of 256. For all
+ other tile sets, the default value is 512. (See the
+ `MGLTileSourceOptionTileSize` documentation for more information about tile
+ sizes.) If you need to use a tile size other than the default, use the
+ `-initWithIdentifier:configurationURL:tileSize:` method.
@param identifier A string that uniquely identifies the source in the style to
which it is added.
- @param url A URL to a TileJSON configuration file describing the source’s
- contents and other metadata.
- @param tileSize The height and width (measured in points) at which to display
- each tile in this source when the map’s zoom level is an integer.
+ @param configurationURL A URL to a TileJSON configuration file describing the
+ source’s contents and other metadata.
@return An initialized raster source.
*/
-- (instancetype)initWithIdentifier:(NSString *)identifier URL:(NSURL *)url tileSize:(CGFloat)tileSize NS_DESIGNATED_INITIALIZER;
+- (instancetype)initWithIdentifier:(NSString *)identifier configurationURL:(NSURL *)configurationURL;
/**
- Returns a raster source initialized with the given identifier, tile size, and
- tile set.
+ Returns a raster source initialized with an identifier, configuration URL, and
+ tile size.
After initializing and configuring the source, add it to a map view’s style
using the `-[MGLStyle addSource:]` method.
-
- @param identifier A string that uniquely identifies the source in the style to
- which it is added.
- @param tileSet A tile set describing the source’s contents and other metadata.
- @param tileSize The height and width (measured in points) at which to display
- each tile in this source when the map’s zoom level is an integer.
- @return An initialized raster source.
- */
-- (instancetype)initWithIdentifier:(NSString *)identifier tileSet:(MGLTileSet *)tileSet tileSize:(CGFloat)tileSize NS_DESIGNATED_INITIALIZER;
-
-#pragma mark Accessing a Source’s Content
-
-/**
- A URL to a TileJSON configuration file describing the source’s contents and
- other metadata.
The URL may be a full HTTP or HTTPS URL or, for tile sets hosted by Mapbox, a
- Mapbox URL indicating a map identifier (`mapbox://<mapid>`).
-
- @see <a href="https://www.mapbox.com/help/an-open-platform/#tilejson">The
- TileJSON specification.</a>
- */
-@property (nonatomic, readonly, copy) NSURL *URL;
-
-/**
- The height and width (measured in points) at which to display each tile in this
- source when the map’s zoom level is an integer.
-
- A tile may be scaled up or down when the zoom level is between two integers.
+ Mapbox URL indicating a map identifier (`mapbox://<mapid>`). The URL should
+ point to a JSON file that conforms to the
+ <a href="https://github.com/mapbox/tilejson-spec/">TileJSON specification</a>.
- The default value of this property is 512 points.
+ @param identifier A string that uniquely identifies the source in the style to
+ which it is added.
+ @param configurationURL A URL to a TileJSON configuration file describing the
+ source’s contents and other metadata.
+ @param tileSize The width and height (measured in points) of each tiled image
+ in the raster source. See the `MGLTileSourceOptionTileSize` documentation
+ for details.
+ @return An initialized raster source.
*/
-@property (nonatomic, readonly, assign) NSUInteger tileSize;
+- (instancetype)initWithIdentifier:(NSString *)identifier configurationURL:(NSURL *)configurationURL tileSize:(CGFloat)tileSize NS_DESIGNATED_INITIALIZER;
-/**
- The tile set used to locate and download tiles.
-
- A tile set holds the raster tile URL template strings and associated
- configuration for those strings. It can be passed in place of the URL
- to TileJSON in order to create a source configured to download tiles
- from ordinary web URLs.
- */
-@property (nonatomic, readonly, nullable) MGLTileSet *tileSet;
+- (instancetype)initWithIdentifier:(NSString *)identifier tileURLTemplates:(NS_ARRAY_OF(NSString *) *)tileURLTemplates options:(nullable NS_DICTIONARY_OF(MGLTileSourceOption, id) *)options NS_DESIGNATED_INITIALIZER;
@end
diff --git a/platform/darwin/src/MGLRasterSource.mm b/platform/darwin/src/MGLRasterSource.mm
index 1671e1decd..edca8bced1 100644
--- a/platform/darwin/src/MGLRasterSource.mm
+++ b/platform/darwin/src/MGLRasterSource.mm
@@ -2,11 +2,16 @@
#import "MGLMapView_Private.h"
#import "MGLSource_Private.h"
-#import "MGLTileSet_Private.h"
+#import "MGLTileSource_Private.h"
#import "NSURL+MGLAdditions.h"
#include <mbgl/style/sources/raster_source.hpp>
+const MGLTileSourceOption MGLTileSourceOptionTileSize = @"MGLTileSourceOptionTileSize";
+
+static const CGFloat MGLRasterSourceClassicTileSize = 256;
+static const CGFloat MGLRasterSourceRetinaTileSize = 512;
+
@interface MGLRasterSource ()
- (instancetype)initWithRawSource:(mbgl::style::RasterSource *)rawSource NS_DESIGNATED_INITIALIZER;
@@ -15,88 +20,84 @@
@end
-@implementation MGLRasterSource
-{
+@implementation MGLRasterSource {
std::unique_ptr<mbgl::style::RasterSource> _pendingSource;
}
-- (instancetype)initWithIdentifier:(NSString *)identifier URL:(NSURL *)url tileSize:(CGFloat)tileSize
-{
- if (self = [super initWithIdentifier:identifier]) {
- _URL = url;
- _tileSize = tileSize;
- [self commonInit];
- }
- return self;
+- (instancetype)initWithIdentifier:(NSString *)identifier configurationURL:(NSURL *)configurationURL {
+ // The style specification default is 512, but 256 is the expected value for
+ // any tile set that would be accessed through a mapbox: URL and therefore
+ // any tile URL that this option currently affects.
+ BOOL isMapboxURL = ([configurationURL.scheme isEqualToString:@"mapbox"]
+ && [configurationURL.host containsString:@"."]
+ && (!configurationURL.path.length || [configurationURL.path isEqualToString:@"/"]));
+ CGFloat tileSize = isMapboxURL ? MGLRasterSourceClassicTileSize : MGLRasterSourceRetinaTileSize;
+ return [self initWithIdentifier:identifier configurationURL:configurationURL tileSize:tileSize];
}
-- (instancetype)initWithIdentifier:(NSString *)identifier tileSet:(MGLTileSet *)tileSet tileSize:(CGFloat)tileSize;
-{
- if (self = [super initWithIdentifier:identifier])
- {
- _tileSet = tileSet;
- _tileSize = tileSize;
- [self commonInit];
+- (instancetype)initWithIdentifier:(NSString *)identifier configurationURL:(NSURL *)configurationURL tileSize:(CGFloat)tileSize {
+ if (self = [super initWithIdentifier:identifier configurationURL:configurationURL]) {
+ auto source = std::make_unique<mbgl::style::RasterSource>(identifier.UTF8String,
+ configurationURL.mgl_URLByStandardizingScheme.absoluteString.UTF8String,
+ uint16_t(round(tileSize)));
+ _pendingSource = std::move(source);
+ self.rawSource = _pendingSource.get();
}
return self;
}
-- (instancetype)initWithRawSource:(mbgl::style::RasterSource *)rawSource {
- if (self = [super initWithRawSource:rawSource]) {
- if (auto attribution = rawSource->getAttribution()) {
- _tileSet = [[MGLTileSet alloc] initWithTileURLTemplates:@[]];
- _tileSet.attribution = @(attribution->c_str());
+- (instancetype)initWithIdentifier:(NSString *)identifier tileURLTemplates:(NS_ARRAY_OF(NSString *) *)tileURLTemplates options:(nullable NS_DICTIONARY_OF(MGLTileSourceOption, id) *)options {
+ if (self = [super initWithIdentifier:identifier tileURLTemplates:tileURLTemplates options:options]) {
+ mbgl::Tileset tileSet = MGLTileSetFromTileURLTemplates(tileURLTemplates, options);
+
+ uint16_t tileSize;
+ if (NSNumber *tileSizeNumber = options[MGLTileSourceOptionTileSize]) {
+ if (![tileSizeNumber isKindOfClass:[NSNumber class]]) {
+ [NSException raise:NSInvalidArgumentException
+ format:@"MGLTileSourceOptionTileSize must be set to an NSNumber."];
+ }
+ tileSize = static_cast<uint16_t>(round(tileSizeNumber.doubleValue));
}
+
+ auto source = std::make_unique<mbgl::style::RasterSource>(identifier.UTF8String, tileSet, tileSize);
+ _pendingSource = std::move(source);
+ self.rawSource = _pendingSource.get();
}
return self;
}
-- (void)commonInit
-{
- std::unique_ptr<mbgl::style::RasterSource> source;
-
- if (self.URL)
- {
- source = std::make_unique<mbgl::style::RasterSource>(self.identifier.UTF8String,
- self.URL.mgl_URLByStandardizingScheme.absoluteString.UTF8String,
- uint16_t(self.tileSize));
- }
- else
- {
- source = std::make_unique<mbgl::style::RasterSource>(self.identifier.UTF8String,
- self.tileSet.mbglTileset,
- uint16_t(self.tileSize));
- }
-
- _pendingSource = std::move(source);
- self.rawSource = _pendingSource.get();
+- (instancetype)initWithRawSource:(mbgl::style::RasterSource *)rawSource {
+ return [super initWithRawSource:rawSource];
}
-- (void)addToMapView:(MGLMapView *)mapView
-{
+- (void)addToMapView:(MGLMapView *)mapView {
if (_pendingSource == nullptr) {
[NSException raise:@"MGLRedundantSourceException"
format:@"This instance %@ was already added to %@. Adding the same source instance " \
- "to the style more than once is invalid.", self, mapView.style];
+ @"to the style more than once is invalid.", self, mapView.style];
}
mapView.mbglMap->addSource(std::move(_pendingSource));
}
-- (void)removeFromMapView:(MGLMapView *)mapView
-{
+- (void)removeFromMapView:(MGLMapView *)mapView {
auto removedSource = mapView.mbglMap->removeSource(self.identifier.UTF8String);
_pendingSource = std::move(reinterpret_cast<std::unique_ptr<mbgl::style::RasterSource> &>(removedSource));
self.rawSource = _pendingSource.get();
}
-- (NSString *)description
-{
- return [NSString stringWithFormat:
- @"<%@: %p; identifier = %@; URL = %@; tileSet = %@; tileSize = %lu>",
- NSStringFromClass([self class]), (void *)self, self.identifier, self.URL,
- self.tileSet, (unsigned long)self.tileSize];
+- (mbgl::style::RasterSource *)rawSource {
+ return (mbgl::style::RasterSource *)super.rawSource;
+}
+
+- (void)setRawSource:(mbgl::style::RasterSource *)rawSource {
+ super.rawSource = rawSource;
+}
+
+- (NSString *)attributionHTMLString {
+ auto attribution = self.rawSource->getAttribution();
+ return attribution ? @(attribution->c_str()) : nil;
}
@end
diff --git a/platform/darwin/src/MGLRasterSource_Private.h b/platform/darwin/src/MGLRasterSource_Private.h
index 4a367cf8f8..47b1c13517 100644
--- a/platform/darwin/src/MGLRasterSource_Private.h
+++ b/platform/darwin/src/MGLRasterSource_Private.h
@@ -1,5 +1,7 @@
#import "MGLRasterSource.h"
+NS_ASSUME_NONNULL_BEGIN
+
namespace mbgl {
namespace style {
class RasterSource;
@@ -11,3 +13,5 @@ namespace mbgl {
- (instancetype)initWithRawSource:(mbgl::style::RasterSource *)rawSource;
@end
+
+NS_ASSUME_NONNULL_END
diff --git a/platform/darwin/src/MGLRasterStyleLayer.mm b/platform/darwin/src/MGLRasterStyleLayer.mm
index 1bb5c33c28..9c2a64d0da 100644
--- a/platform/darwin/src/MGLRasterStyleLayer.mm
+++ b/platform/darwin/src/MGLRasterStyleLayer.mm
@@ -26,10 +26,21 @@
if (self = [super initWithIdentifier:identifier source:source]) {
auto layer = std::make_unique<mbgl::style::RasterLayer>(identifier.UTF8String, source.identifier.UTF8String);
_pendingLayer = std::move(layer);
- _rawLayer = _pendingLayer.get();
+ self.rawLayer = _pendingLayer.get();
}
return self;
}
+
+- (mbgl::style::RasterLayer *)rawLayer
+{
+ return (mbgl::style::RasterLayer *)super.rawLayer;
+}
+
+- (void)setRawLayer:(mbgl::style::RasterLayer *)rawLayer
+{
+ super.rawLayer = rawLayer;
+}
+
#pragma mark - Adding to and removing from a map view
- (void)addToMapView:(MGLMapView *)mapView belowLayer:(MGLStyleLayer *)otherLayer
@@ -51,7 +62,7 @@
- (void)removeFromMapView:(MGLMapView *)mapView
{
_pendingLayer = nullptr;
- _rawLayer = nullptr;
+ self.rawLayer = nullptr;
auto removedLayer = mapView.mbglMap->removeLayer(self.identifier.UTF8String);
if (!removedLayer) {
@@ -66,7 +77,7 @@
removedLayer.release();
_pendingLayer = std::unique_ptr<mbgl::style::RasterLayer>(layer);
- _rawLayer = _pendingLayer.get();
+ self.rawLayer = _pendingLayer.get();
}
#pragma mark - Accessing the Paint Attributes
@@ -75,13 +86,13 @@
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(maximumRasterBrightness);
- _rawLayer->setRasterBrightnessMax(mbglValue);
+ self.rawLayer->setRasterBrightnessMax(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)maximumRasterBrightness {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getRasterBrightnessMax() ?: _rawLayer->getDefaultRasterBrightnessMax();
+ auto propertyValue = self.rawLayer->getRasterBrightnessMax() ?: self.rawLayer->getDefaultRasterBrightnessMax();
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}
@@ -89,13 +100,13 @@
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(minimumRasterBrightness);
- _rawLayer->setRasterBrightnessMin(mbglValue);
+ self.rawLayer->setRasterBrightnessMin(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)minimumRasterBrightness {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getRasterBrightnessMin() ?: _rawLayer->getDefaultRasterBrightnessMin();
+ auto propertyValue = self.rawLayer->getRasterBrightnessMin() ?: self.rawLayer->getDefaultRasterBrightnessMin();
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}
@@ -103,13 +114,13 @@
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(rasterContrast);
- _rawLayer->setRasterContrast(mbglValue);
+ self.rawLayer->setRasterContrast(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)rasterContrast {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getRasterContrast() ?: _rawLayer->getDefaultRasterContrast();
+ auto propertyValue = self.rawLayer->getRasterContrast() ?: self.rawLayer->getDefaultRasterContrast();
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}
@@ -117,13 +128,13 @@
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(rasterFadeDuration);
- _rawLayer->setRasterFadeDuration(mbglValue);
+ self.rawLayer->setRasterFadeDuration(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)rasterFadeDuration {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getRasterFadeDuration() ?: _rawLayer->getDefaultRasterFadeDuration();
+ auto propertyValue = self.rawLayer->getRasterFadeDuration() ?: self.rawLayer->getDefaultRasterFadeDuration();
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}
@@ -131,13 +142,13 @@
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(rasterHueRotation);
- _rawLayer->setRasterHueRotate(mbglValue);
+ self.rawLayer->setRasterHueRotate(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)rasterHueRotation {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getRasterHueRotate() ?: _rawLayer->getDefaultRasterHueRotate();
+ auto propertyValue = self.rawLayer->getRasterHueRotate() ?: self.rawLayer->getDefaultRasterHueRotate();
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}
@@ -145,13 +156,13 @@
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(rasterOpacity);
- _rawLayer->setRasterOpacity(mbglValue);
+ self.rawLayer->setRasterOpacity(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)rasterOpacity {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getRasterOpacity() ?: _rawLayer->getDefaultRasterOpacity();
+ auto propertyValue = self.rawLayer->getRasterOpacity() ?: self.rawLayer->getDefaultRasterOpacity();
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}
@@ -159,13 +170,13 @@
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(rasterSaturation);
- _rawLayer->setRasterSaturation(mbglValue);
+ self.rawLayer->setRasterSaturation(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)rasterSaturation {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getRasterSaturation() ?: _rawLayer->getDefaultRasterSaturation();
+ auto propertyValue = self.rawLayer->getRasterSaturation() ?: self.rawLayer->getDefaultRasterSaturation();
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}
diff --git a/platform/darwin/src/MGLShape.h b/platform/darwin/src/MGLShape.h
index ce9375c910..e7dbe90242 100644
--- a/platform/darwin/src/MGLShape.h
+++ b/platform/darwin/src/MGLShape.h
@@ -13,6 +13,30 @@ NS_ASSUME_NONNULL_BEGIN
*/
@interface MGLShape : NSObject <MGLAnnotation>
+#pragma mark Creating a Shape
+
+/**
+ Returns an `MGLShape` object initialized with the given data interpreted as a
+ string containing a GeoJSON object.
+
+ If the GeoJSON object is a geometry, the returned value is a kind of
+ `MGLShape`. If it is a feature object, the returned value is a kind of
+ `MGLShape` that conforms to the `MGLFeature` protocol. If it is a feature
+ collection object, the returned value is an instance of
+ `MGLShapeCollectionFeature`.
+
+ @param data String data containing GeoJSON source code.
+ @param encoding The encoding used by `data`.
+ @param outError Upon return, if an error has occurred, a pointer to an
+ `NSError` object describing the error. Pass in `NULL` to ignore any error.
+ @return An `MGLShape` object representation of `data`, or `nil` if `data` could
+ not be parsed as valid GeoJSON source code. If `nil`, `outError` contains an
+ `NSError` object describing the problem.
+ */
++ (nullable instancetype)shapeWithData:(NSData *)data encoding:(NSStringEncoding)encoding error:(NSError * _Nullable *)outError;
+
+#pragma mark Accessing the Shape Attributes
+
/**
The title of the shape annotation. The default value of this property is `nil`.
*/
@@ -34,6 +58,17 @@ NS_ASSUME_NONNULL_BEGIN
#endif
+#pragma mark Creating GeoJSON Data
+
+/**
+ Returns the GeoJSON string representation of the shape encapsulated in a data
+ object.
+
+ @param encoding The string encoding to use.
+ @return A data object containing the shape’s GeoJSON string representation.
+ */
+- (NSData *)geoJSONDataUsingEncoding:(NSStringEncoding)encoding;
+
@end
NS_ASSUME_NONNULL_END
diff --git a/platform/darwin/src/MGLShape.mm b/platform/darwin/src/MGLShape.mm
index e3d92c38c8..ee14027cd8 100644
--- a/platform/darwin/src/MGLShape.mm
+++ b/platform/darwin/src/MGLShape.mm
@@ -1,14 +1,52 @@
-#import "MGLShape.h"
+#import "MGLShape_Private.h"
+
+#import "MGLFeature_Private.h"
@implementation MGLShape
-- (CLLocationCoordinate2D)coordinate
-{
- [[NSException exceptionWithName:@"MGLAbstractClassException"
- reason:@"MGLShape is an abstract class"
- userInfo:nil] raise];
++ (nullable instancetype)shapeWithData:(NSData *)data encoding:(NSStringEncoding)encoding error:(NSError * _Nullable *)outError {
+ NSString *string = [[NSString alloc] initWithData:data encoding:encoding];
+ if (!string) {
+ if (outError) {
+ *outError = [NSError errorWithDomain:MGLErrorDomain code:MGLErrorCodeUnknown userInfo:nil];
+ }
+ return nil;
+ }
+
+ try {
+ const auto geojson = mapbox::geojson::parse(string.UTF8String);
+ return MGLShapeFromGeoJSON(geojson);
+ } catch (std::runtime_error &err) {
+ if (outError) {
+ *outError = [NSError errorWithDomain:MGLErrorDomain code:MGLErrorCodeUnknown userInfo:@{
+ NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"%s", err.what()],
+ }];
+ }
+ return nil;
+ }
+}
+
+- (mbgl::GeoJSON)geoJSONObject {
+ return self.geometryObject;
+}
+
+- (mbgl::Geometry<double>)geometryObject {
+ [NSException raise:@"MGLAbstractClassException"
+ format:@"MGLShape is an abstract class"];
+ return mbgl::Point<double>();
+}
+
+- (NSData *)geoJSONDataUsingEncoding:(NSStringEncoding)encoding {
+ auto geometry = self.geoJSONObject;
+ NSString *string = @(mapbox::geojson::stringify(geometry).c_str());
+ return [string dataUsingEncoding:NSUTF8StringEncoding];
+}
+
+- (CLLocationCoordinate2D)coordinate {
+ [NSException raise:@"MGLAbstractClassException"
+ format:@"MGLShape is an abstract class"];
- return CLLocationCoordinate2DMake(MAXFLOAT, MAXFLOAT);
+ return kCLLocationCoordinate2DInvalid;
}
@end
diff --git a/platform/darwin/src/MGLShapeCollectionFeature_Private.h b/platform/darwin/src/MGLShapeCollectionFeature_Private.h
deleted file mode 100644
index 4f07a93b35..0000000000
--- a/platform/darwin/src/MGLShapeCollectionFeature_Private.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#import "MGLFeature.h"
-
-#import <mbgl/util/feature.hpp>
-
-NS_ASSUME_NONNULL_BEGIN
-
-@interface MGLShapeCollectionFeature ()
-
-- (mbgl::FeatureCollection)mbglFeatureCollection;
-
-@end
-
-NS_ASSUME_NONNULL_END
diff --git a/platform/darwin/src/MGLShapeSource.h b/platform/darwin/src/MGLShapeSource.h
index 407d9c45a1..68cb40a83f 100644
--- a/platform/darwin/src/MGLShapeSource.h
+++ b/platform/darwin/src/MGLShapeSource.h
@@ -64,6 +64,14 @@ extern const MGLShapeSourceOption MGLShapeSourceOptionSimplificationTolerance;
`MGLStyle` object along with an `MGLVectorStyleLayer` object. The vector style
layer defines the appearance of any content supplied by the shape source.
+ Each
+ <a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources-geojson"><code>geojson</code></a>
+ source defined by the style JSON file is represented at runtime by an
+ `MGLShapeSource` object that you can use to refine the map’s content and
+ initialize new style layers. You can also add and remove sources dynamically
+ using methods such as `-[MGLStyle addSource:]` and
+ `-[MGLStyle sourceWithIdentifier:]`.
+
Any vector style layer initialized with a shape source should have a `nil`
value in its `sourceLayerIdentifier` property.
*/
@@ -72,23 +80,8 @@ extern const MGLShapeSourceOption MGLShapeSourceOptionSimplificationTolerance;
#pragma mark Initializing a Source
/**
- Returns a shape source initialized with an identifier, GeoJSON data, and a
- dictionary of options for the source according to the
- <a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources-geojson">style
- specification</a>.
-
- @param identifier A string that uniquely identifies the source.
- @param geoJSONData An `NSData` object representing GeoJSON source code.
- @param options An `NSDictionary` of options for this source.
- @return An initialized shape source.
- */
-- (instancetype)initWithIdentifier:(NSString *)identifier geoJSONData:(NSData *)data options:(nullable NS_DICTIONARY_OF(MGLShapeSourceOption, id) *)options NS_DESIGNATED_INITIALIZER;
-
-/**
Returns a shape source with an identifier, URL, and dictionary of options for
- the source according to the
- <a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources-geojson">style
- specification</a>.
+ the source.
@param identifier A string that uniquely identifies the source.
@param URL An HTTP(S) URL, absolute file URL, or local file URL relative to the
@@ -99,10 +92,16 @@ extern const MGLShapeSourceOption MGLShapeSourceOptionSimplificationTolerance;
- (instancetype)initWithIdentifier:(NSString *)identifier URL:(NSURL *)url options:(nullable NS_DICTIONARY_OF(MGLShapeSourceOption, id) *)options NS_DESIGNATED_INITIALIZER;
/**
- Returns a shape source with an identifier, a shape, and dictionary
- of options for the source according to the
- <a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources-geojson">style
- specification</a>.
+ Returns a shape source with an identifier, a shape, and dictionary of options
+ for the source.
+
+ To specify attributes about the shape, use an instance of an `MGLShape`
+ subclass that conforms to the `MGLFeature` protocol, such as `MGLPointFeature`.
+ To include multiple shapes in the source, use an `MGLShapeCollection` or
+ `MGLShapeCollectionFeature` object.
+
+ To create a shape from GeoJSON source code, use the
+ `+[MGLShape shapeWithData:encoding:error:]` method.
@param identifier A string that uniquely identifies the source.
@param shape A concrete subclass of `MGLShape`
@@ -119,31 +118,17 @@ extern const MGLShapeSourceOption MGLShapeSourceOptionSimplificationTolerance;
If the receiver was initialized using `-initWithIdentifier:URL:options:`, this
property is set to `nil`. This property is unavailable until the receiver is
- passed into `-[MGLStyle addSource]`.
- */
-@property (nonatomic, nullable) MGLShape *shape;
-
-/**
- A GeoJSON representation of the contents of the source.
-
- Use the `shape` property instead to get an object representation of the
- contents. Alternatively, use `NSJSONSerialization` with the value of this
- property to transform it into Foundation types.
-
- If the receiver was initialized using `-initWithIdentifier:URL:options` or
- `-initWithIdentifier:shape:options`, this property is set to `nil`.
- This property is unavailable until the receiver is passed into
- `-[MGLStyle addSource]`.
+ passed into `-[MGLStyle addSource:]`.
*/
-@property (nonatomic, nullable, copy) NSData *geoJSONData;
+@property (nonatomic, copy, nullable) MGLShape *shape;
/**
The URL to the GeoJSON document that specifies the contents of the source.
- If the receiver was initialized using
- `-initWithIdentifier:geoJSONData:options`, this property is set to `nil`.
+ If the receiver was initialized using `-initWithIdentifier:shape:options:`,
+ this property is set to `nil`.
*/
-@property (nonatomic, nullable) NSURL *URL;
+@property (nonatomic, copy, nullable) NSURL *URL;
@end
diff --git a/platform/darwin/src/MGLShapeSource.mm b/platform/darwin/src/MGLShapeSource.mm
index 987306a228..d062e656c2 100644
--- a/platform/darwin/src/MGLShapeSource.mm
+++ b/platform/darwin/src/MGLShapeSource.mm
@@ -3,7 +3,6 @@
#import "MGLMapView_Private.h"
#import "MGLSource_Private.h"
#import "MGLFeature_Private.h"
-#import "MGLShapeCollectionFeature_Private.h"
#import "MGLShape_Private.h"
#import "NSURL+MGLAdditions.h"
@@ -26,39 +25,32 @@ const MGLShapeSourceOption MGLShapeSourceOptionSimplificationTolerance = @"MGLSh
@end
-@implementation MGLShapeSource
-{
+@implementation MGLShapeSource {
std::unique_ptr<mbgl::style::GeoJSONSource> _pendingSource;
}
-- (instancetype)initWithIdentifier:(NSString *)identifier geoJSONData:(NSData *)data options:(NS_DICTIONARY_OF(NSString *, id) *)options
-{
- if (self = [super initWithIdentifier:identifier])
- {
- _geoJSONData = data;
- _options = options;
- [self commonInit];
- }
- return self;
-}
-
-- (instancetype)initWithIdentifier:(NSString *)identifier URL:(NSURL *)url options:(NS_DICTIONARY_OF(NSString *, id) *)options
-{
- if (self = [super initWithIdentifier:identifier])
- {
- _URL = url;
- _options = options;
- [self commonInit];
+- (instancetype)initWithIdentifier:(NSString *)identifier URL:(NSURL *)url options:(NS_DICTIONARY_OF(NSString *, id) *)options {
+ if (self = [super initWithIdentifier:identifier]) {
+ auto geoJSONOptions = MGLGeoJSONOptionsFromDictionary(options);
+ auto source = std::make_unique<mbgl::style::GeoJSONSource>(identifier.UTF8String, geoJSONOptions);
+
+ _pendingSource = std::move(source);
+ self.rawSource = _pendingSource.get();
+
+ self.URL = url;
}
return self;
}
-- (instancetype)initWithIdentifier:(NSString *)identifier shape:(nullable MGLShape *)shape options:(NSDictionary<MGLShapeSourceOption,id> *)options
-{
+- (instancetype)initWithIdentifier:(NSString *)identifier shape:(nullable MGLShape *)shape options:(NS_DICTIONARY_OF(MGLShapeSourceOption, id) *)options {
if (self = [super initWithIdentifier:identifier]) {
- _shape = shape;
- _options = options;
- [self commonInit];
+ auto geoJSONOptions = MGLGeoJSONOptionsFromDictionary(options);
+ auto source = std::make_unique<mbgl::style::GeoJSONSource>(identifier.UTF8String, geoJSONOptions);
+
+ _pendingSource = std::move(source);
+ self.rawSource = _pendingSource.get();
+
+ self.shape = shape;
}
return self;
}
@@ -67,8 +59,7 @@ const MGLShapeSourceOption MGLShapeSourceOptionSimplificationTolerance = @"MGLSh
return [super initWithRawSource:rawSource];
}
-- (void)addToMapView:(MGLMapView *)mapView
-{
+- (void)addToMapView:(MGLMapView *)mapView {
if (_pendingSource == nullptr) {
[NSException raise:@"MGLRedundantSourceException"
format:@"This instance %@ was already added to %@. Adding the same source instance " \
@@ -78,135 +69,97 @@ const MGLShapeSourceOption MGLShapeSourceOptionSimplificationTolerance = @"MGLSh
mapView.mbglMap->addSource(std::move(_pendingSource));
}
-- (void)removeFromMapView:(MGLMapView *)mapView
-{
+- (void)removeFromMapView:(MGLMapView *)mapView {
auto removedSource = mapView.mbglMap->removeSource(self.identifier.UTF8String);
_pendingSource = std::move(reinterpret_cast<std::unique_ptr<mbgl::style::GeoJSONSource> &>(removedSource));
self.rawSource = _pendingSource.get();
}
-- (void)commonInit
-{
- auto source = std::make_unique<mbgl::style::GeoJSONSource>(self.identifier.UTF8String, self.geoJSONOptions);
-
- if (self.URL) {
- NSURL *url = self.URL.mgl_URLByStandardizingScheme;
- source->setURL(url.absoluteString.UTF8String);
+- (mbgl::style::GeoJSONSource *)rawSource {
+ return (mbgl::style::GeoJSONSource *)super.rawSource;
+}
+
+- (void)setRawSource:(mbgl::style::GeoJSONSource *)rawSource {
+ super.rawSource = rawSource;
+}
+
+- (NSURL *)URL {
+ auto url = self.rawSource->getURL();
+ return url ? [NSURL URLWithString:@(url->c_str())] : nil;
+}
+
+- (void)setURL:(NSURL *)url {
+ if (url) {
+ self.rawSource->setURL(url.mgl_URLByStandardizingScheme.absoluteString.UTF8String);
_shape = nil;
- } else if (self.geoJSONData) {
- NSString *string = [[NSString alloc] initWithData:self.geoJSONData encoding:NSUTF8StringEncoding];
- const auto geojson = mapbox::geojson::parse(string.UTF8String);
- source->setGeoJSON(geojson);
- _shape = MGLShapeFromGeoJSON(geojson);
} else {
- if ([self.shape isKindOfClass:[MGLShapeCollectionFeature class]]) {
- MGLShapeCollectionFeature *feature = (MGLShapeCollectionFeature *)self.shape;
- source->setGeoJSON(mbgl::GeoJSON{[feature mbglFeatureCollection]});
- } else if ([self.shape conformsToProtocol:@protocol(MGLFeature)]) {
- id<MGLFeaturePrivate> feature = (id<MGLFeaturePrivate>)self.shape;
- source->setGeoJSON(mbgl::GeoJSON{[feature mbglFeature]});
- } else {
- source->setGeoJSON(mbgl::GeoJSON{self.shape.geometryObject});
- }
+ self.shape = nil;
}
-
- _pendingSource = std::move(source);
- self.rawSource = _pendingSource.get();
}
-- (mbgl::style::GeoJSONOptions)geoJSONOptions
-{
- auto mbglOptions = mbgl::style::GeoJSONOptions();
-
- if (id value = self.options[MGLShapeSourceOptionMaximumZoomLevel]) {
- [self validateValue:value];
- mbglOptions.maxzoom = [value integerValue];
- }
-
- if (id value = self.options[MGLShapeSourceOptionBuffer]) {
- [self validateValue:value];
- mbglOptions.buffer = [value integerValue];
- }
-
- if (id value = self.options[MGLShapeSourceOptionSimplificationTolerance]) {
- [self validateValue:value];
- mbglOptions.tolerance = [value doubleValue];
- }
-
- if (id value = self.options[MGLShapeSourceOptionClusterRadius]) {
- [self validateValue:value];
- mbglOptions.clusterRadius = [value integerValue];
- }
-
- if (id value = self.options[MGLShapeSourceOptionMaximumZoomLevelForClustering]) {
- [self validateValue:value];
- mbglOptions.clusterMaxZoom = [value integerValue];
- }
-
- if (id value = self.options[MGLShapeSourceOptionClustered]) {
- [self validateValue:value];
- mbglOptions.cluster = [value boolValue];
- }
-
- return mbglOptions;
+- (void)setShape:(MGLShape *)shape {
+ self.rawSource->setGeoJSON({ shape.geoJSONObject });
+ _shape = shape;
}
-- (void)validateValue:(id)value
-{
- if (! [value isKindOfClass:[NSNumber class]])
- {
- [NSException raise:@"Value not handled" format:@"%@ is not an NSNumber", value];
- }
+- (NSString *)description {
+ return [NSString stringWithFormat:@"<%@: %p; identifier = %@; URL = %@; shape = %@>",
+ NSStringFromClass([self class]), (void *)self, self.identifier, self.URL, self.shape];
}
-- (void)setGeoJSONData:(NSData *)geoJSONData
-{
- _geoJSONData = geoJSONData;
+@end
+
+mbgl::style::GeoJSONOptions MGLGeoJSONOptionsFromDictionary(NS_DICTIONARY_OF(MGLShapeSourceOption, id) *options) {
+ auto geoJSONOptions = mbgl::style::GeoJSONOptions();
- if (self.rawSource == NULL)
- {
- [self commonInit];
+ if (NSNumber *value = options[MGLShapeSourceOptionMaximumZoomLevel]) {
+ if (![value isKindOfClass:[NSNumber class]]) {
+ [NSException raise:NSInvalidArgumentException
+ format:@"MGLShapeSourceOptionMaximumZoomLevel must be an NSNumber."];
+ }
+ geoJSONOptions.maxzoom = value.integerValue;
}
- NSString *string = [[NSString alloc] initWithData:_geoJSONData encoding:NSUTF8StringEncoding];
- const auto geojson = mapbox::geojson::parse(string.UTF8String);
- self.rawSource->setGeoJSON(geojson);
+ if (NSNumber *value = options[MGLShapeSourceOptionBuffer]) {
+ if (![value isKindOfClass:[NSNumber class]]) {
+ [NSException raise:NSInvalidArgumentException
+ format:@"MGLShapeSourceOptionBuffer must be an NSNumber."];
+ }
+ geoJSONOptions.buffer = value.integerValue;
+ }
- _shape = MGLShapeFromGeoJSON(geojson);
-}
-
-- (void)setURL:(NSURL *)URL
-{
- _URL = URL;
+ if (NSNumber *value = options[MGLShapeSourceOptionSimplificationTolerance]) {
+ if (![value isKindOfClass:[NSNumber class]]) {
+ [NSException raise:NSInvalidArgumentException
+ format:@"MGLShapeSourceOptionSimplificationTolerance must be an NSNumber."];
+ }
+ geoJSONOptions.tolerance = value.doubleValue;
+ }
+
+ if (NSNumber *value = options[MGLShapeSourceOptionClusterRadius]) {
+ if (![value isKindOfClass:[NSNumber class]]) {
+ [NSException raise:NSInvalidArgumentException
+ format:@"MGLShapeSourceOptionClusterRadius must be an NSNumber."];
+ }
+ geoJSONOptions.clusterRadius = value.integerValue;
+ }
- if (self.rawSource == NULL)
- {
- [self commonInit];
+ if (NSNumber *value = options[MGLShapeSourceOptionMaximumZoomLevelForClustering]) {
+ if (![value isKindOfClass:[NSNumber class]]) {
+ [NSException raise:NSInvalidArgumentException
+ format:@"MGLShapeSourceOptionMaximumZoomLevelForClustering must be an NSNumber."];
+ }
+ geoJSONOptions.clusterMaxZoom = value.integerValue;
}
- NSURL *url = self.URL.mgl_URLByStandardizingScheme;
- self.rawSource->setURL(url.absoluteString.UTF8String);
-}
-
-
-- (void)setShape:(MGLShape *)shape
-{
- if (self.rawSource == NULL)
- {
- [self commonInit];
+ if (NSNumber *value = options[MGLShapeSourceOptionClustered]) {
+ if (![value isKindOfClass:[NSNumber class]]) {
+ [NSException raise:NSInvalidArgumentException
+ format:@"MGLShapeSourceOptionClustered must be an NSNumber."];
+ }
+ geoJSONOptions.cluster = value.boolValue;
}
-
- const auto geojson = mbgl::GeoJSON{shape.geometryObject};
- self.rawSource->setGeoJSON(geojson);
- _shape = shape;
-}
-
-- (NSString *)description
-{
- return [NSString stringWithFormat:@"<%@: %p; identifier = %@; URL = %@; geoJSONData = %@; shape = %@>",
- NSStringFromClass([self class]), (void *)self, self.identifier, self.URL, self.geoJSONData, self.shape];
+ return geoJSONOptions;
}
-
-@end
diff --git a/platform/darwin/src/MGLShapeSource_Private.h b/platform/darwin/src/MGLShapeSource_Private.h
index af5dc33f96..584a5a4b30 100644
--- a/platform/darwin/src/MGLShapeSource_Private.h
+++ b/platform/darwin/src/MGLShapeSource_Private.h
@@ -1,12 +1,21 @@
#import "MGLShapeSource.h"
#import "MGLShapeSource_Private.h"
-#include <mbgl/style/sources/geojson_source.hpp>
+NS_ASSUME_NONNULL_BEGIN
+
+namespace mbgl {
+ namespace style {
+ class GeoJSONOptions;
+ struct GeoJSONSource;
+ }
+}
@interface MGLShapeSource (Private)
- (instancetype)initWithRawSource:(mbgl::style::GeoJSONSource *)rawSource;
-- (mbgl::style::GeoJSONOptions)geoJSONOptions;
-
@end
+
+mbgl::style::GeoJSONOptions MGLGeoJSONOptionsFromDictionary(NS_DICTIONARY_OF(MGLShapeSourceOption, id) *options);
+
+NS_ASSUME_NONNULL_END
diff --git a/platform/darwin/src/MGLShape_Private.h b/platform/darwin/src/MGLShape_Private.h
index 2c7c4700a3..15d1c1eb97 100644
--- a/platform/darwin/src/MGLShape_Private.h
+++ b/platform/darwin/src/MGLShape_Private.h
@@ -1,10 +1,16 @@
#import "MGLShape.h"
+#import <mbgl/util/geojson.hpp>
#import <mbgl/util/geometry.hpp>
@interface MGLShape (Private)
/**
+ Returns an `mbgl::GeoJSON` representation of the `MGLShape`.
+ */
+- (mbgl::GeoJSON)geoJSONObject;
+
+/**
Returns an `mbgl::Geometry<double>` representation of the `MGLShape`.
*/
- (mbgl::Geometry<double>)geometryObject;
diff --git a/platform/darwin/src/MGLSource.h b/platform/darwin/src/MGLSource.h
index f0a8aacecb..6b381fca19 100644
--- a/platform/darwin/src/MGLSource.h
+++ b/platform/darwin/src/MGLSource.h
@@ -1,5 +1,7 @@
#import <Foundation/Foundation.h>
+NS_ASSUME_NONNULL_BEGIN
+
/**
`MGLSource` is an abstract base class for map content sources. A map content
source supplies content to be shown on the map. A source is added to an
@@ -13,13 +15,15 @@
`-[MGLStyle addSource:]` and `-[MGLStyle sourceWithIdentifier:]`.
Do not create instances of this class directly, and do not create your own
- subclasses of this class. Instead, create instances of `MGLRasterSource`,
- `MGLShapeSource`, and `MGLVectorSource`.
+ subclasses of this class. Instead, create instances of `MGLShapeSource` and the
+ concrete subclasses of `MGLTileSource`.
*/
@interface MGLSource : NSObject
#pragma mark Initializing a Source
+- (instancetype)init __attribute__((unavailable("Use -initWithIdentifier: instead.")));
+
/**
Returns a source initialized with an identifier.
@@ -40,3 +44,5 @@
@property (nonatomic, copy) NSString *identifier;
@end
+
+NS_ASSUME_NONNULL_END
diff --git a/platform/darwin/src/MGLSource_Private.h b/platform/darwin/src/MGLSource_Private.h
index 3100e0ae6e..6e1d2e379c 100644
--- a/platform/darwin/src/MGLSource_Private.h
+++ b/platform/darwin/src/MGLSource_Private.h
@@ -1,5 +1,7 @@
#import "MGLSource.h"
+NS_ASSUME_NONNULL_BEGIN
+
namespace mbgl {
namespace style {
class Source;
@@ -46,3 +48,5 @@ namespace mbgl {
- (void)removeFromMapView:(MGLMapView *)mapView;
@end
+
+NS_ASSUME_NONNULL_END
diff --git a/platform/darwin/src/MGLStyle.mm b/platform/darwin/src/MGLStyle.mm
index 1e60b956c7..c2ae75ed9c 100644
--- a/platform/darwin/src/MGLStyle.mm
+++ b/platform/darwin/src/MGLStyle.mm
@@ -17,12 +17,12 @@
#import "NSDate+MGLAdditions.h"
#import "MGLSource.h"
-#import "MGLVectorSource_Private.h"
+#import "MGLTileSource_Private.h"
+#import "MGLVectorSource.h"
#import "MGLRasterSource.h"
#import "MGLShapeSource.h"
-#import "MGLAttributionInfo.h"
-#import "MGLTileSet_Private.h"
+#import "MGLAttributionInfo_Private.h"
#include <mbgl/util/default_styles.hpp>
#include <mbgl/sprite/sprite_image.hpp>
@@ -209,13 +209,12 @@ static NSURL *MGLStyleURL_emerald;
auto rawSources = self.mapView.mbglMap->getSources();
NSMutableArray *infos = [NSMutableArray arrayWithCapacity:rawSources.size()];
for (auto rawSource = rawSources.begin(); rawSource != rawSources.end(); ++rawSource) {
- MGLSource *source = [self sourceFromMBGLSource:*rawSource];
- if (![source isKindOfClass:[MGLVectorSource class]]
- && ![source isKindOfClass:[MGLRasterSource class]]) {
+ MGLTileSource *source = (MGLTileSource *)[self sourceFromMBGLSource:*rawSource];
+ if (![source isKindOfClass:[MGLTileSource class]]) {
continue;
}
- NSArray *tileSetInfos = [[(id)source tileSet] attributionInfosWithFontSize:fontSize linkColor:linkColor];
+ NSArray *tileSetInfos = [source attributionInfosWithFontSize:fontSize linkColor:linkColor];
[infos growArrayByAddingAttributionInfosFromArray:tileSetInfos];
}
return infos;
diff --git a/platform/darwin/src/MGLStyleLayer.mm.ejs b/platform/darwin/src/MGLStyleLayer.mm.ejs
index 032fbfcc9b..3b446dd02e 100644
--- a/platform/darwin/src/MGLStyleLayer.mm.ejs
+++ b/platform/darwin/src/MGLStyleLayer.mm.ejs
@@ -62,7 +62,7 @@ namespace mbgl {
if (self = [super initWithIdentifier:identifier]) {
auto layer = std::make_unique<mbgl::style::<%- camelize(type) %>Layer>(identifier.UTF8String);
_pendingLayer = std::move(layer);
- _rawLayer = _pendingLayer.get();
+ self.rawLayer = _pendingLayer.get();
}
return self;
}
@@ -73,17 +73,28 @@ namespace mbgl {
if (self = [super initWithIdentifier:identifier source:source]) {
auto layer = std::make_unique<mbgl::style::<%- camelize(type) %>Layer>(identifier.UTF8String, source.identifier.UTF8String);
_pendingLayer = std::move(layer);
- _rawLayer = _pendingLayer.get();
+ self.rawLayer = _pendingLayer.get();
}
return self;
}
+
<% } -%>
+- (mbgl::style::<%- camelize(type) %>Layer *)rawLayer
+{
+ return (mbgl::style::<%- camelize(type) %>Layer *)super.rawLayer;
+}
+
+- (void)setRawLayer:(mbgl::style::<%- camelize(type) %>Layer *)rawLayer
+{
+ super.rawLayer = rawLayer;
+}
+
<% if (type !== 'background' && type !== 'raster') { -%>
- (NSString *)sourceLayerIdentifier
{
MGLAssertStyleLayerIsValid();
- auto layerID = _rawLayer->getSourceLayer();
+ auto layerID = self.rawLayer->getSourceLayer();
return layerID.empty() ? nil : @(layerID.c_str());
}
@@ -91,24 +102,25 @@ namespace mbgl {
{
MGLAssertStyleLayerIsValid();
- _rawLayer->setSourceLayer(sourceLayerIdentifier.UTF8String ?: "");
+ self.rawLayer->setSourceLayer(sourceLayerIdentifier.UTF8String ?: "");
}
- (void)setPredicate:(NSPredicate *)predicate
{
MGLAssertStyleLayerIsValid();
- _rawLayer->setFilter(predicate.mgl_filter);
+ self.rawLayer->setFilter(predicate.mgl_filter);
}
- (NSPredicate *)predicate
{
MGLAssertStyleLayerIsValid();
- return [NSPredicate mgl_predicateWithFilter:_rawLayer->getFilter()];
+ return [NSPredicate mgl_predicateWithFilter:self.rawLayer->getFilter()];
}
+
<% } -%>
-#pragma mark - Adding to and removing from a map view
+#pragma mark - Adding to and removing from a map view
- (void)addToMapView:(MGLMapView *)mapView belowLayer:(MGLStyleLayer *)otherLayer
{
@@ -129,7 +141,7 @@ namespace mbgl {
- (void)removeFromMapView:(MGLMapView *)mapView
{
_pendingLayer = nullptr;
- _rawLayer = nullptr;
+ self.rawLayer = nullptr;
auto removedLayer = mapView.mbglMap->removeLayer(self.identifier.UTF8String);
if (!removedLayer) {
@@ -144,7 +156,7 @@ namespace mbgl {
removedLayer.release();
_pendingLayer = std::unique_ptr<mbgl::style::<%- camelize(type) %>Layer>(layer);
- _rawLayer = _pendingLayer.get();
+ self.rawLayer = _pendingLayer.get();
}
<% if (layoutProperties.length) { -%>
@@ -156,17 +168,17 @@ namespace mbgl {
<% if (property.type == "enum") { -%>
auto mbglValue = MGLStyleValueTransformer<mbgl::style::<%- mbglType(property) %>, NSValue *, mbgl::style::<%- mbglType(property) %>, MGL<%- camelize(originalPropertyName(property)) %>>().toEnumPropertyValue(<%- objCName(property) %>);
- _rawLayer->set<%- camelize(originalPropertyName(property)) %>(mbglValue);
+ self.rawLayer->set<%- camelize(originalPropertyName(property)) %>(mbglValue);
<% } else { -%>
auto mbglValue = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toPropertyValue(<%- objCName(property) %>);
- _rawLayer->set<%- camelize(originalPropertyName(property)) %>(mbglValue);
+ self.rawLayer->set<%- camelize(originalPropertyName(property)) %>(mbglValue);
<% } -%>
}
- (MGLStyleValue<<%- propertyType(property, true) %>> *)<%- objCName(property) %> {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->get<%- camelize(originalPropertyName(property)) %>() ?: _rawLayer->getDefault<%- camelize(originalPropertyName(property)) %>();
+ auto propertyValue = self.rawLayer->get<%- camelize(originalPropertyName(property)) %>() ?: self.rawLayer->getDefault<%- camelize(originalPropertyName(property)) %>();
<% if (property.type == "enum") { -%>
return MGLStyleValueTransformer<mbgl::style::<%- mbglType(property) %>, NSValue *, mbgl::style::<%- mbglType(property) %>, MGL<%- camelize(originalPropertyName(property)) %>>().toEnumStyleValue(propertyValue);
<% } else { -%>
@@ -185,17 +197,17 @@ namespace mbgl {
<% if (property.type == "enum") { -%>
auto mbglValue = MGLStyleValueTransformer<mbgl::style::<%- mbglType(property) %>, NSValue *, mbgl::style::<%- mbglType(property) %>, MGL<%- camelize(originalPropertyName(property)) %>>().toEnumPropertyValue(<%- objCName(property) %>);
- _rawLayer->set<%- camelize(originalPropertyName(property)) %>(mbglValue);
+ self.rawLayer->set<%- camelize(originalPropertyName(property)) %>(mbglValue);
<% } else { -%>
auto mbglValue = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toPropertyValue(<%- objCName(property) %>);
- _rawLayer->set<%- camelize(originalPropertyName(property)) %>(mbglValue);
+ self.rawLayer->set<%- camelize(originalPropertyName(property)) %>(mbglValue);
<% } -%>
}
- (MGLStyleValue<<%- propertyType(property, true) %>> *)<%- objCName(property) %> {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->get<%- camelize(originalPropertyName(property)) %>() ?: _rawLayer->getDefault<%- camelize(originalPropertyName(property)) %>();
+ auto propertyValue = self.rawLayer->get<%- camelize(originalPropertyName(property)) %>() ?: self.rawLayer->getDefault<%- camelize(originalPropertyName(property)) %>();
<% if (property.type == "enum") { -%>
return MGLStyleValueTransformer<mbgl::style::<%- mbglType(property) %>, NSValue *, mbgl::style::<%- mbglType(property) %>, MGL<%- camelize(originalPropertyName(property)) %>>().toEnumStyleValue(propertyValue);
<% } else { -%>
diff --git a/platform/darwin/src/MGLStyleLayer_Private.h b/platform/darwin/src/MGLStyleLayer_Private.h
index 077af9a995..8f1cdfb4a1 100644
--- a/platform/darwin/src/MGLStyleLayer_Private.h
+++ b/platform/darwin/src/MGLStyleLayer_Private.h
@@ -21,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN
@"-[MGLStyle removeLayer:] has been called " \
@"with this instance but another style layer instance was added with the same identifer. It is an " \
@"error to send any message to this layer since it cannot be recovered after removal due to the " \
- @"identifer collision. Use unique identifiers for all layer instances including layers of " \
+ @"identifier collision. Use unique identifiers for all layer instances including layers of " \
@"different types."]; \
} \
} while (NO);
diff --git a/platform/darwin/src/MGLSymbolStyleLayer.mm b/platform/darwin/src/MGLSymbolStyleLayer.mm
index 2561152efc..af92c6ba67 100644
--- a/platform/darwin/src/MGLSymbolStyleLayer.mm
+++ b/platform/darwin/src/MGLSymbolStyleLayer.mm
@@ -93,15 +93,26 @@ namespace mbgl {
if (self = [super initWithIdentifier:identifier source:source]) {
auto layer = std::make_unique<mbgl::style::SymbolLayer>(identifier.UTF8String, source.identifier.UTF8String);
_pendingLayer = std::move(layer);
- _rawLayer = _pendingLayer.get();
+ self.rawLayer = _pendingLayer.get();
}
return self;
}
+
+- (mbgl::style::SymbolLayer *)rawLayer
+{
+ return (mbgl::style::SymbolLayer *)super.rawLayer;
+}
+
+- (void)setRawLayer:(mbgl::style::SymbolLayer *)rawLayer
+{
+ super.rawLayer = rawLayer;
+}
+
- (NSString *)sourceLayerIdentifier
{
MGLAssertStyleLayerIsValid();
- auto layerID = _rawLayer->getSourceLayer();
+ auto layerID = self.rawLayer->getSourceLayer();
return layerID.empty() ? nil : @(layerID.c_str());
}
@@ -109,22 +120,23 @@ namespace mbgl {
{
MGLAssertStyleLayerIsValid();
- _rawLayer->setSourceLayer(sourceLayerIdentifier.UTF8String ?: "");
+ self.rawLayer->setSourceLayer(sourceLayerIdentifier.UTF8String ?: "");
}
- (void)setPredicate:(NSPredicate *)predicate
{
MGLAssertStyleLayerIsValid();
- _rawLayer->setFilter(predicate.mgl_filter);
+ self.rawLayer->setFilter(predicate.mgl_filter);
}
- (NSPredicate *)predicate
{
MGLAssertStyleLayerIsValid();
- return [NSPredicate mgl_predicateWithFilter:_rawLayer->getFilter()];
+ return [NSPredicate mgl_predicateWithFilter:self.rawLayer->getFilter()];
}
+
#pragma mark - Adding to and removing from a map view
- (void)addToMapView:(MGLMapView *)mapView belowLayer:(MGLStyleLayer *)otherLayer
@@ -146,7 +158,7 @@ namespace mbgl {
- (void)removeFromMapView:(MGLMapView *)mapView
{
_pendingLayer = nullptr;
- _rawLayer = nullptr;
+ self.rawLayer = nullptr;
auto removedLayer = mapView.mbglMap->removeLayer(self.identifier.UTF8String);
if (!removedLayer) {
@@ -161,7 +173,7 @@ namespace mbgl {
removedLayer.release();
_pendingLayer = std::unique_ptr<mbgl::style::SymbolLayer>(layer);
- _rawLayer = _pendingLayer.get();
+ self.rawLayer = _pendingLayer.get();
}
#pragma mark - Accessing the Layout Attributes
@@ -170,13 +182,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<bool, NSNumber *>().toPropertyValue(iconAllowOverlap);
- _rawLayer->setIconAllowOverlap(mbglValue);
+ self.rawLayer->setIconAllowOverlap(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)iconAllowOverlap {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getIconAllowOverlap() ?: _rawLayer->getDefaultIconAllowOverlap();
+ auto propertyValue = self.rawLayer->getIconAllowOverlap() ?: self.rawLayer->getDefaultIconAllowOverlap();
return MGLStyleValueTransformer<bool, NSNumber *>().toStyleValue(propertyValue);
}
@@ -184,13 +196,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<bool, NSNumber *>().toPropertyValue(iconIgnorePlacement);
- _rawLayer->setIconIgnorePlacement(mbglValue);
+ self.rawLayer->setIconIgnorePlacement(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)iconIgnorePlacement {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getIconIgnorePlacement() ?: _rawLayer->getDefaultIconIgnorePlacement();
+ auto propertyValue = self.rawLayer->getIconIgnorePlacement() ?: self.rawLayer->getDefaultIconIgnorePlacement();
return MGLStyleValueTransformer<bool, NSNumber *>().toStyleValue(propertyValue);
}
@@ -198,13 +210,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<std::string, NSString *>().toPropertyValue(iconImageName);
- _rawLayer->setIconImage(mbglValue);
+ self.rawLayer->setIconImage(mbglValue);
}
- (MGLStyleValue<NSString *> *)iconImageName {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getIconImage() ?: _rawLayer->getDefaultIconImage();
+ auto propertyValue = self.rawLayer->getIconImage() ?: self.rawLayer->getDefaultIconImage();
return MGLStyleValueTransformer<std::string, NSString *>().toStyleValue(propertyValue);
}
@@ -212,13 +224,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<bool, NSNumber *>().toPropertyValue(iconKeepUpright);
- _rawLayer->setIconKeepUpright(mbglValue);
+ self.rawLayer->setIconKeepUpright(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)iconKeepUpright {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getIconKeepUpright() ?: _rawLayer->getDefaultIconKeepUpright();
+ auto propertyValue = self.rawLayer->getIconKeepUpright() ?: self.rawLayer->getDefaultIconKeepUpright();
return MGLStyleValueTransformer<bool, NSNumber *>().toStyleValue(propertyValue);
}
@@ -226,13 +238,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toPropertyValue(iconOffset);
- _rawLayer->setIconOffset(mbglValue);
+ self.rawLayer->setIconOffset(mbglValue);
}
- (MGLStyleValue<NSValue *> *)iconOffset {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getIconOffset() ?: _rawLayer->getDefaultIconOffset();
+ auto propertyValue = self.rawLayer->getIconOffset() ?: self.rawLayer->getDefaultIconOffset();
return MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toStyleValue(propertyValue);
}
@@ -240,13 +252,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<bool, NSNumber *>().toPropertyValue(iconOptional);
- _rawLayer->setIconOptional(mbglValue);
+ self.rawLayer->setIconOptional(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)iconOptional {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getIconOptional() ?: _rawLayer->getDefaultIconOptional();
+ auto propertyValue = self.rawLayer->getIconOptional() ?: self.rawLayer->getDefaultIconOptional();
return MGLStyleValueTransformer<bool, NSNumber *>().toStyleValue(propertyValue);
}
@@ -254,13 +266,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(iconPadding);
- _rawLayer->setIconPadding(mbglValue);
+ self.rawLayer->setIconPadding(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)iconPadding {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getIconPadding() ?: _rawLayer->getDefaultIconPadding();
+ auto propertyValue = self.rawLayer->getIconPadding() ?: self.rawLayer->getDefaultIconPadding();
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}
@@ -268,13 +280,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(iconRotate);
- _rawLayer->setIconRotate(mbglValue);
+ self.rawLayer->setIconRotate(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)iconRotate {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getIconRotate() ?: _rawLayer->getDefaultIconRotate();
+ auto propertyValue = self.rawLayer->getIconRotate() ?: self.rawLayer->getDefaultIconRotate();
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}
@@ -282,13 +294,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<mbgl::style::AlignmentType, NSValue *, mbgl::style::AlignmentType, MGLIconRotationAlignment>().toEnumPropertyValue(iconRotationAlignment);
- _rawLayer->setIconRotationAlignment(mbglValue);
+ self.rawLayer->setIconRotationAlignment(mbglValue);
}
- (MGLStyleValue<NSValue *> *)iconRotationAlignment {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getIconRotationAlignment() ?: _rawLayer->getDefaultIconRotationAlignment();
+ auto propertyValue = self.rawLayer->getIconRotationAlignment() ?: self.rawLayer->getDefaultIconRotationAlignment();
return MGLStyleValueTransformer<mbgl::style::AlignmentType, NSValue *, mbgl::style::AlignmentType, MGLIconRotationAlignment>().toEnumStyleValue(propertyValue);
}
@@ -296,13 +308,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(iconScale);
- _rawLayer->setIconSize(mbglValue);
+ self.rawLayer->setIconSize(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)iconScale {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getIconSize() ?: _rawLayer->getDefaultIconSize();
+ auto propertyValue = self.rawLayer->getIconSize() ?: self.rawLayer->getDefaultIconSize();
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}
@@ -310,13 +322,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<mbgl::style::IconTextFitType, NSValue *, mbgl::style::IconTextFitType, MGLIconTextFit>().toEnumPropertyValue(iconTextFit);
- _rawLayer->setIconTextFit(mbglValue);
+ self.rawLayer->setIconTextFit(mbglValue);
}
- (MGLStyleValue<NSValue *> *)iconTextFit {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getIconTextFit() ?: _rawLayer->getDefaultIconTextFit();
+ auto propertyValue = self.rawLayer->getIconTextFit() ?: self.rawLayer->getDefaultIconTextFit();
return MGLStyleValueTransformer<mbgl::style::IconTextFitType, NSValue *, mbgl::style::IconTextFitType, MGLIconTextFit>().toEnumStyleValue(propertyValue);
}
@@ -324,13 +336,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<std::array<float, 4>, NSValue *>().toPropertyValue(iconTextFitPadding);
- _rawLayer->setIconTextFitPadding(mbglValue);
+ self.rawLayer->setIconTextFitPadding(mbglValue);
}
- (MGLStyleValue<NSValue *> *)iconTextFitPadding {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getIconTextFitPadding() ?: _rawLayer->getDefaultIconTextFitPadding();
+ auto propertyValue = self.rawLayer->getIconTextFitPadding() ?: self.rawLayer->getDefaultIconTextFitPadding();
return MGLStyleValueTransformer<std::array<float, 4>, NSValue *>().toStyleValue(propertyValue);
}
@@ -338,13 +350,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<bool, NSNumber *>().toPropertyValue(symbolAvoidEdges);
- _rawLayer->setSymbolAvoidEdges(mbglValue);
+ self.rawLayer->setSymbolAvoidEdges(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)symbolAvoidEdges {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getSymbolAvoidEdges() ?: _rawLayer->getDefaultSymbolAvoidEdges();
+ auto propertyValue = self.rawLayer->getSymbolAvoidEdges() ?: self.rawLayer->getDefaultSymbolAvoidEdges();
return MGLStyleValueTransformer<bool, NSNumber *>().toStyleValue(propertyValue);
}
@@ -352,13 +364,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<mbgl::style::SymbolPlacementType, NSValue *, mbgl::style::SymbolPlacementType, MGLSymbolPlacement>().toEnumPropertyValue(symbolPlacement);
- _rawLayer->setSymbolPlacement(mbglValue);
+ self.rawLayer->setSymbolPlacement(mbglValue);
}
- (MGLStyleValue<NSValue *> *)symbolPlacement {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getSymbolPlacement() ?: _rawLayer->getDefaultSymbolPlacement();
+ auto propertyValue = self.rawLayer->getSymbolPlacement() ?: self.rawLayer->getDefaultSymbolPlacement();
return MGLStyleValueTransformer<mbgl::style::SymbolPlacementType, NSValue *, mbgl::style::SymbolPlacementType, MGLSymbolPlacement>().toEnumStyleValue(propertyValue);
}
@@ -366,13 +378,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(symbolSpacing);
- _rawLayer->setSymbolSpacing(mbglValue);
+ self.rawLayer->setSymbolSpacing(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)symbolSpacing {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getSymbolSpacing() ?: _rawLayer->getDefaultSymbolSpacing();
+ auto propertyValue = self.rawLayer->getSymbolSpacing() ?: self.rawLayer->getDefaultSymbolSpacing();
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}
@@ -380,13 +392,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<bool, NSNumber *>().toPropertyValue(textAllowOverlap);
- _rawLayer->setTextAllowOverlap(mbglValue);
+ self.rawLayer->setTextAllowOverlap(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)textAllowOverlap {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getTextAllowOverlap() ?: _rawLayer->getDefaultTextAllowOverlap();
+ auto propertyValue = self.rawLayer->getTextAllowOverlap() ?: self.rawLayer->getDefaultTextAllowOverlap();
return MGLStyleValueTransformer<bool, NSNumber *>().toStyleValue(propertyValue);
}
@@ -394,13 +406,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<mbgl::style::TextAnchorType, NSValue *, mbgl::style::TextAnchorType, MGLTextAnchor>().toEnumPropertyValue(textAnchor);
- _rawLayer->setTextAnchor(mbglValue);
+ self.rawLayer->setTextAnchor(mbglValue);
}
- (MGLStyleValue<NSValue *> *)textAnchor {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getTextAnchor() ?: _rawLayer->getDefaultTextAnchor();
+ auto propertyValue = self.rawLayer->getTextAnchor() ?: self.rawLayer->getDefaultTextAnchor();
return MGLStyleValueTransformer<mbgl::style::TextAnchorType, NSValue *, mbgl::style::TextAnchorType, MGLTextAnchor>().toEnumStyleValue(propertyValue);
}
@@ -408,13 +420,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<std::string, NSString *>().toPropertyValue(textField);
- _rawLayer->setTextField(mbglValue);
+ self.rawLayer->setTextField(mbglValue);
}
- (MGLStyleValue<NSString *> *)textField {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getTextField() ?: _rawLayer->getDefaultTextField();
+ auto propertyValue = self.rawLayer->getTextField() ?: self.rawLayer->getDefaultTextField();
return MGLStyleValueTransformer<std::string, NSString *>().toStyleValue(propertyValue);
}
@@ -422,13 +434,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<std::vector<std::string>, NSArray<NSString *> *, std::string>().toPropertyValue(textFont);
- _rawLayer->setTextFont(mbglValue);
+ self.rawLayer->setTextFont(mbglValue);
}
- (MGLStyleValue<NSArray<NSString *> *> *)textFont {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getTextFont() ?: _rawLayer->getDefaultTextFont();
+ auto propertyValue = self.rawLayer->getTextFont() ?: self.rawLayer->getDefaultTextFont();
return MGLStyleValueTransformer<std::vector<std::string>, NSArray<NSString *> *, std::string>().toStyleValue(propertyValue);
}
@@ -436,13 +448,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<bool, NSNumber *>().toPropertyValue(textIgnorePlacement);
- _rawLayer->setTextIgnorePlacement(mbglValue);
+ self.rawLayer->setTextIgnorePlacement(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)textIgnorePlacement {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getTextIgnorePlacement() ?: _rawLayer->getDefaultTextIgnorePlacement();
+ auto propertyValue = self.rawLayer->getTextIgnorePlacement() ?: self.rawLayer->getDefaultTextIgnorePlacement();
return MGLStyleValueTransformer<bool, NSNumber *>().toStyleValue(propertyValue);
}
@@ -450,13 +462,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<mbgl::style::TextJustifyType, NSValue *, mbgl::style::TextJustifyType, MGLTextJustify>().toEnumPropertyValue(textJustify);
- _rawLayer->setTextJustify(mbglValue);
+ self.rawLayer->setTextJustify(mbglValue);
}
- (MGLStyleValue<NSValue *> *)textJustify {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getTextJustify() ?: _rawLayer->getDefaultTextJustify();
+ auto propertyValue = self.rawLayer->getTextJustify() ?: self.rawLayer->getDefaultTextJustify();
return MGLStyleValueTransformer<mbgl::style::TextJustifyType, NSValue *, mbgl::style::TextJustifyType, MGLTextJustify>().toEnumStyleValue(propertyValue);
}
@@ -464,13 +476,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<bool, NSNumber *>().toPropertyValue(textKeepUpright);
- _rawLayer->setTextKeepUpright(mbglValue);
+ self.rawLayer->setTextKeepUpright(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)textKeepUpright {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getTextKeepUpright() ?: _rawLayer->getDefaultTextKeepUpright();
+ auto propertyValue = self.rawLayer->getTextKeepUpright() ?: self.rawLayer->getDefaultTextKeepUpright();
return MGLStyleValueTransformer<bool, NSNumber *>().toStyleValue(propertyValue);
}
@@ -478,13 +490,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(textLetterSpacing);
- _rawLayer->setTextLetterSpacing(mbglValue);
+ self.rawLayer->setTextLetterSpacing(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)textLetterSpacing {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getTextLetterSpacing() ?: _rawLayer->getDefaultTextLetterSpacing();
+ auto propertyValue = self.rawLayer->getTextLetterSpacing() ?: self.rawLayer->getDefaultTextLetterSpacing();
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}
@@ -492,13 +504,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(textLineHeight);
- _rawLayer->setTextLineHeight(mbglValue);
+ self.rawLayer->setTextLineHeight(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)textLineHeight {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getTextLineHeight() ?: _rawLayer->getDefaultTextLineHeight();
+ auto propertyValue = self.rawLayer->getTextLineHeight() ?: self.rawLayer->getDefaultTextLineHeight();
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}
@@ -506,13 +518,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(textMaxAngle);
- _rawLayer->setTextMaxAngle(mbglValue);
+ self.rawLayer->setTextMaxAngle(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)textMaxAngle {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getTextMaxAngle() ?: _rawLayer->getDefaultTextMaxAngle();
+ auto propertyValue = self.rawLayer->getTextMaxAngle() ?: self.rawLayer->getDefaultTextMaxAngle();
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}
@@ -520,13 +532,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(textMaxWidth);
- _rawLayer->setTextMaxWidth(mbglValue);
+ self.rawLayer->setTextMaxWidth(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)textMaxWidth {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getTextMaxWidth() ?: _rawLayer->getDefaultTextMaxWidth();
+ auto propertyValue = self.rawLayer->getTextMaxWidth() ?: self.rawLayer->getDefaultTextMaxWidth();
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}
@@ -534,13 +546,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toPropertyValue(textOffset);
- _rawLayer->setTextOffset(mbglValue);
+ self.rawLayer->setTextOffset(mbglValue);
}
- (MGLStyleValue<NSValue *> *)textOffset {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getTextOffset() ?: _rawLayer->getDefaultTextOffset();
+ auto propertyValue = self.rawLayer->getTextOffset() ?: self.rawLayer->getDefaultTextOffset();
return MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toStyleValue(propertyValue);
}
@@ -548,13 +560,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<bool, NSNumber *>().toPropertyValue(textOptional);
- _rawLayer->setTextOptional(mbglValue);
+ self.rawLayer->setTextOptional(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)textOptional {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getTextOptional() ?: _rawLayer->getDefaultTextOptional();
+ auto propertyValue = self.rawLayer->getTextOptional() ?: self.rawLayer->getDefaultTextOptional();
return MGLStyleValueTransformer<bool, NSNumber *>().toStyleValue(propertyValue);
}
@@ -562,13 +574,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(textPadding);
- _rawLayer->setTextPadding(mbglValue);
+ self.rawLayer->setTextPadding(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)textPadding {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getTextPadding() ?: _rawLayer->getDefaultTextPadding();
+ auto propertyValue = self.rawLayer->getTextPadding() ?: self.rawLayer->getDefaultTextPadding();
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}
@@ -576,13 +588,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<mbgl::style::AlignmentType, NSValue *, mbgl::style::AlignmentType, MGLTextPitchAlignment>().toEnumPropertyValue(textPitchAlignment);
- _rawLayer->setTextPitchAlignment(mbglValue);
+ self.rawLayer->setTextPitchAlignment(mbglValue);
}
- (MGLStyleValue<NSValue *> *)textPitchAlignment {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getTextPitchAlignment() ?: _rawLayer->getDefaultTextPitchAlignment();
+ auto propertyValue = self.rawLayer->getTextPitchAlignment() ?: self.rawLayer->getDefaultTextPitchAlignment();
return MGLStyleValueTransformer<mbgl::style::AlignmentType, NSValue *, mbgl::style::AlignmentType, MGLTextPitchAlignment>().toEnumStyleValue(propertyValue);
}
@@ -590,13 +602,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(textRotate);
- _rawLayer->setTextRotate(mbglValue);
+ self.rawLayer->setTextRotate(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)textRotate {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getTextRotate() ?: _rawLayer->getDefaultTextRotate();
+ auto propertyValue = self.rawLayer->getTextRotate() ?: self.rawLayer->getDefaultTextRotate();
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}
@@ -604,13 +616,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<mbgl::style::AlignmentType, NSValue *, mbgl::style::AlignmentType, MGLTextRotationAlignment>().toEnumPropertyValue(textRotationAlignment);
- _rawLayer->setTextRotationAlignment(mbglValue);
+ self.rawLayer->setTextRotationAlignment(mbglValue);
}
- (MGLStyleValue<NSValue *> *)textRotationAlignment {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getTextRotationAlignment() ?: _rawLayer->getDefaultTextRotationAlignment();
+ auto propertyValue = self.rawLayer->getTextRotationAlignment() ?: self.rawLayer->getDefaultTextRotationAlignment();
return MGLStyleValueTransformer<mbgl::style::AlignmentType, NSValue *, mbgl::style::AlignmentType, MGLTextRotationAlignment>().toEnumStyleValue(propertyValue);
}
@@ -618,13 +630,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(textSize);
- _rawLayer->setTextSize(mbglValue);
+ self.rawLayer->setTextSize(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)textSize {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getTextSize() ?: _rawLayer->getDefaultTextSize();
+ auto propertyValue = self.rawLayer->getTextSize() ?: self.rawLayer->getDefaultTextSize();
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}
@@ -632,13 +644,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<mbgl::style::TextTransformType, NSValue *, mbgl::style::TextTransformType, MGLTextTransform>().toEnumPropertyValue(textTransform);
- _rawLayer->setTextTransform(mbglValue);
+ self.rawLayer->setTextTransform(mbglValue);
}
- (MGLStyleValue<NSValue *> *)textTransform {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getTextTransform() ?: _rawLayer->getDefaultTextTransform();
+ auto propertyValue = self.rawLayer->getTextTransform() ?: self.rawLayer->getDefaultTextTransform();
return MGLStyleValueTransformer<mbgl::style::TextTransformType, NSValue *, mbgl::style::TextTransformType, MGLTextTransform>().toEnumStyleValue(propertyValue);
}
@@ -648,13 +660,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue(iconColor);
- _rawLayer->setIconColor(mbglValue);
+ self.rawLayer->setIconColor(mbglValue);
}
- (MGLStyleValue<MGLColor *> *)iconColor {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getIconColor() ?: _rawLayer->getDefaultIconColor();
+ auto propertyValue = self.rawLayer->getIconColor() ?: self.rawLayer->getDefaultIconColor();
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toStyleValue(propertyValue);
}
@@ -662,13 +674,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(iconHaloBlur);
- _rawLayer->setIconHaloBlur(mbglValue);
+ self.rawLayer->setIconHaloBlur(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)iconHaloBlur {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getIconHaloBlur() ?: _rawLayer->getDefaultIconHaloBlur();
+ auto propertyValue = self.rawLayer->getIconHaloBlur() ?: self.rawLayer->getDefaultIconHaloBlur();
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}
@@ -676,13 +688,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue(iconHaloColor);
- _rawLayer->setIconHaloColor(mbglValue);
+ self.rawLayer->setIconHaloColor(mbglValue);
}
- (MGLStyleValue<MGLColor *> *)iconHaloColor {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getIconHaloColor() ?: _rawLayer->getDefaultIconHaloColor();
+ auto propertyValue = self.rawLayer->getIconHaloColor() ?: self.rawLayer->getDefaultIconHaloColor();
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toStyleValue(propertyValue);
}
@@ -690,13 +702,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(iconHaloWidth);
- _rawLayer->setIconHaloWidth(mbglValue);
+ self.rawLayer->setIconHaloWidth(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)iconHaloWidth {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getIconHaloWidth() ?: _rawLayer->getDefaultIconHaloWidth();
+ auto propertyValue = self.rawLayer->getIconHaloWidth() ?: self.rawLayer->getDefaultIconHaloWidth();
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}
@@ -704,13 +716,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(iconOpacity);
- _rawLayer->setIconOpacity(mbglValue);
+ self.rawLayer->setIconOpacity(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)iconOpacity {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getIconOpacity() ?: _rawLayer->getDefaultIconOpacity();
+ auto propertyValue = self.rawLayer->getIconOpacity() ?: self.rawLayer->getDefaultIconOpacity();
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}
@@ -718,13 +730,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toPropertyValue(iconTranslate);
- _rawLayer->setIconTranslate(mbglValue);
+ self.rawLayer->setIconTranslate(mbglValue);
}
- (MGLStyleValue<NSValue *> *)iconTranslate {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getIconTranslate() ?: _rawLayer->getDefaultIconTranslate();
+ auto propertyValue = self.rawLayer->getIconTranslate() ?: self.rawLayer->getDefaultIconTranslate();
return MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toStyleValue(propertyValue);
}
@@ -732,13 +744,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLIconTranslateAnchor>().toEnumPropertyValue(iconTranslateAnchor);
- _rawLayer->setIconTranslateAnchor(mbglValue);
+ self.rawLayer->setIconTranslateAnchor(mbglValue);
}
- (MGLStyleValue<NSValue *> *)iconTranslateAnchor {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getIconTranslateAnchor() ?: _rawLayer->getDefaultIconTranslateAnchor();
+ auto propertyValue = self.rawLayer->getIconTranslateAnchor() ?: self.rawLayer->getDefaultIconTranslateAnchor();
return MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLIconTranslateAnchor>().toEnumStyleValue(propertyValue);
}
@@ -746,13 +758,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue(textColor);
- _rawLayer->setTextColor(mbglValue);
+ self.rawLayer->setTextColor(mbglValue);
}
- (MGLStyleValue<MGLColor *> *)textColor {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getTextColor() ?: _rawLayer->getDefaultTextColor();
+ auto propertyValue = self.rawLayer->getTextColor() ?: self.rawLayer->getDefaultTextColor();
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toStyleValue(propertyValue);
}
@@ -760,13 +772,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(textHaloBlur);
- _rawLayer->setTextHaloBlur(mbglValue);
+ self.rawLayer->setTextHaloBlur(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)textHaloBlur {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getTextHaloBlur() ?: _rawLayer->getDefaultTextHaloBlur();
+ auto propertyValue = self.rawLayer->getTextHaloBlur() ?: self.rawLayer->getDefaultTextHaloBlur();
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}
@@ -774,13 +786,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue(textHaloColor);
- _rawLayer->setTextHaloColor(mbglValue);
+ self.rawLayer->setTextHaloColor(mbglValue);
}
- (MGLStyleValue<MGLColor *> *)textHaloColor {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getTextHaloColor() ?: _rawLayer->getDefaultTextHaloColor();
+ auto propertyValue = self.rawLayer->getTextHaloColor() ?: self.rawLayer->getDefaultTextHaloColor();
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toStyleValue(propertyValue);
}
@@ -788,13 +800,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(textHaloWidth);
- _rawLayer->setTextHaloWidth(mbglValue);
+ self.rawLayer->setTextHaloWidth(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)textHaloWidth {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getTextHaloWidth() ?: _rawLayer->getDefaultTextHaloWidth();
+ auto propertyValue = self.rawLayer->getTextHaloWidth() ?: self.rawLayer->getDefaultTextHaloWidth();
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}
@@ -802,13 +814,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(textOpacity);
- _rawLayer->setTextOpacity(mbglValue);
+ self.rawLayer->setTextOpacity(mbglValue);
}
- (MGLStyleValue<NSNumber *> *)textOpacity {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getTextOpacity() ?: _rawLayer->getDefaultTextOpacity();
+ auto propertyValue = self.rawLayer->getTextOpacity() ?: self.rawLayer->getDefaultTextOpacity();
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}
@@ -816,13 +828,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toPropertyValue(textTranslate);
- _rawLayer->setTextTranslate(mbglValue);
+ self.rawLayer->setTextTranslate(mbglValue);
}
- (MGLStyleValue<NSValue *> *)textTranslate {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getTextTranslate() ?: _rawLayer->getDefaultTextTranslate();
+ auto propertyValue = self.rawLayer->getTextTranslate() ?: self.rawLayer->getDefaultTextTranslate();
return MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toStyleValue(propertyValue);
}
@@ -830,13 +842,13 @@ namespace mbgl {
MGLAssertStyleLayerIsValid();
auto mbglValue = MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLTextTranslateAnchor>().toEnumPropertyValue(textTranslateAnchor);
- _rawLayer->setTextTranslateAnchor(mbglValue);
+ self.rawLayer->setTextTranslateAnchor(mbglValue);
}
- (MGLStyleValue<NSValue *> *)textTranslateAnchor {
MGLAssertStyleLayerIsValid();
- auto propertyValue = _rawLayer->getTextTranslateAnchor() ?: _rawLayer->getDefaultTextTranslateAnchor();
+ auto propertyValue = self.rawLayer->getTextTranslateAnchor() ?: self.rawLayer->getDefaultTextTranslateAnchor();
return MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLTextTranslateAnchor>().toEnumStyleValue(propertyValue);
}
diff --git a/platform/darwin/src/MGLTileSet.h b/platform/darwin/src/MGLTileSet.h
deleted file mode 100644
index 88bc7e4ae0..0000000000
--- a/platform/darwin/src/MGLTileSet.h
+++ /dev/null
@@ -1,82 +0,0 @@
-#import <Foundation/Foundation.h>
-#import "MGLTypes.h"
-
-NS_ASSUME_NONNULL_BEGIN
-
-/** These constants represent the scheme that the tile URL templates will use. */
-typedef NS_ENUM(NSUInteger, MGLTileSetScheme) {
- MGLTileSetSchemeXYZ = 0,
- MGLTileSetSchemeTMS
-};
-
-/**
- The `MGLTileSet` class holds the tile URL template strings and associated
- configuration for those strings. It can be passed to an `MGLVectorSource` or
- `MGLRasterSource` instead of an `NSURL` representing a TileJSON URL to create a
- source.
- */
-@interface MGLTileSet : NSObject
-
-#pragma mark Creating a Tile Set
-
-/**
- Initializes and returns a new tile set object.
-
- @param tileURLTemplates An `NSArray` of `NSString` objects that represent the
- tile templates.
- @return The initialized tile set object.
- */
-- (instancetype)initWithTileURLTemplates:(NS_ARRAY_OF(NSString *) *)tileURLTemplates;
-
-/**
- Initializes and returns a new tile set object.
-
- @param tileURLTemplates An `NSArray` of `NSString` objects that represent the
- tile templates.
- @param minimumZoomLevel An `NSUInteger`; specifies the minimum zoom level at
- which to display tiles.
- @param maximumZoomLevel An `NSUInteger`; specifies the maximum zoom level at
- which to display tiles.
- @return The initialized tile set object.
- */
-- (instancetype)initWithTileURLTemplates:(NS_ARRAY_OF(NSString *) *)tileURLTemplates minimumZoomLevel:(NSUInteger)minimumZoomLevel maximumZoomLevel:(NSUInteger)maximumZoomLevel;
-
-#pragma mark Accessing Tile Set Metadata
-
-/**
- An `NSArray` of `NSString` objects that represent the tile templates.
- */
-@property (nonatomic, copy) NS_ARRAY_OF(NSString *) *tileURLTemplates;
-
-/**
- An `NSNumber` object containing an integer; specifies the minimum zoom level at
- which the source will display tiles. The value should be in the range of 0 to
- 22. The default value is 0 and the source will use the default value
- if `minimumZoomLevel` is nil.
- */
-@property (nonatomic, nullable) NSNumber *minimumZoomLevel;
-
-/**
- An `NSNumber` object containing an integer; specifies the maximum zoom level at
- which to display tiles. The value should be in the range of 0 to 22 and greater
- than `minimumZoomLevel`. The default value is 22 and the source will use the
- default value if `maximumZoomLevel` is nil.
- */
-@property (nonatomic, nullable) NSNumber *maximumZoomLevel;
-
-/**
- An `NSString` object that contains an attribution to be displayed when the map
- is shown to a user. The default value is `nil`.
- */
-@property (nonatomic, copy, nullable) NSString *attribution;
-
-/**
- An `MGLTileSetScheme` value that contains an enumeration (either
- `MGLTileSetSchemeXYZ` or `MGLTileSetSchemeTMS`) that influences the y direction
- of the tile coordinates. The default is `MGLTileSetSchemeXYZ`.
- */
-@property (nonatomic) MGLTileSetScheme scheme;
-
-@end
-
-NS_ASSUME_NONNULL_END
diff --git a/platform/darwin/src/MGLTileSet.mm b/platform/darwin/src/MGLTileSet.mm
deleted file mode 100644
index 6afc6c19af..0000000000
--- a/platform/darwin/src/MGLTileSet.mm
+++ /dev/null
@@ -1,101 +0,0 @@
-#import "MGLTileSet.h"
-
-#import "MGLAttributionInfo.h"
-
-#include <mbgl/util/tileset.hpp>
-
-@implementation MGLTileSet
-
-- (instancetype)initWithTileURLTemplates:(NS_ARRAY_OF(NSString *) *)tileURLTemplates
-{
- if (self = [super init])
- {
- _tileURLTemplates = tileURLTemplates;
- }
- return self;
-}
-
-- (instancetype)initWithTileURLTemplates:(NS_ARRAY_OF(NSString *) *)tileURLTemplates minimumZoomLevel:(NSUInteger)minimumZoomLevel maximumZoomLevel:(NSUInteger)maximumZoomLevel
-{
- if (minimumZoomLevel > maximumZoomLevel)
- {
- [[NSException exceptionWithName:@"Invalid minimumZoomLevel"
- reason:@"minimumZoomLevel must be less than maximumZoomLevel"
- userInfo:nil] raise];
- return nil;
- }
-
- if (self = [super init])
- {
- _tileURLTemplates = tileURLTemplates;
- _minimumZoomLevel = @(minimumZoomLevel);
- _maximumZoomLevel = @(maximumZoomLevel);
- }
- return self;
-}
-
-- (void)setMinimumZoomLevel:(NSNumber *)minimumZoomLevel
-{
- if (self.maximumZoomLevel && [minimumZoomLevel integerValue] > [self.maximumZoomLevel integerValue])
- {
- [[NSException exceptionWithName:@"Invalid minimumZoomLevel"
- reason:@"minimumZoomLevel must be less than maximumZoomLevel"
- userInfo:nil] raise];
- return;
- }
-
- _minimumZoomLevel = minimumZoomLevel;
-}
-
-- (void)setMaximumZoomLevel:(NSNumber *)maximumZoomLevel
-{
- if (self.maximumZoomLevel && [maximumZoomLevel integerValue] < [self.maximumZoomLevel integerValue])
- {
- [[NSException exceptionWithName:@"Invalid minimumZoomLevel"
- reason:@"minimumZoomLevel must be less than maximumZoomLevel"
- userInfo:nil] raise];
- }
-
- _maximumZoomLevel = maximumZoomLevel;
-}
-
-- (nullable NS_ARRAY_OF(MGLAttributionInfo *) *)attributionInfosWithFontSize:(CGFloat)fontSize linkColor:(nullable MGLColor *)linkColor {
- return [MGLAttributionInfo attributionInfosFromHTMLString:self.attribution
- fontSize:fontSize
- linkColor:linkColor];
-}
-
-- (mbgl::Tileset)mbglTileset
-{
- mbgl::Tileset tileset;
-
- for (NSString *tileURLTemplate in self.tileURLTemplates)
- {
- tileset.tiles.push_back(tileURLTemplate.UTF8String);
- }
-
- // set the minimum / maximum zoom range to the values specified by this class if they
- // were set. otherwise, use the core objects default values
- uint8_t minimumZoomLevel = self.minimumZoomLevel ? [self.minimumZoomLevel unsignedIntegerValue] : tileset.zoomRange.min;
- uint8_t maximumZoomLevel = self.minimumZoomLevel ? [self.maximumZoomLevel unsignedIntegerValue] : tileset.zoomRange.max;
- tileset.zoomRange = mbgl::Range<uint8_t>(minimumZoomLevel, maximumZoomLevel);
-
- if (self.attribution)
- {
- tileset.attribution = self.attribution.UTF8String;
- }
-
- if (self.scheme == MGLTileSetSchemeTMS) {
- tileset.scheme = mbgl::Tileset::Scheme::TMS;
- }
-
- return tileset;
-}
-
-- (NSString *)description
-{
- return [NSString stringWithFormat:@"<%@: %p; tileURLTemplates = %@>",
- NSStringFromClass([self class]), (void *)self, self.tileURLTemplates];
-}
-
-@end
diff --git a/platform/darwin/src/MGLTileSet_Private.h b/platform/darwin/src/MGLTileSet_Private.h
deleted file mode 100644
index 038fe57fa2..0000000000
--- a/platform/darwin/src/MGLTileSet_Private.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#import "MGLTileSet.h"
-
-#include <mbgl/util/tileset.hpp>
-
-NS_ASSUME_NONNULL_BEGIN
-
-@class MGLAttributionInfo;
-
-@interface MGLTileSet (Private)
-
-/**
- A structured representation of the `attribution` property. The default value is
- `nil`.
-
- @param fontSize The default text size in points.
- @param linkColor The default link color.
- */
-- (nullable NS_ARRAY_OF(MGLAttributionInfo *) *)attributionInfosWithFontSize:(CGFloat)fontSize linkColor:(nullable MGLColor *)linkColor;
-
-- (mbgl::Tileset)mbglTileset;
-
-@end
-
-NS_ASSUME_NONNULL_END
diff --git a/platform/darwin/src/MGLTileSource.h b/platform/darwin/src/MGLTileSource.h
new file mode 100644
index 0000000000..caf915637e
--- /dev/null
+++ b/platform/darwin/src/MGLTileSource.h
@@ -0,0 +1,179 @@
+#import <Foundation/Foundation.h>
+
+#import "MGLSource.h"
+#import "MGLTypes.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+@class MGLAttributionInfo;
+
+/**
+ Options for `MGLTileSource` objects.
+ */
+typedef NSString *MGLTileSourceOption NS_STRING_ENUM;
+
+/**
+ An `NSNumber` object containing an unsigned integer that specifies the minimum
+ zoom level at which to display tiles from the source.
+
+ The value should be between 0 and 22, inclusive, and less than
+ `MGLTileSourceOptionMaximumZoomLevel`, if specified. The default value for this
+ option is 0.
+ */
+extern const MGLTileSourceOption MGLTileSourceOptionMinimumZoomLevel;
+
+/**
+ An `NSNumber` object containing an unsigned integer that specifies the maximum
+ zoom level at which to display tiles from the source.
+
+ The value should be between 0 and 22, inclusive, and less than
+ `MGLTileSourceOptionMinimumZoomLevel`, if specified. The default value for this
+ option is 22.
+ */
+extern const MGLTileSourceOption MGLTileSourceOptionMaximumZoomLevel;
+
+#if TARGET_OS_IPHONE
+/**
+ An HTML string defining the buttons to be displayed in an action sheet when the
+ source is part of a map view’s style and the map view’s attribution button is
+ pressed.
+
+ By default, no attribution statements are displayed. If the
+ `MGLTileSourceOptionAttributionInfos` option is specified, this option is
+ ignored.
+ */
+extern const MGLTileSourceOption MGLTileSourceOptionAttributionHTMLString;
+
+/**
+ An array of `MGLAttributionInfo` objects defining the buttons to be displayed
+ in an action sheet when the source is part of a map view’s style and the map
+ view’s attribution button is pressed.
+
+ By default, no attribution statements are displayed.
+ */
+extern const MGLTileSourceOption MGLTileSourceOptionAttributionInfos;
+#else
+/**
+ An HTML string defining the buttons to be displayed in the map view’s
+ attribution view when the source is part of the map view’s style.
+
+ By default, no attribution statements are displayed. If the
+ `MGLTileSourceOptionAttributionInfos` option is specified, this option is
+ ignored.
+ */
+extern const MGLTileSourceOption MGLTileSourceOptionAttributionHTMLString;
+
+/**
+ An array of `MGLAttributionInfo` objects defining the buttons to be displayed
+ in the map view’s attribution view when the source is part of the map view’s
+ style.
+
+ By default, no attribution statements are displayed.
+ */
+extern const MGLTileSourceOption MGLTileSourceOptionAttributionInfos;
+#endif
+
+/**
+ An `NSNumber` object containing an unsigned integer that specifies the tile
+ coordinate system for the source’s tile URLs. The integer corresponds to one of
+ the constants described in `MGLTileCoordinateSystem`.
+
+ The default value for this option is `MGLTileCoordinateSystemXYZ`.
+ */
+extern const MGLTileSourceOption MGLTileSourceOptionTileCoordinateSystem;
+
+/**
+ Tile coordinate systems that determine how tile coordinates in tile URLs are
+ interpreted.
+ */
+typedef NS_ENUM(NSUInteger, MGLTileCoordinateSystem) {
+ /**
+ The origin is at the top-left (northwest), and `y` values increase
+ southwards.
+
+ This tile coordinate system is used by Mapbox and OpenStreetMap tile
+ servers.
+ */
+ MGLTileCoordinateSystemXYZ = 0,
+
+ /**
+ The origin is at the bottom-left (southwest), and `y` values increase
+ northwards.
+
+ This tile coordinate system is used by tile servers that conform to the
+ <a href="http://wiki.osgeo.org/wiki/Tile_Map_Service_Specification">Tile Map Service Specification</a>.
+ */
+ MGLTileCoordinateSystemTMS
+};
+
+/**
+ `MGLTileSource` is a map content source that supplies map tiles to be shown on
+ the map. The location of and metadata about the tiles are defined either by an
+ option dictionary or by an external file that conforms to the
+ <a href="https://github.com/mapbox/tilejson-spec/">TileJSON specification</a>.
+ A tile source is added to an `MGLStyle` object along with one or more
+ `MGLRasterStyleLayer` or `MGLVectorStyleLayer` objects. Use a style layer to
+ control the appearance of content supplied by the tile source.
+
+ Do not create instances of this class directly, and do not create your own
+ subclasses of this class. Instead, create instances of `MGLRasterSource` and
+ `MGLVectorSource`.
+ */
+@interface MGLTileSource : MGLSource
+
+#pragma mark Initializing a Source
+
+- (instancetype)init __attribute__((unavailable("Use -initWithIdentifier:configurationURL: or -initWithIdentifier:tileURLTemplates:options: instead.")));
+- (instancetype)initWithIdentifier:(NSString *)identifier __attribute__((unavailable("Use -initWithIdentifier:configurationURL: or -initWithIdentifier:tileURLTemplates:options: instead.")));
+
+/**
+ Returns a tile source initialized with an identifier and configuration URL.
+
+ After initializing and configuring the source, add it to a map view’s style
+ using the `-[MGLStyle addSource:]` method.
+
+ The URL may be a full HTTP or HTTPS URL or, for tile sets hosted by Mapbox, a
+ Mapbox URL indicating a map identifier (`mapbox://<mapid>`). The URL should
+ point to a JSON file that conforms to the
+ <a href="https://github.com/mapbox/tilejson-spec/">TileJSON specification</a>.
+
+ @param identifier A string that uniquely identifies the source in the style to
+ which it is added.
+ @param configurationURL A URL to a TileJSON configuration file describing the
+ source’s contents and other metadata.
+ @return An initialized tile source.
+ */
+- (instancetype)initWithIdentifier:(NSString *)identifier configurationURL:(NSURL *)configurationURL;
+
+/**
+ Returns a tile source initialized an identifier, tile URL templates, and
+ options.
+
+ After initializing and configuring the source, add it to a map view’s style
+ using the `-[MGLStyle addSource:]` method.
+
+ @param identifier A string that uniquely identifies the source in the style to
+ which it is added.
+ @param tileURLTemplates An array of tile URL template strings.
+ @param options A dictionary containing configuration options. See
+ `MGLTileSourceOption` for available keys and values. Pass in `nil` to use
+ the default values.
+ @return An initialized tile source.
+ */
+- (instancetype)initWithIdentifier:(NSString *)identifier tileURLTemplates:(NS_ARRAY_OF(NSString *) *)tileURLTemplates options:(nullable NS_DICTIONARY_OF(MGLTileSourceOption, id) *)options;
+
+#pragma mark Accessing Attribution Strings
+
+/**
+ An array of `MGLAttributionInfo` objects that define the attribution
+ statements to be displayed when the map is shown to the user.
+
+ By default, this array is empty. If the source is initialized with a
+ configuration URL, this array is also empty until the configuration JSON file
+ is loaded.
+ */
+@property (nonatomic, copy, readonly) NS_ARRAY_OF(MGLAttributionInfo *) *attributionInfos;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/platform/darwin/src/MGLTileSource.mm b/platform/darwin/src/MGLTileSource.mm
new file mode 100644
index 0000000000..522675bc88
--- /dev/null
+++ b/platform/darwin/src/MGLTileSource.mm
@@ -0,0 +1,123 @@
+#import "MGLTileSource_Private.h"
+
+#import "MGLAttributionInfo_Private.h"
+#import "NSString+MGLAdditions.h"
+
+#if TARGET_OS_IPHONE
+ #import <UIKit/UIKit.h>
+#else
+ #import <Cocoa/Cocoa.h>
+#endif
+
+#include <mbgl/util/tileset.hpp>
+
+const MGLTileSourceOption MGLTileSourceOptionMinimumZoomLevel = @"MGLTileSourceOptionMinimumZoomLevel";
+const MGLTileSourceOption MGLTileSourceOptionMaximumZoomLevel = @"MGLTileSourceOptionMaximumZoomLevel";
+const MGLTileSourceOption MGLTileSourceOptionAttributionHTMLString = @"MGLTileSourceOptionAttributionHTMLString";
+const MGLTileSourceOption MGLTileSourceOptionAttributionInfos = @"MGLTileSourceOptionAttributionInfos";
+const MGLTileSourceOption MGLTileSourceOptionTileCoordinateSystem = @"MGLTileSourceOptionTileCoordinateSystem";
+
+@implementation MGLTileSource
+
+- (instancetype)initWithIdentifier:(NSString *)identifier configurationURL:(NSURL *)configurationURL {
+ return [super initWithIdentifier:identifier];
+}
+
+- (instancetype)initWithIdentifier:(NSString *)identifier tileURLTemplates:(NS_ARRAY_OF(NSString *) *)tileURLTemplates options:(NS_DICTIONARY_OF(MGLTileSourceOption, id) *)options {
+ return [super initWithIdentifier:identifier];
+}
+
+- (NS_ARRAY_OF(MGLAttributionInfo *) *)attributionInfos {
+ return [self attributionInfosWithFontSize:0 linkColor:nil];
+}
+
+- (NS_ARRAY_OF(MGLAttributionInfo *) *)attributionInfosWithFontSize:(CGFloat)fontSize linkColor:(nullable MGLColor *)linkColor {
+ return [MGLAttributionInfo attributionInfosFromHTMLString:self.attributionHTMLString
+ fontSize:fontSize
+ linkColor:linkColor];
+}
+
+- (NSString *)attributionHTMLString {
+ [NSException raise:@"MGLAbstractClassException"
+ format:@"MGLTileSource is an abstract class"];
+ return nil;
+}
+
+@end
+
+mbgl::Tileset MGLTileSetFromTileURLTemplates(NS_ARRAY_OF(NSString *) *tileURLTemplates, NS_DICTIONARY_OF(MGLTileSourceOption, id) * _Nullable options) {
+ mbgl::Tileset tileSet;
+
+ for (NSString *tileURLTemplate in tileURLTemplates) {
+ tileSet.tiles.push_back(tileURLTemplate.UTF8String);
+ }
+
+ // set the minimum / maximum zoom range to the values specified by this class if they
+ // were set. otherwise, use the core objects default values
+ if (NSNumber *minimumZoomLevel = options[MGLTileSourceOptionMinimumZoomLevel]) {
+ if (![minimumZoomLevel isKindOfClass:[NSNumber class]]) {
+ [NSException raise:NSInvalidArgumentException
+ format:@"MGLTileSourceOptionMinimumZoomLevel must be set to an NSNumber."];
+ }
+ tileSet.zoomRange.min = minimumZoomLevel.integerValue;
+ }
+ if (NSNumber *maximumZoomLevel = options[MGLTileSourceOptionMaximumZoomLevel]) {
+ if (![maximumZoomLevel isKindOfClass:[NSNumber class]]) {
+ [NSException raise:NSInvalidArgumentException
+ format:@"MGLTileSourceOptionMinimumZoomLevel must be set to an NSNumber."];
+ }
+ tileSet.zoomRange.max = maximumZoomLevel.integerValue;
+ }
+ if (tileSet.zoomRange.min > tileSet.zoomRange.max) {
+ [NSException raise:NSInvalidArgumentException
+ format:@"MGLTileSourceOptionMinimumZoomLevel must be less than MGLTileSourceOptionMaximumZoomLevel."];
+ }
+
+ if (NSString *attribution = options[MGLTileSourceOptionAttributionHTMLString]) {
+ if (![attribution isKindOfClass:[NSString class]]) {
+ [NSException raise:NSInvalidArgumentException
+ format:@"MGLTileSourceOptionAttributionHTMLString must be set to a string."];
+ }
+ tileSet.attribution = attribution.UTF8String;
+ }
+
+ if (NSArray *attributionInfos = options[MGLTileSourceOptionAttributionInfos]) {
+ if (![attributionInfos isKindOfClass:[NSArray class]]) {
+ [NSException raise:NSInvalidArgumentException
+ format:@"MGLTileSourceOptionAttributionInfos must be set to a string."];
+ }
+
+ NSAttributedString *attributedString = [MGLAttributionInfo attributedStringForAttributionInfos:attributionInfos];
+#if TARGET_OS_IPHONE
+ static NSString * const NSExcludedElementsDocumentAttribute = @"ExcludedElements";
+#endif
+ NSDictionary *documentAttributes = @{
+ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType,
+ NSCharacterEncodingDocumentAttribute: @(NSUTF8StringEncoding),
+ // The attribution string is meant to be a simple, inline fragment, not a full-fledged, validating document.
+ NSExcludedElementsDocumentAttribute: @[@"XML", @"DOCTYPE", @"html", @"head", @"meta", @"title", @"style", @"body", @"p"],
+ };
+ NSData *data = [attributedString dataFromRange:attributedString.mgl_wholeRange documentAttributes:documentAttributes error:NULL];
+ NSString *html = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
+ tileSet.attribution = html.UTF8String;
+ }
+
+ if (NSNumber *tileCoordinateSystemNumber = options[MGLTileSourceOptionTileCoordinateSystem]) {
+ if (![tileCoordinateSystemNumber isKindOfClass:[NSValue class]]) {
+ [NSException raise:NSInvalidArgumentException
+ format:@"MGLTileSourceOptionTileCoordinateSystem must be set to an NSValue or NSNumber."];
+ }
+ MGLTileCoordinateSystem tileCoordinateSystem;
+ [tileCoordinateSystemNumber getValue:&tileCoordinateSystem];
+ switch (tileCoordinateSystem) {
+ case MGLTileCoordinateSystemXYZ:
+ tileSet.scheme = mbgl::Tileset::Scheme::XYZ;
+ break;
+ case MGLTileCoordinateSystemTMS:
+ tileSet.scheme = mbgl::Tileset::Scheme::TMS;
+ break;
+ }
+ }
+
+ return tileSet;
+}
diff --git a/platform/darwin/src/MGLTileSource_Private.h b/platform/darwin/src/MGLTileSource_Private.h
new file mode 100644
index 0000000000..ca80e3d960
--- /dev/null
+++ b/platform/darwin/src/MGLTileSource_Private.h
@@ -0,0 +1,36 @@
+#import "MGLTileSource.h"
+
+#import <CoreGraphics/CoreGraphics.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+namespace mbgl {
+ class Tileset;
+}
+
+@class MGLAttributionInfo;
+
+@interface MGLTileSource (Private)
+
+/**
+ An HTML string to be displayed as attribution when the map is shown to a user.
+
+ The default value is `nil`. If the source is initialized with a configuration
+ URL, this property is also `nil` until the configuration JSON file is loaded.
+ */
+@property (nonatomic, copy, nullable, readonly) NSString *attributionHTMLString;
+
+/**
+ A structured representation of the `attribution` property. The default value is
+ `nil`.
+
+ @param fontSize The default text size in points, or 0 to use the default.
+ @param linkColor The default link color, or `nil` to use the default.
+ */
+- (NS_ARRAY_OF(MGLAttributionInfo *) *)attributionInfosWithFontSize:(CGFloat)fontSize linkColor:(nullable MGLColor *)linkColor;
+
+@end
+
+mbgl::Tileset MGLTileSetFromTileURLTemplates(NS_ARRAY_OF(NSString *) *tileURLTemplates, NS_DICTIONARY_OF(MGLTileSourceOption, id) * _Nullable options);
+
+NS_ASSUME_NONNULL_END
diff --git a/platform/darwin/src/MGLVectorSource.h b/platform/darwin/src/MGLVectorSource.h
index 758b4c993f..f91a0cbb23 100644
--- a/platform/darwin/src/MGLVectorSource.h
+++ b/platform/darwin/src/MGLVectorSource.h
@@ -1,80 +1,35 @@
-#import "MGLSource.h"
-#import "MGLTypes.h"
-
-@class MGLTileSet;
+#import "MGLTileSource.h"
NS_ASSUME_NONNULL_BEGIN
/**
`MGLVectorSource` is a map content source that supplies tiled vector data in
<a href="https://www.mapbox.com/vector-tiles/">Mapbox Vector Tile</a> format to
- be shown on the map. The location of and metadata about the vector tiles are
- defined by either an `MGLTileSet` object or an external TileJSON resource. A
- vector source is added to an `MGLStyle` object along with an
- `MGLVectorStyleLayer` object. The vector style layer defines the appearance of
+ be shown on the map. The location of and metadata about the tiles are defined
+ either by an option dictionary or by an external file that conforms to the
+ <a href="https://github.com/mapbox/tilejson-spec/">TileJSON specification</a>.
+ A vector source is added to an `MGLStyle` object along with one or more
+ `MGLVectorStyleLayer` objects. A vector style layer defines the appearance of
any content supplied by the vector source.
+ Each
+ <a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources-vector"><code>vector</code></a>
+ source defined by the style JSON file is represented at runtime by an
+ `MGLVectorSource` object that you can use to initialize new style layers. You
+ can also add and remove sources dynamically using methods such as
+ `-[MGLStyle addSource:]` and `-[MGLStyle sourceWithIdentifier:]`.
+
Within each vector tile, each geometric coordinate must lie between
−1&nbsp;×&nbsp;<var>extent</var> and
(<var>extent</var>&nbsp;×&nbsp;2)&nbsp;−&nbsp;1, inclusive. Any vector style
layer initialized with a vector source must have a non-`nil` value in its
`sourceLayerIdentifier` property.
*/
-@interface MGLVectorSource : MGLSource
-
-#pragma mark Initializing a Source
-
-/**
- Returns a vector source initialized with an identifier and TileJSON URL.
-
- After initializing and configuring the source, add it to a map view’s style
- using the `-[MGLStyle addSource:]` method.
-
- The URL may be a full HTTP or HTTPS URL or, for tile sets hosted by Mapbox, a
- Mapbox URL indicating a map identifier (`mapbox://<mapid>`).
-
- @param identifier A string that uniquely identifies the source in the style to
- which it is added.
- @param url A URL to a TileJSON configuration file describing the source’s
- contents and other metadata.
- @return An initialized vector source.
- */
-- (instancetype)initWithIdentifier:(NSString *)identifier URL:(NSURL *)url NS_DESIGNATED_INITIALIZER;
-
-/**
- Returns a vector source initialized an identifier and tile set.
-
- After initializing and configuring the source, add it to a map view’s style
- using the `-[MGLStyle addSource:]` method.
-
- @param identifier A string that uniquely identifies the source in the style to
- which it is added.
- @param tileSet A tile set describing the source’s contents and other metadata.
- @return An initialized vector source.
- */
-- (instancetype)initWithIdentifier:(NSString *)identifier tileSet:(MGLTileSet *)tileSet NS_DESIGNATED_INITIALIZER;
+@interface MGLVectorSource : MGLTileSource
-#pragma mark Accessing a Source’s Content
+- (instancetype)initWithIdentifier:(NSString *)identifier configurationURL:(NSURL *)configurationURL NS_DESIGNATED_INITIALIZER;
-/**
- A URL to a TileJSON configuration file describing the source’s contents and
- other metadata.
-
- The URL may be a full HTTP or HTTPS URL or, for tile sets hosted by Mapbox, a
- Mapbox URL indicating a map identifier (`mapbox://<mapid>`).
-
- If the receiver was initialized using `-initWithIdentifier:tileSet:`, this
- property is set to `nil`.
- */
-@property (nonatomic, readonly, copy) NSURL *URL;
-
-/**
- A tile set describing the source’s contents and other metadata.
-
- If the receiver was initialized using `-initWithIdentifier:URL:`, this property
- is set to `nil`.
- */
-@property (nonatomic, readonly, nullable) MGLTileSet *tileSet;
+- (instancetype)initWithIdentifier:(NSString *)identifier tileURLTemplates:(NS_ARRAY_OF(NSString *) *)tileURLTemplates options:(nullable NS_DICTIONARY_OF(MGLTileSourceOption, id) *)options NS_DESIGNATED_INITIALIZER;
@end
diff --git a/platform/darwin/src/MGLVectorSource.mm b/platform/darwin/src/MGLVectorSource.mm
index b5ec0b33be..0eea8dd18c 100644
--- a/platform/darwin/src/MGLVectorSource.mm
+++ b/platform/darwin/src/MGLVectorSource.mm
@@ -2,7 +2,7 @@
#import "MGLMapView_Private.h"
#import "MGLSource_Private.h"
-#import "MGLTileSet_Private.h"
+#import "MGLTileSource_Private.h"
#import "NSURL+MGLAdditions.h"
#include <mbgl/style/sources/vector_source.hpp>
@@ -15,62 +15,36 @@
@end
-@implementation MGLVectorSource
-{
+@implementation MGLVectorSource {
std::unique_ptr<mbgl::style::VectorSource> _pendingSource;
}
-- (instancetype)initWithIdentifier:(NSString *)identifier URL:(NSURL *)url
-{
- if (self = [super initWithIdentifier:identifier])
- {
- _URL = url;
- [self commonInit];
+- (instancetype)initWithIdentifier:(NSString *)identifier configurationURL:(NSURL *)configurationURL {
+ if (self = [super initWithIdentifier:identifier configurationURL:configurationURL]) {
+ auto source = std::make_unique<mbgl::style::VectorSource>(identifier.UTF8String,
+ configurationURL.mgl_URLByStandardizingScheme.absoluteString.UTF8String);
+ _pendingSource = std::move(source);
+ self.rawSource = _pendingSource.get();
}
return self;
}
-- (instancetype)initWithIdentifier:(NSString *)identifier tileSet:(MGLTileSet *)tileSet
-{
- if (self = [super initWithIdentifier:identifier])
- {
- _tileSet = tileSet;
- [self commonInit];
+- (instancetype)initWithIdentifier:(NSString *)identifier tileURLTemplates:(NS_ARRAY_OF(NSString *) *)tileURLTemplates options:(nullable NS_DICTIONARY_OF(MGLTileSourceOption, id) *)options {
+ if (self = [super initWithIdentifier:identifier tileURLTemplates:tileURLTemplates options:options]) {
+ mbgl::Tileset tileSet = MGLTileSetFromTileURLTemplates(tileURLTemplates, options);
+
+ auto source = std::make_unique<mbgl::style::VectorSource>(identifier.UTF8String, tileSet);
+ _pendingSource = std::move(source);
+ self.rawSource = _pendingSource.get();
}
return self;
}
- (instancetype)initWithRawSource:(mbgl::style::VectorSource *)rawSource {
- if (self = [super initWithRawSource:rawSource]) {
- if (auto attribution = rawSource->getAttribution()) {
- _tileSet = [[MGLTileSet alloc] initWithTileURLTemplates:@[]];
- _tileSet.attribution = @(attribution->c_str());
- }
- }
- return self;
+ return [super initWithRawSource:rawSource];
}
-- (void)commonInit
-{
- std::unique_ptr<mbgl::style::VectorSource> source;
-
- if (self.URL)
- {
- source = std::make_unique<mbgl::style::VectorSource>(self.identifier.UTF8String,
- self.URL.mgl_URLByStandardizingScheme.absoluteString.UTF8String);
- }
- else
- {
- source = std::make_unique<mbgl::style::VectorSource>(self.identifier.UTF8String,
- self.tileSet.mbglTileset);
- }
-
- _pendingSource = std::move(source);
- self.rawSource = _pendingSource.get();
-}
-
-- (void)addToMapView:(MGLMapView *)mapView
-{
+- (void)addToMapView:(MGLMapView *)mapView {
if (_pendingSource == nullptr) {
[NSException raise:@"MGLRedundantSourceException"
format:@"This instance %@ was already added to %@. Adding the same source instance " \
@@ -80,18 +54,24 @@
mapView.mbglMap->addSource(std::move(_pendingSource));
}
-- (void)removeFromMapView:(MGLMapView *)mapView
-{
+- (void)removeFromMapView:(MGLMapView *)mapView {
auto removedSource = mapView.mbglMap->removeSource(self.identifier.UTF8String);
_pendingSource = std::move(reinterpret_cast<std::unique_ptr<mbgl::style::VectorSource> &>(removedSource));
self.rawSource = _pendingSource.get();
}
-- (NSString *)description
-{
- return [NSString stringWithFormat:@"<%@: %p; identifier = %@; URL = %@; tileSet = %@>",
- NSStringFromClass([self class]), (void *)self, self.identifier, self.URL, self.tileSet];
+- (mbgl::style::VectorSource *)rawSource {
+ return (mbgl::style::VectorSource *)super.rawSource;
+}
+
+- (void)setRawSource:(mbgl::style::VectorSource *)rawSource {
+ super.rawSource = rawSource;
+}
+
+- (NSString *)attributionHTMLString {
+ auto attribution = self.rawSource->getAttribution();
+ return attribution ? @(attribution->c_str()) : nil;
}
@end
diff --git a/platform/darwin/src/MGLVectorSource_Private.h b/platform/darwin/src/MGLVectorSource_Private.h
index ce6bccdbae..12fcd82012 100644
--- a/platform/darwin/src/MGLVectorSource_Private.h
+++ b/platform/darwin/src/MGLVectorSource_Private.h
@@ -1,5 +1,7 @@
#import "MGLVectorSource.h"
+NS_ASSUME_NONNULL_BEGIN
+
namespace mbgl {
namespace style {
class VectorSource;
@@ -11,3 +13,5 @@ namespace mbgl {
- (instancetype)initWithRawSource:(mbgl::style::VectorSource *)rawSource;
@end
+
+NS_ASSUME_NONNULL_END
diff --git a/platform/darwin/src/NSArray+MGLAdditions.h b/platform/darwin/src/NSArray+MGLAdditions.h
index 6871f15486..eb1cfb7c47 100644
--- a/platform/darwin/src/NSArray+MGLAdditions.h
+++ b/platform/darwin/src/NSArray+MGLAdditions.h
@@ -6,4 +6,7 @@
- (std::vector<mbgl::Value>)mgl_vector;
+/** Returns a string resulting from inserting a separator between each attributed string in the array */
+- (NSAttributedString *)mgl_attributedComponentsJoinedByString:(NSString *)separator;
+
@end
diff --git a/platform/darwin/src/NSArray+MGLAdditions.mm b/platform/darwin/src/NSArray+MGLAdditions.mm
index 976eda704f..b2799c46e1 100644
--- a/platform/darwin/src/NSArray+MGLAdditions.mm
+++ b/platform/darwin/src/NSArray+MGLAdditions.mm
@@ -23,4 +23,19 @@
return vector;
}
+- (NSAttributedString *)mgl_attributedComponentsJoinedByString:(NSString *)separator {
+ NSAttributedString *attributedSeparator = [[NSAttributedString alloc] initWithString:separator];
+ NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] init];
+ BOOL isSubsequentItem = NO;
+ for (NSAttributedString *component in self) {
+ NSAssert([component isKindOfClass:[NSAttributedString class]], @"Items in array must be attributed strings.");
+ if (isSubsequentItem) {
+ [attributedString appendAttributedString:attributedSeparator];
+ }
+ isSubsequentItem = YES;
+ [attributedString appendAttributedString:component];
+ }
+ return attributedString;
+}
+
@end
diff --git a/platform/darwin/test/MGLAttributionInfoTests.m b/platform/darwin/test/MGLAttributionInfoTests.m
index 003637bf1b..3cdb7adffb 100644
--- a/platform/darwin/test/MGLAttributionInfoTests.m
+++ b/platform/darwin/test/MGLAttributionInfoTests.m
@@ -1,7 +1,7 @@
#import <Mapbox/Mapbox.h>
#import <XCTest/XCTest.h>
-#import "MGLAttributionInfo.h"
+#import "MGLAttributionInfo_Private.h"
@interface MGLAttributionInfoTests : XCTestCase
diff --git a/platform/darwin/test/MGLFeatureTests.mm b/platform/darwin/test/MGLFeatureTests.mm
index 7f464aaab1..33c146e723 100644
--- a/platform/darwin/test/MGLFeatureTests.mm
+++ b/platform/darwin/test/MGLFeatureTests.mm
@@ -159,7 +159,7 @@
}
- (void)testPointFeatureGeoJSONDictionary {
- MGLPointFeature<MGLFeaturePrivate> *pointFeature = (MGLPointFeature<MGLFeaturePrivate> *)[[MGLPointFeature alloc] init];
+ MGLPointFeature *pointFeature = [[MGLPointFeature alloc] init];
CLLocationCoordinate2D coordinate = { 10, 10 };
pointFeature.coordinate = coordinate;
diff --git a/platform/darwin/test/MGLFilterTests.mm b/platform/darwin/test/MGLFilterTests.mm
index 4b393fd1dc..e688d50583 100644
--- a/platform/darwin/test/MGLFilterTests.mm
+++ b/platform/darwin/test/MGLFilterTests.mm
@@ -18,7 +18,11 @@
NSString *filePath = [[NSBundle bundleForClass:self.class] pathForResource:@"amsterdam" ofType:@"geojson"];
NSURL *url = [NSURL fileURLWithPath:filePath];
NSData *geoJSONData = [NSData dataWithContentsOfURL:url];
- source = [[MGLShapeSource alloc] initWithIdentifier:@"test-source" geoJSONData:geoJSONData options:nil];
+ NSError *error;
+ MGLShape *shape = [MGLShape shapeWithData:geoJSONData encoding:NSUTF8StringEncoding error:&error];
+ XCTAssertNil(error);
+ XCTAssertNotNil(shape);
+ source = [[MGLShapeSource alloc] initWithIdentifier:@"test-source" shape:shape options:nil];
[self.mapView.style addSource:source];
layer = [[MGLLineStyleLayer alloc] initWithIdentifier:@"test-layer" source:source];
}
diff --git a/platform/darwin/test/MGLGeometryTests.mm b/platform/darwin/test/MGLGeometryTests.mm
index b15916e6fa..0ffc27b29e 100644
--- a/platform/darwin/test/MGLGeometryTests.mm
+++ b/platform/darwin/test/MGLGeometryTests.mm
@@ -99,4 +99,49 @@
XCTAssertFalse(MGLCoordinateInCoordinateBounds(kCLLocationCoordinate2DInvalid, wyoming));
}
+- (void)testGeoJSONDeserialization {
+ NSData *data = [@"{\"type\": \"Feature\", \"geometry\": {\"type\": \"Point\", \"coordinates\": [0, 0]}, \"properties\": {}}" dataUsingEncoding:NSUTF8StringEncoding];
+ NSError *error;
+ MGLPointFeature *feature = (MGLPointFeature *)[MGLShape shapeWithData:data encoding:NSUTF8StringEncoding error:&error];
+ XCTAssertNil(error, @"Valid GeoJSON data should produce no error on deserialization.");
+ XCTAssertNotNil(feature, @"Valid GeoJSON data should produce an object on deserialization.");
+ XCTAssertTrue([feature isKindOfClass:[MGLPointFeature class]], @"Valid GeoJSON point feature data should produce an MGLPointFeature.");
+ XCTAssertEqual(feature.attributes.count, 0);
+ XCTAssertEqual(feature.coordinate.latitude, 0);
+ XCTAssertEqual(feature.coordinate.longitude, 0);
+
+ data = [@"{\"type\": \"Feature\", \"feature\": {\"type\": \"Point\", \"coordinates\": [0, 0]}}" dataUsingEncoding:NSUTF8StringEncoding];
+ error = nil;
+ MGLShape *shape = [MGLShape shapeWithData:data encoding:NSUTF8StringEncoding error:&error];
+ XCTAssertNotNil(error, @"Invalid GeoJSON data should produce an error on deserialization.");
+ XCTAssertNil(shape, @"Invalid GeoJSON data should produce no object on deserialization.");
+}
+
+- (void)testGeoJSONSerialization {
+ MGLPointFeature *feature = [[MGLPointFeature alloc] init];
+ feature.identifier = @504;
+ feature.coordinate = CLLocationCoordinate2DMake(29.95, -90.066667);
+
+ NSData *data = [feature geoJSONDataUsingEncoding:NSUTF8StringEncoding];
+ XCTAssertNotNil(data, @"MGLPointFeature should serialize as an UTF-8 string data object.");
+ NSError *error;
+ NSDictionary *serializedGeoJSON = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
+ XCTAssertNil(error, @"Serialized GeoJSON data should be deserializable JSON.");
+ XCTAssertNotNil(serializedGeoJSON, @"Serialized GeoJSON data should be valid JSON.");
+ XCTAssertTrue([serializedGeoJSON isKindOfClass:[NSDictionary class]], @"Serialized GeoJSON data should be a JSON object.");
+ NSDictionary *geoJSON = @{
+ @"type": @"Feature",
+ @"id": @504,
+ @"geometry": @{
+ @"type": @"Point",
+ @"coordinates": @[
+ @(-90.066667),
+ @29.95,
+ ],
+ },
+ @"properties": @{},
+ };
+ XCTAssertEqualObjects(serializedGeoJSON, geoJSON, @"MGLPointFeature should serialize as a GeoJSON point feature.");
+}
+
@end
diff --git a/platform/darwin/test/MGLShapeSourceTests.mm b/platform/darwin/test/MGLShapeSourceTests.mm
index df90ea74d7..efff4b393e 100644
--- a/platform/darwin/test/MGLShapeSourceTests.mm
+++ b/platform/darwin/test/MGLShapeSourceTests.mm
@@ -12,18 +12,15 @@
@implementation MGLShapeSourceTests
-- (void)testMGLShapeSourceWithOptions {
- NSURL *url = [NSURL URLWithString:@"http://www.mapbox.com/source"];
-
+- (void)testGeoJSONOptionsFromDictionary {
NSDictionary *options = @{MGLShapeSourceOptionClustered: @YES,
MGLShapeSourceOptionClusterRadius: @42,
MGLShapeSourceOptionMaximumZoomLevelForClustering: @98,
MGLShapeSourceOptionMaximumZoomLevel: @99,
MGLShapeSourceOptionBuffer: @1976,
MGLShapeSourceOptionSimplificationTolerance: @0.42};
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"source-id" URL:url options:options];
- auto mbglOptions = [source geoJSONOptions];
+ auto mbglOptions = MGLGeoJSONOptionsFromDictionary(options);
XCTAssertTrue(mbglOptions.cluster);
XCTAssertEqual(mbglOptions.clusterRadius, 42);
XCTAssertEqual(mbglOptions.clusterMaxZoom, 98);
@@ -32,7 +29,7 @@
XCTAssertEqual(mbglOptions.tolerance, 0.42);
options = @{MGLShapeSourceOptionClustered: @"number 1"};
- XCTAssertThrows([[MGLShapeSource alloc] initWithIdentifier:@"source-id" URL:url options:options]);
+ XCTAssertThrows(MGLGeoJSONOptionsFromDictionary(options));
}
- (void)testNilShape {
@@ -45,7 +42,11 @@
NSString *geoJSON = @"{\"type\": \"FeatureCollection\",\"features\": [{\"type\": \"Feature\",\"properties\": {},\"geometry\": {\"type\": \"LineString\",\"coordinates\": [[-107.75390625,40.329795743702064],[-104.34814453125,37.64903402157866]]}}]}";
NSData *data = [geoJSON dataUsingEncoding:NSUTF8StringEncoding];
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"source-id" geoJSONData:data options:nil];
+ NSError *error;
+ MGLShape *shape = [MGLShape shapeWithData:data encoding:NSUTF8StringEncoding error:&error];
+ XCTAssertNil(error);
+ XCTAssertNotNil(shape);
+ MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"source-id" shape:shape options:nil];
MGLShapeCollection *collection = (MGLShapeCollection *)source.shape;
XCTAssertNotNil(collection);
@@ -54,18 +55,24 @@
}
- (void)testMGLShapeSourceWithSingleGeometry {
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"geojson"
- geoJSONData:[@"{\"type\": \"Point\", \"coordinates\": [0, 0]}" dataUsingEncoding:NSUTF8StringEncoding]
- options:nil];
+ NSData *data = [@"{\"type\": \"Point\", \"coordinates\": [0, 0]}" dataUsingEncoding:NSUTF8StringEncoding];
+ NSError *error;
+ MGLShape *shape = [MGLShape shapeWithData:data encoding:NSUTF8StringEncoding error:&error];
+ XCTAssertNil(error);
+ XCTAssertNotNil(shape);
+ MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"geojson" shape:shape options:nil];
XCTAssertNotNil(source.shape);
- XCTAssert([source.shape isKindOfClass:[MGLPointFeature class]]);
+ XCTAssert([source.shape isKindOfClass:[MGLPointAnnotation class]]);
}
- (void)testMGLGeoJSONSourceWithSingleFeature {
NSString *geoJSON = @"{\"type\": \"Feature\", \"properties\": {\"color\": \"green\"}, \"geometry\": { \"type\": \"Point\", \"coordinates\": [ -114.06847000122069, 51.050459433092655 ] }}";
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"geojson"
- geoJSONData:[geoJSON dataUsingEncoding:NSUTF8StringEncoding]
- options:nil];
+ NSData *data = [geoJSON dataUsingEncoding:NSUTF8StringEncoding];
+ NSError *error;
+ MGLShape *shape = [MGLShape shapeWithData:data encoding:NSUTF8StringEncoding error:&error];
+ XCTAssertNil(error);
+ XCTAssertNotNil(shape);
+ MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"geojson" shape:shape options:nil];
XCTAssertNotNil(source.shape);
XCTAssert([source.shape isKindOfClass:[MGLPointFeature class]]);
MGLPointFeature *feature = (MGLPointFeature *)source.shape;
@@ -90,7 +97,7 @@
CLLocationCoordinate2DMake(100.0, 1.0),
CLLocationCoordinate2DMake(100.0, 0.0)};
- MGLPolygonFeature<MGLFeaturePrivate> *polygonFeature = (MGLPolygonFeature<MGLFeaturePrivate> *)[MGLPolygonFeature polygonWithCoordinates:coordinates count:5];
+ MGLPolygonFeature *polygonFeature = [MGLPolygonFeature polygonWithCoordinates:coordinates count:5];
polygonFeature.identifier = @"feature-id";
NSString *stringAttribute = @"string";
NSNumber *boolAttribute = [NSNumber numberWithBool:YES];
diff --git a/platform/darwin/test/MGLStyleTests.mm b/platform/darwin/test/MGLStyleTests.mm
index 7abc88eebc..c67497640b 100644
--- a/platform/darwin/test/MGLStyleTests.mm
+++ b/platform/darwin/test/MGLStyleTests.mm
@@ -126,18 +126,18 @@
[self.style addSource:shapeSource];
XCTAssertThrowsSpecificNamed([self.style addSource:shapeSource], NSException, @"MGLRedundantSourceException");
- MGLRasterSource *rasterSource = [[MGLRasterSource alloc] initWithIdentifier:@"rasterSource" URL:[NSURL new] tileSize:42];
+ MGLRasterSource *rasterSource = [[MGLRasterSource alloc] initWithIdentifier:@"rasterSource" configurationURL:[NSURL URLWithString:@".json"] tileSize:42];
[self.style addSource:rasterSource];
XCTAssertThrowsSpecificNamed([self.style addSource:rasterSource], NSException, @"MGLRedundantSourceException");
- MGLVectorSource *vectorSource = [[MGLVectorSource alloc] initWithIdentifier:@"vectorSource" URL:[NSURL new]];
+ MGLVectorSource *vectorSource = [[MGLVectorSource alloc] initWithIdentifier:@"vectorSource" configurationURL:[NSURL URLWithString:@".json"]];
[self.style addSource:vectorSource];
XCTAssertThrowsSpecificNamed([self.style addSource:vectorSource], NSException, @"MGLRedundantSourceException");
}
- (void)testAddingSourcesWithDuplicateIdentifiers {
- MGLVectorSource *source1 = [[MGLVectorSource alloc] initWithIdentifier:@"my-source" URL:[NSURL URLWithString:@"mapbox://mapbox.mapbox-terrain-v2"]];
- MGLVectorSource *source2 = [[MGLVectorSource alloc] initWithIdentifier:@"my-source" URL:[NSURL URLWithString:@"mapbox://mapbox.mapbox-terrain-v2"]];
+ MGLVectorSource *source1 = [[MGLVectorSource alloc] initWithIdentifier:@"my-source" configurationURL:[NSURL URLWithString:@"mapbox://mapbox.mapbox-terrain-v2"]];
+ MGLVectorSource *source2 = [[MGLVectorSource alloc] initWithIdentifier:@"my-source" configurationURL:[NSURL URLWithString:@"mapbox://mapbox.mapbox-terrain-v2"]];
[self.style addSource: source1];
XCTAssertThrowsSpecificNamed([self.style addSource: source2], NSException, @"MGLRedundantSourceIdentifierException");
@@ -173,7 +173,7 @@
- (void)testAddingLayersWithDuplicateIdentifiers {
//Just some source
- MGLVectorSource *source = [[MGLVectorSource alloc] initWithIdentifier:@"my-source" URL:[NSURL URLWithString:@"mapbox://mapbox.mapbox-terrain-v2"]];
+ MGLVectorSource *source = [[MGLVectorSource alloc] initWithIdentifier:@"my-source" configurationURL:[NSURL URLWithString:@"mapbox://mapbox.mapbox-terrain-v2"]];
[self.mapView.style addSource: source];
//Add initial layer
diff --git a/platform/darwin/test/MGLTileSetTests.mm b/platform/darwin/test/MGLTileSetTests.mm
index d77046928c..06901a0e96 100644
--- a/platform/darwin/test/MGLTileSetTests.mm
+++ b/platform/darwin/test/MGLTileSetTests.mm
@@ -1,7 +1,7 @@
#import <XCTest/XCTest.h>
#import <Mapbox/Mapbox.h>
-#import "MGLTileSet_Private.h"
+#import "MGLTileSource_Private.h"
#include <mbgl/util/tileset.hpp>
@@ -11,72 +11,91 @@
@implementation MGLTileSetTests
-- (void)testTileSet {
+- (void)testTileSetFromTileURLTemplates {
// a tile set that provides an mbgl tile set
- MGLTileSet *tileSet = [[MGLTileSet alloc] initWithTileURLTemplates:@[@"tile.1",
- @"tile.2",
- @"tile.3"]];
- mbgl::Tileset mbglTileset = [tileSet mbglTileset];
+ NSArray *tileURLTemplates = @[@"tile.1", @"tile.2", @"tile.3"];
+ mbgl::Tileset tileSet = MGLTileSetFromTileURLTemplates(tileURLTemplates, nil);
// has the correct URL templates
- XCTAssertEqual(mbglTileset.tiles.size(), 3);
- XCTAssertEqual(mbglTileset.tiles[0], "tile.1");
- XCTAssertEqual(mbglTileset.tiles[1], "tile.2");
- XCTAssertEqual(mbglTileset.tiles[2], "tile.3");
+ XCTAssertEqual(tileSet.tiles.size(), 3);
+ XCTAssertEqual(tileSet.tiles[0], "tile.1");
+ XCTAssertEqual(tileSet.tiles[1], "tile.2");
+ XCTAssertEqual(tileSet.tiles[2], "tile.3");
// has the default scheme
- XCTAssertEqual(mbglTileset.scheme, mbgl::Tileset::Scheme::XYZ);
+ XCTAssertEqual(tileSet.scheme, mbgl::Tileset::Scheme::XYZ);
// when the tile set has no min or max zoom level set
- tileSet.minimumZoomLevel = nil;
- tileSet.maximumZoomLevel = nil;
-
// the mbgl object has default values for min and max zoom level
- XCTAssertEqual([tileSet mbglTileset].zoomRange.min, 0);
- XCTAssertEqual([tileSet mbglTileset].zoomRange.max, 22);
+ XCTAssertEqual(tileSet.zoomRange.min, 0);
+ XCTAssertEqual(tileSet.zoomRange.max, 22);
// when the tile set has min and/or max zoom level set
- tileSet.minimumZoomLevel = @(1);
- tileSet.maximumZoomLevel = @(2);
+ tileSet = MGLTileSetFromTileURLTemplates(@[@"tile.1"], @{
+ MGLTileSourceOptionMinimumZoomLevel: @1,
+ MGLTileSourceOptionMaximumZoomLevel: @2,
+ });
// the mbgl object reflects the set values for min and max zoom level
- XCTAssertEqual([tileSet mbglTileset].zoomRange.min, 1);
- XCTAssertEqual([tileSet mbglTileset].zoomRange.max, 2);
+ XCTAssertEqual(tileSet.zoomRange.min, 1);
+ XCTAssertEqual(tileSet.zoomRange.max, 2);
// when the tile set has an attribution
- tileSet.attribution = @"my tileset © ©️🎈";
+ NSString *attribution = @"my tileset © ©️🎈";
+ tileSet = MGLTileSetFromTileURLTemplates(tileURLTemplates, @{
+ MGLTileSourceOptionAttributionHTMLString: attribution,
+ });
// the attribution is reflected by the mbgl tileset
- XCTAssertEqual([tileSet mbglTileset].attribution, tileSet.attribution.UTF8String);
+ XCTAssertEqual(tileSet.attribution, attribution.UTF8String);
+
+ // when the tile set has attribution infos
+ MGLAttributionInfo *mapboxInfo = [[MGLAttributionInfo alloc] initWithTitle:[[NSAttributedString alloc] initWithString:@"Mapbox"]
+ URL:[NSURL URLWithString:@"https://www.mapbox.com/"]];
+ NSAttributedString *gl = [[NSAttributedString alloc] initWithString:@"GL" attributes:@{
+ NSBackgroundColorAttributeName: [MGLColor redColor],
+ }];
+ MGLAttributionInfo *glInfo = [[MGLAttributionInfo alloc] initWithTitle:gl URL:nil];
+ tileSet = MGLTileSetFromTileURLTemplates(tileURLTemplates, @{
+ MGLTileSourceOptionAttributionInfos: @[mapboxInfo, glInfo],
+ });
- // when the scheme is changed
- tileSet.scheme = MGLTileSetSchemeTMS;
+ // the attribution is reflected by the mbgl tileset
+#if TARGET_OS_IPHONE
+ NSString *html = (@"<font style=\"font-family: 'Helvetica'; font-weight: normal; font-style: normal; font-size: 12.00pt\">"
+ @"<a href=\"https://www.mapbox.com/\">Mapbox</a> </font>"
+ @"<font style=\"font-family: 'Helvetica'; font-weight: normal; font-style: normal; font-size: 12.00pt; background-color: #ff0000\">GL</font>\n");
+#else
+ NSString *html = (@"<font face=\"Helvetica\" size=\"3\" style=\"font: 12.0px Helvetica\">"
+ @"<a href=\"https://www.mapbox.com/\">Mapbox</a> </font>"
+ @"<font face=\"Helvetica\" size=\"3\" style=\"font: 12.0px Helvetica; background-color: #ff2600\">GL</font>\n");
+#endif
+ XCTAssertEqualObjects(@(tileSet.attribution.c_str()), html);
+
+ // when the tile coordinate system is changed using an NSNumber
+ tileSet = MGLTileSetFromTileURLTemplates(tileURLTemplates, @{
+ MGLTileSourceOptionTileCoordinateSystem: @(MGLTileCoordinateSystemTMS),
+ });
// the scheme is reflected by the mbgl tileset
- XCTAssertEqual([tileSet mbglTileset].scheme , mbgl::Tileset::Scheme::TMS);
+ XCTAssertEqual(tileSet.scheme, mbgl::Tileset::Scheme::TMS);
- // a tile set that provides an mbgl tile set and minimum and maximum zoom levels
- tileSet = [[MGLTileSet alloc] initWithTileURLTemplates:@[@"tile.1"] minimumZoomLevel:15 maximumZoomLevel:20];
+ // when the tile coordinate system is changed using an NSValue
+ MGLTileCoordinateSystem tms = MGLTileCoordinateSystemTMS;
+ tileSet = MGLTileSetFromTileURLTemplates(tileURLTemplates, @{
+ MGLTileSourceOptionTileCoordinateSystem: [NSValue value:&tms withObjCType:@encode(MGLTileCoordinateSystem)],
+ });
- // the zoom levels are reflected by the mbgl tileset
- XCTAssertEqual([tileSet mbglTileset].zoomRange.min, 15);
- XCTAssertEqual([tileSet mbglTileset].zoomRange.max, 20);
+ // the scheme is reflected by the mbgl tileset
+ XCTAssertEqual(tileSet.scheme, mbgl::Tileset::Scheme::TMS);
}
- (void)testInvalidTileSet {
// a tile set that provides an mbgl tile set and invalid (crossed) minimum and maximum zoom levels throws an exception
- XCTAssertThrowsSpecificNamed([[MGLTileSet alloc] initWithTileURLTemplates:@[@"tile.1"] minimumZoomLevel:10 maximumZoomLevel:9], NSException, @"Invalid minimumZoomLevel");
-
- // a tile set that provides an mbgl tile set
- MGLTileSet *tileSet = [[MGLTileSet alloc] initWithTileURLTemplates:@[@"tile.1"]];
- tileSet.maximumZoomLevel = @(10);
-
- // when the minimum zoom level is set higher than the maximum zoom level
- XCTAssertThrowsSpecificNamed(tileSet.minimumZoomLevel = @(11), NSException, @"Invalid minimumZoomLevel");
-
- // when the maximum zoom level is set lower than the minimum zoom level
- tileSet.minimumZoomLevel = @(5);
- XCTAssertThrowsSpecificNamed(tileSet.maximumZoomLevel = @(4), NSException, @"Invalid minimumZoomLevel");
+ XCTAssertThrowsSpecificNamed(MGLTileSetFromTileURLTemplates(@[@"tile.1"], @{
+ MGLTileSourceOptionMinimumZoomLevel: @10,
+ MGLTileSourceOptionMaximumZoomLevel: @9,
+ }), NSException, NSInvalidArgumentException);
}
@end
diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m
index 7f3799ebdd..3a7f415f1f 100644
--- a/platform/ios/app/MBXViewController.m
+++ b/platform/ios/app/MBXViewController.m
@@ -757,7 +757,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
- (void)styleRasterLayer
{
NSURL *rasterURL = [NSURL URLWithString:@"mapbox://mapbox.satellite"];
- MGLRasterSource *rasterSource = [[MGLRasterSource alloc] initWithIdentifier:@"my-raster-source" URL:rasterURL tileSize:512];
+ MGLRasterSource *rasterSource = [[MGLRasterSource alloc] initWithIdentifier:@"my-raster-source" configurationURL:rasterURL tileSize:512];
[self.mapView.style addSource:rasterSource];
MGLRasterStyleLayer *rasterLayer = [[MGLRasterStyleLayer alloc] initWithIdentifier:@"my-raster-layer" source:rasterSource];
@@ -967,7 +967,8 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
NSString *geoJSON = @"{\"type\": \"Feature\", \"properties\": {\"color\": \"green\"}, \"geometry\": { \"type\": \"Point\", \"coordinates\": [ -114.06847000122069, 51.050459433092655 ] }}";
NSData *data = [geoJSON dataUsingEncoding:NSUTF8StringEncoding];
- MGLShapeSource *pointSource = [[MGLShapeSource alloc] initWithIdentifier:@"leaf-point-source" geoJSONData:data options:nil];
+ MGLShape *shape = [MGLShape shapeWithData:data encoding:NSUTF8StringEncoding error:NULL];
+ MGLShapeSource *pointSource = [[MGLShapeSource alloc] initWithIdentifier:@"leaf-point-source" shape:shape options:nil];
[self.mapView.style addSource:pointSource];
MGLCircleStyleLayer *circleLayer = [[MGLCircleStyleLayer alloc] initWithIdentifier:@"leaf-circle-layer" source:pointSource];
@@ -999,7 +1000,8 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
NSString *geoJSON = @"{\"type\": \"FeatureCollection\",\"features\": [{\"type\": \"Feature\",\"properties\": {},\"geometry\": {\"type\": \"LineString\",\"coordinates\": [[-107.75390625,40.329795743702064],[-104.34814453125,37.64903402157866]]}}]}";
NSData *data = [geoJSON dataUsingEncoding:NSUTF8StringEncoding];
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"mutable-data-source-id" geoJSONData:data options:nil];
+ MGLShape *shape = [MGLShape shapeWithData:data encoding:NSUTF8StringEncoding error:NULL];
+ MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"mutable-data-source-id" shape:shape options:nil];
[self.mapView.style addSource:source];
MGLLineStyleLayer *layer = [[MGLLineStyleLayer alloc] initWithIdentifier:@"mutable-data-layer-id" source:source];
@@ -1008,8 +1010,8 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
NSString *geoJSON = @"{\"type\": \"FeatureCollection\",\"features\": [{\"type\": \"Feature\",\"properties\": {},\"geometry\": {\"type\": \"LineString\",\"coordinates\": [[-107.75390625,40.329795743702064],[-109.34814453125,37.64903402157866]]}}]}";
NSData *data = [geoJSON dataUsingEncoding:NSUTF8StringEncoding];
-
- source.geoJSONData = data;
+ MGLShape *shape = [MGLShape shapeWithData:data encoding:NSUTF8StringEncoding error:NULL];
+ source.shape = shape;
});
}
@@ -1093,7 +1095,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
- (void)styleVectorSource
{
NSURL *url = [[NSURL alloc] initWithString:@"mapbox://mapbox.mapbox-terrain-v2"];
- MGLVectorSource *vectorSource = [[MGLVectorSource alloc] initWithIdentifier:@"style-vector-source-id" URL:url];
+ MGLVectorSource *vectorSource = [[MGLVectorSource alloc] initWithIdentifier:@"style-vector-source-id" configurationURL:url];
[self.mapView.style addSource:vectorSource];
MGLBackgroundStyleLayer *backgroundLayer = [[MGLBackgroundStyleLayer alloc] initWithIdentifier:@"style-vector-background-layer-id"];
@@ -1114,8 +1116,10 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
- (void)styleRasterSource
{
// 3rd party raster source requires NSAppTransportSecurity exception for stamen.com
- MGLTileSet *rasterTileSet = [[MGLTileSet alloc] initWithTileURLTemplates:@[@"http://a.tile.stamen.com/terrain-background/{z}/{x}/{y}.jpg"]];
- MGLRasterSource *rasterSource = [[MGLRasterSource alloc] initWithIdentifier:@"style-raster-source-id" tileSet:rasterTileSet tileSize:256];
+ NSArray *tileURLTemplates = @[@"http://a.tile.stamen.com/terrain-background/{z}/{x}/{y}.jpg"];
+ MGLRasterSource *rasterSource = [[MGLRasterSource alloc] initWithIdentifier:@"style-raster-source-id" tileURLTemplates:tileURLTemplates options:@{
+ MGLTileSourceOptionTileSize: @256,
+ }];
[self.mapView.style addSource:rasterSource];
MGLRasterStyleLayer *rasterLayer = [[MGLRasterStyleLayer alloc] initWithIdentifier:@"style-raster-layer-id" source:rasterSource];
diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj
index 6d778c571a..188492cc9d 100644
--- a/platform/ios/ios.xcodeproj/project.pbxproj
+++ b/platform/ios/ios.xcodeproj/project.pbxproj
@@ -138,12 +138,12 @@
4049C29F1DB6CD6C00B3F799 /* MGLPointCollection.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4049C29C1DB6CD6C00B3F799 /* MGLPointCollection.mm */; };
4049C2A01DB6CD6C00B3F799 /* MGLPointCollection.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4049C29C1DB6CD6C00B3F799 /* MGLPointCollection.mm */; };
4049C2AC1DB6E05500B3F799 /* MGLPointCollection_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 4049C2AB1DB6E05500B3F799 /* MGLPointCollection_Private.h */; };
- 404C26E21D89B877000AA13D /* MGLTileSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 404C26E01D89B877000AA13D /* MGLTileSet.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 404C26E31D89B877000AA13D /* MGLTileSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 404C26E01D89B877000AA13D /* MGLTileSet.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 404C26E41D89B877000AA13D /* MGLTileSet.mm in Sources */ = {isa = PBXBuildFile; fileRef = 404C26E11D89B877000AA13D /* MGLTileSet.mm */; };
- 404C26E51D89B877000AA13D /* MGLTileSet.mm in Sources */ = {isa = PBXBuildFile; fileRef = 404C26E11D89B877000AA13D /* MGLTileSet.mm */; };
- 404C26E71D89C55D000AA13D /* MGLTileSet_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 404C26E61D89C515000AA13D /* MGLTileSet_Private.h */; };
- 404C26E81D89C55D000AA13D /* MGLTileSet_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 404C26E61D89C515000AA13D /* MGLTileSet_Private.h */; };
+ 404C26E21D89B877000AA13D /* MGLTileSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 404C26E01D89B877000AA13D /* MGLTileSource.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ 404C26E31D89B877000AA13D /* MGLTileSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 404C26E01D89B877000AA13D /* MGLTileSource.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ 404C26E41D89B877000AA13D /* MGLTileSource.mm in Sources */ = {isa = PBXBuildFile; fileRef = 404C26E11D89B877000AA13D /* MGLTileSource.mm */; };
+ 404C26E51D89B877000AA13D /* MGLTileSource.mm in Sources */ = {isa = PBXBuildFile; fileRef = 404C26E11D89B877000AA13D /* MGLTileSource.mm */; };
+ 404C26E71D89C55D000AA13D /* MGLTileSource_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 404C26E61D89C515000AA13D /* MGLTileSource_Private.h */; };
+ 404C26E81D89C55D000AA13D /* MGLTileSource_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 404C26E61D89C515000AA13D /* MGLTileSource_Private.h */; };
40599F0C1DEE1B7600182B5D /* api_mapbox_staging.der in Resources */ = {isa = PBXBuildFile; fileRef = 40599F001DEE1B2400182B5D /* api_mapbox_staging.der */; };
40599F0D1DEE1B7A00182B5D /* api_mapbox_com-digicert.der in Resources */ = {isa = PBXBuildFile; fileRef = 40599F011DEE1B2400182B5D /* api_mapbox_com-digicert.der */; };
40599F0E1DEE1B7E00182B5D /* api_mapbox_com-geotrust.der in Resources */ = {isa = PBXBuildFile; fileRef = 40599F021DEE1B2400182B5D /* api_mapbox_com-geotrust.der */; };
@@ -172,8 +172,8 @@
7E016D851D9E890300A29A21 /* MGLPolygon+MGLAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E016D821D9E890300A29A21 /* MGLPolygon+MGLAdditions.h */; };
7E016D861D9E890300A29A21 /* MGLPolygon+MGLAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E016D831D9E890300A29A21 /* MGLPolygon+MGLAdditions.m */; };
7E016D871D9E890300A29A21 /* MGLPolygon+MGLAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E016D831D9E890300A29A21 /* MGLPolygon+MGLAdditions.m */; };
- DA00FC8E1D5EEB0D009AABC8 /* MGLAttributionInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = DA00FC8C1D5EEB0D009AABC8 /* MGLAttributionInfo.h */; };
- DA00FC8F1D5EEB0D009AABC8 /* MGLAttributionInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = DA00FC8C1D5EEB0D009AABC8 /* MGLAttributionInfo.h */; };
+ DA00FC8E1D5EEB0D009AABC8 /* MGLAttributionInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = DA00FC8C1D5EEB0D009AABC8 /* MGLAttributionInfo.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ DA00FC8F1D5EEB0D009AABC8 /* MGLAttributionInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = DA00FC8C1D5EEB0D009AABC8 /* MGLAttributionInfo.h */; settings = {ATTRIBUTES = (Public, ); }; };
DA00FC901D5EEB0D009AABC8 /* MGLAttributionInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = DA00FC8D1D5EEB0D009AABC8 /* MGLAttributionInfo.mm */; };
DA00FC911D5EEB0D009AABC8 /* MGLAttributionInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = DA00FC8D1D5EEB0D009AABC8 /* MGLAttributionInfo.mm */; };
DA0CD5901CF56F6A00A5F5A5 /* MGLFeatureTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = DA0CD58F1CF56F6A00A5F5A5 /* MGLFeatureTests.mm */; };
@@ -412,6 +412,12 @@
DAED38651D62D0FC00D7640F /* NSURL+MGLAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = DAED38621D62D0FC00D7640F /* NSURL+MGLAdditions.m */; };
DAED38661D62D0FC00D7640F /* NSURL+MGLAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = DAED38621D62D0FC00D7640F /* NSURL+MGLAdditions.m */; };
DAEDC4341D603417000224FF /* MGLAttributionInfoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DAEDC4331D603417000224FF /* MGLAttributionInfoTests.m */; };
+ DAF0D8101DFE0EA000B28378 /* MGLRasterSource_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = DAF0D80F1DFE0EA000B28378 /* MGLRasterSource_Private.h */; };
+ DAF0D8111DFE0EA000B28378 /* MGLRasterSource_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = DAF0D80F1DFE0EA000B28378 /* MGLRasterSource_Private.h */; };
+ DAF0D8131DFE0EC500B28378 /* MGLVectorSource_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = DAF0D8121DFE0EC500B28378 /* MGLVectorSource_Private.h */; };
+ DAF0D8141DFE0EC500B28378 /* MGLVectorSource_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = DAF0D8121DFE0EC500B28378 /* MGLVectorSource_Private.h */; };
+ DAF0D8181DFE6B2800B28378 /* MGLAttributionInfo_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = DAF0D8171DFE6B2800B28378 /* MGLAttributionInfo_Private.h */; };
+ DAF0D8191DFE6B2800B28378 /* MGLAttributionInfo_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = DAF0D8171DFE6B2800B28378 /* MGLAttributionInfo_Private.h */; };
DD0902A91DB1929D00C5BDCE /* MGLNetworkConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = DD0902A21DB18DE700C5BDCE /* MGLNetworkConfiguration.m */; };
DD0902AA1DB1929D00C5BDCE /* MGLNetworkConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = DD0902A21DB18DE700C5BDCE /* MGLNetworkConfiguration.m */; };
DD0902AB1DB192A800C5BDCE /* MGLNetworkConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = DD0902A41DB18F1B00C5BDCE /* MGLNetworkConfiguration.h */; };
@@ -583,16 +589,15 @@
4049C29B1DB6CD6C00B3F799 /* MGLPointCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLPointCollection.h; sourceTree = "<group>"; };
4049C29C1DB6CD6C00B3F799 /* MGLPointCollection.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLPointCollection.mm; sourceTree = "<group>"; };
4049C2AB1DB6E05500B3F799 /* MGLPointCollection_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLPointCollection_Private.h; sourceTree = "<group>"; };
- 404C26E01D89B877000AA13D /* MGLTileSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLTileSet.h; sourceTree = "<group>"; };
- 404C26E11D89B877000AA13D /* MGLTileSet.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLTileSet.mm; sourceTree = "<group>"; };
- 404C26E61D89C515000AA13D /* MGLTileSet_Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLTileSet_Private.h; sourceTree = "<group>"; };
+ 404C26E01D89B877000AA13D /* MGLTileSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLTileSource.h; sourceTree = "<group>"; };
+ 404C26E11D89B877000AA13D /* MGLTileSource.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLTileSource.mm; sourceTree = "<group>"; };
+ 404C26E61D89C515000AA13D /* MGLTileSource_Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLTileSource_Private.h; sourceTree = "<group>"; };
40599F001DEE1B2400182B5D /* api_mapbox_staging.der */ = {isa = PBXFileReference; lastKnownFileType = file; path = api_mapbox_staging.der; sourceTree = "<group>"; };
40599F011DEE1B2400182B5D /* api_mapbox_com-digicert.der */ = {isa = PBXFileReference; lastKnownFileType = file; path = "api_mapbox_com-digicert.der"; sourceTree = "<group>"; };
40599F021DEE1B2400182B5D /* api_mapbox_com-geotrust.der */ = {isa = PBXFileReference; lastKnownFileType = file; path = "api_mapbox_com-geotrust.der"; sourceTree = "<group>"; };
4085AF081D933DEA00F11B22 /* MGLTileSetTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLTileSetTests.mm; path = ../../darwin/test/MGLTileSetTests.mm; sourceTree = "<group>"; };
408AA8551DAEDA0800022900 /* NSDictionary+MGLAdditions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSDictionary+MGLAdditions.h"; sourceTree = "<group>"; };
408AA8561DAEDA0800022900 /* NSDictionary+MGLAdditions.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = "NSDictionary+MGLAdditions.mm"; sourceTree = "<group>"; };
- 40986FE51DFA2B5C004A7E6E /* MGLShapeCollectionFeature_Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLShapeCollectionFeature_Private.h; sourceTree = "<group>"; };
40CF6DBA1DAC3C1800A4D18B /* MGLShape_Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLShape_Private.h; sourceTree = "<group>"; };
40CFA6501D787579008103BD /* MGLShapeSourceTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLShapeSourceTests.mm; path = ../../darwin/test/MGLShapeSourceTests.mm; sourceTree = "<group>"; };
40EDA1BD1CFE0D4A00D9EA68 /* MGLAnnotationContainerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLAnnotationContainerView.h; sourceTree = "<group>"; };
@@ -784,6 +789,9 @@
DAED38611D62D0FC00D7640F /* NSURL+MGLAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSURL+MGLAdditions.h"; sourceTree = "<group>"; };
DAED38621D62D0FC00D7640F /* NSURL+MGLAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSURL+MGLAdditions.m"; sourceTree = "<group>"; };
DAEDC4331D603417000224FF /* MGLAttributionInfoTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MGLAttributionInfoTests.m; path = ../../darwin/test/MGLAttributionInfoTests.m; sourceTree = "<group>"; };
+ DAF0D80F1DFE0EA000B28378 /* MGLRasterSource_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLRasterSource_Private.h; sourceTree = "<group>"; };
+ DAF0D8121DFE0EC500B28378 /* MGLVectorSource_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLVectorSource_Private.h; sourceTree = "<group>"; };
+ DAF0D8171DFE6B2800B28378 /* MGLAttributionInfo_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLAttributionInfo_Private.h; sourceTree = "<group>"; };
DD0902A21DB18DE700C5BDCE /* MGLNetworkConfiguration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLNetworkConfiguration.m; sourceTree = "<group>"; };
DD0902A41DB18F1B00C5BDCE /* MGLNetworkConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLNetworkConfiguration.h; sourceTree = "<group>"; };
DD4823721D94AE6C00EB71B7 /* fill_filter_style.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = fill_filter_style.json; sourceTree = "<group>"; };
@@ -844,19 +852,21 @@
35136D491D4277EA00C20EFD /* Sources */ = {
isa = PBXGroup;
children = (
+ 3566C76A1D4A8DFA008152BC /* MGLRasterSource.h */,
+ DAF0D80F1DFE0EA000B28378 /* MGLRasterSource_Private.h */,
+ 3566C76B1D4A8DFA008152BC /* MGLRasterSource.mm */,
+ 3566C7641D4A77BA008152BC /* MGLShapeSource.h */,
+ 40F8876F1D7A1DB8008ECB67 /* MGLShapeSource_Private.h */,
+ 3566C7651D4A77BA008152BC /* MGLShapeSource.mm */,
35136D4A1D4277FC00C20EFD /* MGLSource.h */,
3566C7701D4A9198008152BC /* MGLSource_Private.h */,
35136D4B1D4277FC00C20EFD /* MGLSource.mm */,
+ 404C26E01D89B877000AA13D /* MGLTileSource.h */,
+ 404C26E61D89C515000AA13D /* MGLTileSource_Private.h */,
+ 404C26E11D89B877000AA13D /* MGLTileSource.mm */,
350098B91D480108004B2AF0 /* MGLVectorSource.h */,
+ DAF0D8121DFE0EC500B28378 /* MGLVectorSource_Private.h */,
350098BA1D480108004B2AF0 /* MGLVectorSource.mm */,
- 3566C7641D4A77BA008152BC /* MGLShapeSource.h */,
- 40F8876F1D7A1DB8008ECB67 /* MGLShapeSource_Private.h */,
- 3566C7651D4A77BA008152BC /* MGLShapeSource.mm */,
- 3566C76A1D4A8DFA008152BC /* MGLRasterSource.h */,
- 3566C76B1D4A8DFA008152BC /* MGLRasterSource.mm */,
- 404C26E01D89B877000AA13D /* MGLTileSet.h */,
- 404C26E61D89C515000AA13D /* MGLTileSet_Private.h */,
- 404C26E11D89B877000AA13D /* MGLTileSet.mm */,
);
name = Sources;
sourceTree = "<group>";
@@ -1119,12 +1129,13 @@
DA8847DF1CBAFA5100AB86E3 /* MGLAccountManager.h */,
DA8847FF1CBAFA6200AB86E3 /* MGLAccountManager_Private.h */,
DA8848001CBAFA6200AB86E3 /* MGLAccountManager.m */,
- DD0902A41DB18F1B00C5BDCE /* MGLNetworkConfiguration.h */,
- DD0902A21DB18DE700C5BDCE /* MGLNetworkConfiguration.m */,
DA00FC8C1D5EEB0D009AABC8 /* MGLAttributionInfo.h */,
+ DAF0D8171DFE6B2800B28378 /* MGLAttributionInfo_Private.h */,
DA00FC8D1D5EEB0D009AABC8 /* MGLAttributionInfo.mm */,
DA8847E21CBAFA5100AB86E3 /* MGLMapCamera.h */,
DA8848031CBAFA6200AB86E3 /* MGLMapCamera.mm */,
+ DD0902A41DB18F1B00C5BDCE /* MGLNetworkConfiguration.h */,
+ DD0902A21DB18DE700C5BDCE /* MGLNetworkConfiguration.m */,
DA8847EC1CBAFA5100AB86E3 /* MGLStyle.h */,
35E0CFE51D3E501500188327 /* MGLStyle_Private.h */,
DA88480F1CBAFA6200AB86E3 /* MGLStyle.mm */,
@@ -1300,13 +1311,12 @@
DA8847E01CBAFA5100AB86E3 /* MGLAnnotation.h */,
DAD165691CF41981001FF4B9 /* MGLFeature.h */,
DAD1656A1CF41981001FF4B9 /* MGLFeature_Private.h */,
- 40986FE51DFA2B5C004A7E6E /* MGLShapeCollectionFeature_Private.h */,
DAD1656B1CF41981001FF4B9 /* MGLFeature.mm */,
DA8847E11CBAFA5100AB86E3 /* MGLGeometry.h */,
DA8848011CBAFA6200AB86E3 /* MGLGeometry_Private.h */,
DA8848021CBAFA6200AB86E3 /* MGLGeometry.mm */,
- DA8848041CBAFA6200AB86E3 /* MGLMultiPoint_Private.h */,
DA8847E31CBAFA5100AB86E3 /* MGLMultiPoint.h */,
+ DA8848041CBAFA6200AB86E3 /* MGLMultiPoint_Private.h */,
DA8848051CBAFA6200AB86E3 /* MGLMultiPoint.mm */,
DA8847E71CBAFA5100AB86E3 /* MGLOverlay.h */,
DA8847E81CBAFA5100AB86E3 /* MGLPointAnnotation.h */,
@@ -1458,6 +1468,7 @@
DA88485A1CBAFB9800AB86E3 /* MGLUserLocation_Private.h in Headers */,
DA27C24F1CBB4C11000B0ECD /* MGLAccountManager_Private.h in Headers */,
DA8847FC1CBAFA5100AB86E3 /* MGLStyle.h in Headers */,
+ DAF0D8131DFE0EC500B28378 /* MGLVectorSource_Private.h in Headers */,
354B83961D2E873E005D9406 /* MGLUserLocationAnnotationView.h in Headers */,
DA8847F01CBAFA5100AB86E3 /* MGLAnnotation.h in Headers */,
7E016D841D9E890300A29A21 /* MGLPolygon+MGLAdditions.h in Headers */,
@@ -1491,6 +1502,7 @@
35CE61821D4165D9004F2359 /* UIColor+MGLAdditions.h in Headers */,
35B82BF81D6C5F8400B1B721 /* NSPredicate+MGLAdditions.h in Headers */,
DA35A29E1CC9E94C00E826B2 /* MGLCoordinateFormatter.h in Headers */,
+ DAF0D8181DFE6B2800B28378 /* MGLAttributionInfo_Private.h in Headers */,
DAAF722B1DA903C700312FA4 /* MGLStyleValue.h in Headers */,
DA8847F71CBAFA5100AB86E3 /* MGLOverlay.h in Headers */,
DA35A2B11CCA141D00E826B2 /* MGLCompassDirectionFormatter.h in Headers */,
@@ -1518,16 +1530,17 @@
DA88481B1CBAFA6200AB86E3 /* MGLGeometry_Private.h in Headers */,
3510FFF91D6DCC4700F413B2 /* NSCompoundPredicate+MGLAdditions.h in Headers */,
DA72620B1DEEE3480043BB89 /* MGLOpenGLStyleLayer.h in Headers */,
- 404C26E71D89C55D000AA13D /* MGLTileSet_Private.h in Headers */,
+ 404C26E71D89C55D000AA13D /* MGLTileSource_Private.h in Headers */,
DA88485C1CBAFB9800AB86E3 /* MGLFaux3DUserLocationAnnotationView.h in Headers */,
DA8848871CBB033F00AB86E3 /* Fabric.h in Headers */,
35305D4A1D22AA6A0007D005 /* NSData+MGLAdditions.h in Headers */,
359F57461D2FDDA6005217F1 /* MGLUserLocationAnnotationView_Private.h in Headers */,
- 404C26E21D89B877000AA13D /* MGLTileSet.h in Headers */,
+ 404C26E21D89B877000AA13D /* MGLTileSource.h in Headers */,
DA8848841CBB033F00AB86E3 /* FABAttributes.h in Headers */,
DA8847FD1CBAFA5100AB86E3 /* MGLTilePyramidOfflineRegion.h in Headers */,
DA88482F1CBAFA6200AB86E3 /* NSProcessInfo+MGLAdditions.h in Headers */,
DA8848601CBAFC2E00AB86E3 /* Mapbox.h in Headers */,
+ DAF0D8101DFE0EA000B28378 /* MGLRasterSource_Private.h in Headers */,
350098BB1D480108004B2AF0 /* MGLVectorSource.h in Headers */,
DA8847F61CBAFA5100AB86E3 /* MGLOfflineStorage.h in Headers */,
DAD1656E1CF41981001FF4B9 /* MGLFeature_Private.h in Headers */,
@@ -1552,7 +1565,7 @@
4049C29E1DB6CD6C00B3F799 /* MGLPointCollection.h in Headers */,
3566C7671D4A77BA008152BC /* MGLShapeSource.h in Headers */,
DA35A29F1CC9E94C00E826B2 /* MGLCoordinateFormatter.h in Headers */,
- 404C26E31D89B877000AA13D /* MGLTileSet.h in Headers */,
+ 404C26E31D89B877000AA13D /* MGLTileSource.h in Headers */,
DABFB8611CBE99E500D62B32 /* MGLMultiPoint.h in Headers */,
3510FFF11D6D9D8C00F413B2 /* NSExpression+MGLAdditions.h in Headers */,
35E0CFE71D3E501500188327 /* MGLStyle_Private.h in Headers */,
@@ -1576,7 +1589,7 @@
DA72620C1DEEE3480043BB89 /* MGLOpenGLStyleLayer.h in Headers */,
35CE61831D4165D9004F2359 /* UIColor+MGLAdditions.h in Headers */,
DABFB8671CBE99E500D62B32 /* MGLPolygon.h in Headers */,
- 404C26E81D89C55D000AA13D /* MGLTileSet_Private.h in Headers */,
+ 404C26E81D89C55D000AA13D /* MGLTileSource_Private.h in Headers */,
DAAF722C1DA903C700312FA4 /* MGLStyleValue.h in Headers */,
DABFB8651CBE99E500D62B32 /* MGLOverlay.h in Headers */,
35E79F211D41266300957B9E /* MGLStyleLayer_Private.h in Headers */,
@@ -1590,8 +1603,10 @@
40F887711D7A1E59008ECB67 /* MGLShapeSource_Private.h in Headers */,
DABFB8631CBE99E500D62B32 /* MGLOfflineRegion.h in Headers */,
DA35A2B21CCA141D00E826B2 /* MGLCompassDirectionFormatter.h in Headers */,
+ DAF0D8141DFE0EC500B28378 /* MGLVectorSource_Private.h in Headers */,
DABFB8731CBE9A9900D62B32 /* Mapbox.h in Headers */,
354B83971D2E873E005D9406 /* MGLUserLocationAnnotationView.h in Headers */,
+ DAF0D8111DFE0EA000B28378 /* MGLRasterSource_Private.h in Headers */,
DABFB86B1CBE99E500D62B32 /* MGLTilePyramidOfflineRegion.h in Headers */,
4018B1CB1CDC288E00F666AF /* MGLAnnotationView.h in Headers */,
DABFB85F1CBE99E500D62B32 /* MGLGeometry.h in Headers */,
@@ -1606,6 +1621,7 @@
DABFB86E1CBE9A0F00D62B32 /* MGLCalloutView.h in Headers */,
DABFB8601CBE99E500D62B32 /* MGLMapCamera.h in Headers */,
DA737EE21D056A4E005BDA16 /* MGLMapViewDelegate.h in Headers */,
+ DAF0D8191DFE6B2800B28378 /* MGLAttributionInfo_Private.h in Headers */,
DABFB86A1CBE99E500D62B32 /* MGLStyle.h in Headers */,
DA00FC8F1D5EEB0D009AABC8 /* MGLAttributionInfo.h in Headers */,
);
@@ -1996,7 +2012,7 @@
DA88481F1CBAFA6200AB86E3 /* MGLMultiPoint.mm in Sources */,
DA88482B1CBAFA6200AB86E3 /* MGLTypes.m in Sources */,
4018B1C71CDC287F00F666AF /* MGLAnnotationView.mm in Sources */,
- 404C26E41D89B877000AA13D /* MGLTileSet.mm in Sources */,
+ 404C26E41D89B877000AA13D /* MGLTileSource.mm in Sources */,
DA88481D1CBAFA6200AB86E3 /* MGLMapCamera.mm in Sources */,
DA8848261CBAFA6200AB86E3 /* MGLPolygon.mm in Sources */,
35B82BFA1D6C5F8400B1B721 /* NSPredicate+MGLAdditions.mm in Sources */,
@@ -2071,7 +2087,7 @@
DAA4E4301CBB730400178DFB /* MGLLocationManager.m in Sources */,
DAA4E4321CBB730400178DFB /* MGLMapView.mm in Sources */,
DAA4E41E1CBB730400178DFB /* MGLMapCamera.mm in Sources */,
- 404C26E51D89B877000AA13D /* MGLTileSet.mm in Sources */,
+ 404C26E51D89B877000AA13D /* MGLTileSource.mm in Sources */,
4018B1C81CDC287F00F666AF /* MGLAnnotationView.mm in Sources */,
DAA4E4341CBB730400178DFB /* MGLFaux3DUserLocationAnnotationView.m in Sources */,
35B82BFB1D6C5F8400B1B721 /* NSPredicate+MGLAdditions.mm in Sources */,
diff --git a/platform/ios/jazzy.yml b/platform/ios/jazzy.yml
index 4b60961c61..0f7e9ccedc 100644
--- a/platform/ios/jazzy.yml
+++ b/platform/ios/jazzy.yml
@@ -63,12 +63,14 @@ custom_categories:
- MGLStyleLayer
- MGLSymbolStyleLayer
- MGLVectorStyleLayer
- - name: Data Sources
+ - name: Content Sources
children:
- - MGLSource
- - MGLShapeSource
+ - MGLAttributionInfo
- MGLRasterSource
- - MGLTileSet
+ - MGLShapeSource
+ - MGLSource
+ - MGLTileCoordinateSystem
+ - MGLTileSource
- MGLVectorSource
- name: Offline Maps
children:
diff --git a/platform/ios/src/Mapbox.h b/platform/ios/src/Mapbox.h
index d401ca020c..69c718ddea 100644
--- a/platform/ios/src/Mapbox.h
+++ b/platform/ios/src/Mapbox.h
@@ -43,6 +43,7 @@ FOUNDATION_EXPORT const unsigned char MapboxVersionString[];
#import "MGLBackgroundStyleLayer.h"
#import "MGLOpenGLStyleLayer.h"
#import "MGLSource.h"
+#import "MGLTileSource.h"
#import "MGLVectorSource.h"
#import "MGLShapeSource.h"
#import "MGLRasterSource.h"
@@ -53,4 +54,4 @@ FOUNDATION_EXPORT const unsigned char MapboxVersionString[];
#import "NSValue+MGLAdditions.h"
#import "NSValue+MGLStyleEnumAttributeAdditions.h"
#import "MGLStyleValue.h"
-#import "MGLTileSet.h"
+#import "MGLAttributionInfo.h"
diff --git a/platform/macos/jazzy.yml b/platform/macos/jazzy.yml
index 079b027ae7..9a7d258f71 100644
--- a/platform/macos/jazzy.yml
+++ b/platform/macos/jazzy.yml
@@ -57,12 +57,14 @@ custom_categories:
- MGLStyleLayer
- MGLSymbolStyleLayer
- MGLVectorStyleLayer
- - name: Data Sources
+ - name: Content Sources
children:
- - MGLSource
- - MGLShapeSource
+ - MGLAttributionInfo
- MGLRasterSource
- - MGLTileSet
+ - MGLShapeSource
+ - MGLSource
+ - MGLTileCoordinateSystem
+ - MGLTileSource
- MGLVectorSource
- name: Offline Maps
children:
diff --git a/platform/macos/macos.xcodeproj/project.pbxproj b/platform/macos/macos.xcodeproj/project.pbxproj
index 4997ed0631..9567efa6eb 100644
--- a/platform/macos/macos.xcodeproj/project.pbxproj
+++ b/platform/macos/macos.xcodeproj/project.pbxproj
@@ -60,7 +60,7 @@
5548BE781D09E718005DDE81 /* libmbgl-core.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DAE6C3451CC31D1200DB3429 /* libmbgl-core.a */; };
558F18221D0B13B100123F46 /* libmbgl-loop.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 558F18211D0B13B000123F46 /* libmbgl-loop.a */; };
55D9B4B11D005D3900C1CCE2 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 55D9B4B01D005D3900C1CCE2 /* libz.tbd */; };
- DA00FC8A1D5EEAC3009AABC8 /* MGLAttributionInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = DA00FC881D5EEAC3009AABC8 /* MGLAttributionInfo.h */; };
+ DA00FC8A1D5EEAC3009AABC8 /* MGLAttributionInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = DA00FC881D5EEAC3009AABC8 /* MGLAttributionInfo.h */; settings = {ATTRIBUTES = (Public, ); }; };
DA00FC8B1D5EEAC3009AABC8 /* MGLAttributionInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = DA00FC891D5EEAC3009AABC8 /* MGLAttributionInfo.mm */; };
DA0CD58E1CF56F5800A5F5A5 /* MGLFeatureTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = DA0CD58D1CF56F5800A5F5A5 /* MGLFeatureTests.mm */; };
DA2207BC1DC076940002F84D /* MGLStyleValueTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA2207BB1DC076940002F84D /* MGLStyleValueTests.swift */; };
@@ -77,9 +77,9 @@
DA35A2C21CCA9F4A00E826B2 /* MGLClockDirectionFormatterTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DA35A2C11CCA9F4A00E826B2 /* MGLClockDirectionFormatterTests.m */; };
DA35A2CF1CCAAED300E826B2 /* NSValue+MGLAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = DA35A2CD1CCAAED300E826B2 /* NSValue+MGLAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
DA35A2D01CCAAED300E826B2 /* NSValue+MGLAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = DA35A2CE1CCAAED300E826B2 /* NSValue+MGLAdditions.m */; };
- DA551B821DB496AC0009AFAF /* MGLTileSet.h in Headers */ = {isa = PBXBuildFile; fileRef = DA551B7F1DB496AC0009AFAF /* MGLTileSet.h */; };
- DA551B831DB496AC0009AFAF /* MGLTileSet_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = DA551B801DB496AC0009AFAF /* MGLTileSet_Private.h */; };
- DA551B841DB496AC0009AFAF /* MGLTileSet.mm in Sources */ = {isa = PBXBuildFile; fileRef = DA551B811DB496AC0009AFAF /* MGLTileSet.mm */; };
+ DA551B821DB496AC0009AFAF /* MGLTileSource.h in Headers */ = {isa = PBXBuildFile; fileRef = DA551B7F1DB496AC0009AFAF /* MGLTileSource.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ DA551B831DB496AC0009AFAF /* MGLTileSource_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = DA551B801DB496AC0009AFAF /* MGLTileSource_Private.h */; };
+ DA551B841DB496AC0009AFAF /* MGLTileSource.mm in Sources */ = {isa = PBXBuildFile; fileRef = DA551B811DB496AC0009AFAF /* MGLTileSource.mm */; };
DA5589771D320C41006B7F64 /* wms.json in Resources */ = {isa = PBXBuildFile; fileRef = DA5589761D320C41006B7F64 /* wms.json */; };
DA6408D71DA4E5DA00908C90 /* MGLVectorStyleLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = DA6408D51DA4E5DA00908C90 /* MGLVectorStyleLayer.h */; settings = {ATTRIBUTES = (Public, ); }; };
DA6408D81DA4E5DA00908C90 /* MGLVectorStyleLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = DA6408D61DA4E5DA00908C90 /* MGLVectorStyleLayer.m */; };
@@ -209,6 +209,8 @@
DAED38601D62CED700D7640F /* NSURL+MGLAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = DAED385E1D62CED700D7640F /* NSURL+MGLAdditions.m */; };
DAEDC4321D6033F1000224FF /* MGLAttributionInfoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DAEDC4311D6033F1000224FF /* MGLAttributionInfoTests.m */; };
DAEDC4371D606291000224FF /* MGLAttributionButtonTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DAEDC4361D606291000224FF /* MGLAttributionButtonTests.m */; };
+ DAF0D80E1DFE0E5D00B28378 /* MGLPointCollection_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = DAF0D80D1DFE0E5D00B28378 /* MGLPointCollection_Private.h */; };
+ DAF0D8161DFE6B1800B28378 /* MGLAttributionInfo_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = DAF0D8151DFE6B1800B28378 /* MGLAttributionInfo_Private.h */; };
DD0902B21DB1AC6400C5BDCE /* MGLNetworkConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = DD0902AF1DB1AC6400C5BDCE /* MGLNetworkConfiguration.m */; };
DD0902B31DB1AC6400C5BDCE /* MGLNetworkConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = DD0902B01DB1AC6400C5BDCE /* MGLNetworkConfiguration.h */; };
DD58A4C91D822C6700E1F038 /* MGLExpressionTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = DD58A4C71D822C6200E1F038 /* MGLExpressionTests.mm */; };
@@ -300,7 +302,6 @@
40B77E431DB11BB0003DA2FE /* NSArray+MGLAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+MGLAdditions.h"; sourceTree = "<group>"; };
40E1601A1DF216E6005EA6D9 /* MGLStyleLayerTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLStyleLayerTests.h; sourceTree = "<group>"; };
40E1601B1DF216E6005EA6D9 /* MGLStyleLayerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLStyleLayerTests.m; sourceTree = "<group>"; };
- 40EA2D951DFF163700103590 /* MGLShapeCollectionFeature_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLShapeCollectionFeature_Private.h; sourceTree = "<group>"; };
52BECB091CC5A26F009CD791 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
5548BE791D0ACBB2005DDE81 /* libmbgl-loop-darwin.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libmbgl-loop-darwin.a"; path = "cmake/Debug/libmbgl-loop-darwin.a"; sourceTree = "<group>"; };
5548BE7B1D0ACBBD005DDE81 /* libmbgl-loop-darwin.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libmbgl-loop-darwin.a"; path = "cmake/Debug/libmbgl-loop-darwin.a"; sourceTree = "<group>"; };
@@ -325,9 +326,9 @@
DA35A2C11CCA9F4A00E826B2 /* MGLClockDirectionFormatterTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MGLClockDirectionFormatterTests.m; path = ../../darwin/test/MGLClockDirectionFormatterTests.m; sourceTree = "<group>"; };
DA35A2CD1CCAAED300E826B2 /* NSValue+MGLAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSValue+MGLAdditions.h"; sourceTree = "<group>"; };
DA35A2CE1CCAAED300E826B2 /* NSValue+MGLAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSValue+MGLAdditions.m"; sourceTree = "<group>"; };
- DA551B7F1DB496AC0009AFAF /* MGLTileSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLTileSet.h; sourceTree = "<group>"; };
- DA551B801DB496AC0009AFAF /* MGLTileSet_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLTileSet_Private.h; sourceTree = "<group>"; };
- DA551B811DB496AC0009AFAF /* MGLTileSet.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLTileSet.mm; sourceTree = "<group>"; };
+ DA551B7F1DB496AC0009AFAF /* MGLTileSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLTileSource.h; sourceTree = "<group>"; };
+ DA551B801DB496AC0009AFAF /* MGLTileSource_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLTileSource_Private.h; sourceTree = "<group>"; };
+ DA551B811DB496AC0009AFAF /* MGLTileSource.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLTileSource.mm; sourceTree = "<group>"; };
DA5589761D320C41006B7F64 /* wms.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = wms.json; sourceTree = "<group>"; };
DA6408D51DA4E5DA00908C90 /* MGLVectorStyleLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLVectorStyleLayer.h; sourceTree = "<group>"; };
DA6408D61DA4E5DA00908C90 /* MGLVectorStyleLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLVectorStyleLayer.m; sourceTree = "<group>"; };
@@ -472,6 +473,8 @@
DAED385E1D62CED700D7640F /* NSURL+MGLAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSURL+MGLAdditions.m"; sourceTree = "<group>"; };
DAEDC4311D6033F1000224FF /* MGLAttributionInfoTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MGLAttributionInfoTests.m; path = ../../darwin/test/MGLAttributionInfoTests.m; sourceTree = "<group>"; };
DAEDC4361D606291000224FF /* MGLAttributionButtonTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLAttributionButtonTests.m; sourceTree = "<group>"; };
+ DAF0D80D1DFE0E5D00B28378 /* MGLPointCollection_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLPointCollection_Private.h; sourceTree = "<group>"; };
+ DAF0D8151DFE6B1800B28378 /* MGLAttributionInfo_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLAttributionInfo_Private.h; sourceTree = "<group>"; };
DD0902AF1DB1AC6400C5BDCE /* MGLNetworkConfiguration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLNetworkConfiguration.m; sourceTree = "<group>"; };
DD0902B01DB1AC6400C5BDCE /* MGLNetworkConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLNetworkConfiguration.h; sourceTree = "<group>"; };
DD58A4C71D822C6200E1F038 /* MGLExpressionTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLExpressionTests.mm; path = ../../darwin/test/MGLExpressionTests.mm; sourceTree = "<group>"; };
@@ -552,21 +555,21 @@
3527427E1D4C242B00A1ECE6 /* Sources */ = {
isa = PBXGroup;
children = (
+ 352742831D4C244700A1ECE6 /* MGLRasterSource.h */,
+ DA7DC9821DED647F0027472F /* MGLRasterSource_Private.h */,
+ 352742841D4C244700A1ECE6 /* MGLRasterSource.mm */,
+ 352742871D4C245800A1ECE6 /* MGLShapeSource.h */,
+ DA87A99B1DC9D8DD00810D09 /* MGLShapeSource_Private.h */,
+ 352742881D4C245800A1ECE6 /* MGLShapeSource.mm */,
3527427F1D4C243B00A1ECE6 /* MGLSource.h */,
DA8F25991D51CAD00010E6B5 /* MGLSource_Private.h */,
352742801D4C243B00A1ECE6 /* MGLSource.mm */,
+ DA551B7F1DB496AC0009AFAF /* MGLTileSource.h */,
+ DA551B801DB496AC0009AFAF /* MGLTileSource_Private.h */,
+ DA551B811DB496AC0009AFAF /* MGLTileSource.mm */,
DA8F25951D51CAC70010E6B5 /* MGLVectorSource.h */,
DA7DC9801DED5F5C0027472F /* MGLVectorSource_Private.h */,
DA8F25961D51CAC70010E6B5 /* MGLVectorSource.mm */,
- 352742871D4C245800A1ECE6 /* MGLShapeSource.h */,
- DA87A99B1DC9D8DD00810D09 /* MGLShapeSource_Private.h */,
- 352742881D4C245800A1ECE6 /* MGLShapeSource.mm */,
- 352742831D4C244700A1ECE6 /* MGLRasterSource.h */,
- DA7DC9821DED647F0027472F /* MGLRasterSource_Private.h */,
- 352742841D4C244700A1ECE6 /* MGLRasterSource.mm */,
- DA551B7F1DB496AC0009AFAF /* MGLTileSet.h */,
- DA551B801DB496AC0009AFAF /* MGLTileSet_Private.h */,
- DA551B811DB496AC0009AFAF /* MGLTileSet.mm */,
);
name = Sources;
sourceTree = "<group>";
@@ -750,12 +753,11 @@
isa = PBXGroup;
children = (
DAE6C34B1CC31E0400DB3429 /* MGLAnnotation.h */,
- DACC22171CF3D4F700D220D9 /* MGLFeature_Private.h */,
DACC22121CF3D3E200D220D9 /* MGLFeature.h */,
- 40EA2D951DFF163700103590 /* MGLShapeCollectionFeature_Private.h */,
+ DACC22171CF3D4F700D220D9 /* MGLFeature_Private.h */,
DACC22131CF3D3E200D220D9 /* MGLFeature.mm */,
- DAE6C36C1CC31E2A00DB3429 /* MGLGeometry_Private.h */,
DAE6C34C1CC31E0400DB3429 /* MGLGeometry.h */,
+ DAE6C36C1CC31E2A00DB3429 /* MGLGeometry_Private.h */,
DAE6C36D1CC31E2A00DB3429 /* MGLGeometry.mm */,
DAE6C34E1CC31E0400DB3429 /* MGLMultiPoint.h */,
DAE6C36F1CC31E2A00DB3429 /* MGLMultiPoint_Private.h */,
@@ -764,13 +766,14 @@
DAE6C3531CC31E0400DB3429 /* MGLPointAnnotation.h */,
DAE6C3761CC31E2A00DB3429 /* MGLPointAnnotation.mm */,
4049C2A11DB6CE7800B3F799 /* MGLPointCollection.h */,
+ DAF0D80D1DFE0E5D00B28378 /* MGLPointCollection_Private.h */,
4049C2A71DB6D09B00B3F799 /* MGLPointCollection.mm */,
DAE6C3541CC31E0400DB3429 /* MGLPolygon.h */,
DAE6C3771CC31E2A00DB3429 /* MGLPolygon.mm */,
DAE6C3551CC31E0400DB3429 /* MGLPolyline.h */,
DAE6C3781CC31E2A00DB3429 /* MGLPolyline.mm */,
- 408AA85A1DAEECF100022900 /* MGLShape_Private.h */,
DAE6C3561CC31E0400DB3429 /* MGLShape.h */,
+ 408AA85A1DAEECF100022900 /* MGLShape_Private.h */,
DAE6C3791CC31E2A00DB3429 /* MGLShape.mm */,
DAD165721CF4CD7A001FF4B9 /* MGLShapeCollection.h */,
DAD165731CF4CD7A001FF4B9 /* MGLShapeCollection.mm */,
@@ -895,12 +898,13 @@
DAE6C34A1CC31E0400DB3429 /* MGLAccountManager.h */,
DAE6C36A1CC31E2A00DB3429 /* MGLAccountManager_Private.h */,
DAE6C36B1CC31E2A00DB3429 /* MGLAccountManager.m */,
- DD0902B01DB1AC6400C5BDCE /* MGLNetworkConfiguration.h */,
- DD0902AF1DB1AC6400C5BDCE /* MGLNetworkConfiguration.m */,
DA00FC881D5EEAC3009AABC8 /* MGLAttributionInfo.h */,
+ DAF0D8151DFE6B1800B28378 /* MGLAttributionInfo_Private.h */,
DA00FC891D5EEAC3009AABC8 /* MGLAttributionInfo.mm */,
DAE6C34D1CC31E0400DB3429 /* MGLMapCamera.h */,
DAE6C36E1CC31E2A00DB3429 /* MGLMapCamera.mm */,
+ DD0902B01DB1AC6400C5BDCE /* MGLNetworkConfiguration.h */,
+ DD0902AF1DB1AC6400C5BDCE /* MGLNetworkConfiguration.m */,
DAE6C3571CC31E0400DB3429 /* MGLStyle.h */,
3537CA731D3F93A600380318 /* MGLStyle_Private.h */,
DAE6C37A1CC31E2A00DB3429 /* MGLStyle.mm */,
@@ -972,6 +976,7 @@
DAE6C35E1CC31E0400DB3429 /* MGLMultiPoint.h in Headers */,
35602BFF1D3EA9B40050646F /* MGLStyleLayer_Private.h in Headers */,
4032C5C51DE1FE930062E8BD /* NSValue+MGLStyleEnumAttributeAdditions.h in Headers */,
+ DAF0D8161DFE6B1800B28378 /* MGLAttributionInfo_Private.h in Headers */,
DAE6C3971CC31E2A00DB3429 /* NSBundle+MGLAdditions.h in Headers */,
DAED385F1D62CED700D7640F /* NSURL+MGLAdditions.h in Headers */,
DAD165741CF4CD7A001FF4B9 /* MGLShapeCollection.h in Headers */,
@@ -990,7 +995,7 @@
4049C2A51DB6CE7F00B3F799 /* MGLPointCollection.h in Headers */,
30E5781B1DAA857E0050F07E /* NSImage+MGLAdditions.h in Headers */,
DAE6C3661CC31E0400DB3429 /* MGLShape.h in Headers */,
- DA551B831DB496AC0009AFAF /* MGLTileSet_Private.h in Headers */,
+ DA551B831DB496AC0009AFAF /* MGLTileSource_Private.h in Headers */,
DA7262071DEEDD460043BB89 /* MGLOpenGLStyleLayer.h in Headers */,
352742811D4C243B00A1ECE6 /* MGLSource.h in Headers */,
DAE6C3C21CC31F4500DB3429 /* Mapbox.h in Headers */,
@@ -1017,7 +1022,7 @@
3538AA231D542685008EC33D /* MGLStyleLayer.h in Headers */,
DAE6C35C1CC31E0400DB3429 /* MGLGeometry.h in Headers */,
DAE6C35A1CC31E0400DB3429 /* MGLAccountManager.h in Headers */,
- DA551B821DB496AC0009AFAF /* MGLTileSet.h in Headers */,
+ DA551B821DB496AC0009AFAF /* MGLTileSource.h in Headers */,
35602C001D3EA9B40050646F /* MGLForegroundStyleLayer.h in Headers */,
DAE6C35D1CC31E0400DB3429 /* MGLMapCamera.h in Headers */,
DAE6C3B41CC31EF300DB3429 /* MGLCompassCell.h in Headers */,
@@ -1026,6 +1031,7 @@
DA8F259A1D51CAD00010E6B5 /* MGLSource_Private.h in Headers */,
DA8F25931D51CA750010E6B5 /* MGLSymbolStyleLayer.h in Headers */,
DAE6C3B91CC31EF300DB3429 /* MGLOpenGLLayer.h in Headers */,
+ DAF0D80E1DFE0E5D00B28378 /* MGLPointCollection_Private.h in Headers */,
35D65C5A1D65AD5500722C23 /* NSDate+MGLAdditions.h in Headers */,
DAE6C3891CC31E2A00DB3429 /* MGLMultiPoint_Private.h in Headers */,
DAE6C3A51CC31E9400DB3429 /* MGLMapView+IBAdditions.h in Headers */,
@@ -1246,7 +1252,7 @@
35602C011D3EA9B40050646F /* MGLForegroundStyleLayer.m in Sources */,
408AA86A1DAEEE5D00022900 /* NSDictionary+MGLAdditions.mm in Sources */,
DA8F25881D51C9E10010E6B5 /* MGLBackgroundStyleLayer.mm in Sources */,
- DA551B841DB496AC0009AFAF /* MGLTileSet.mm in Sources */,
+ DA551B841DB496AC0009AFAF /* MGLTileSource.mm in Sources */,
DAE6C3B81CC31EF300DB3429 /* MGLMapView+IBAdditions.mm in Sources */,
DA35A2D01CCAAED300E826B2 /* NSValue+MGLAdditions.m in Sources */,
3538AA241D542685008EC33D /* MGLStyleLayer.mm in Sources */,
diff --git a/platform/macos/src/Mapbox.h b/platform/macos/src/Mapbox.h
index bb4722a8be..524ff1a93a 100644
--- a/platform/macos/src/Mapbox.h
+++ b/platform/macos/src/Mapbox.h
@@ -41,6 +41,7 @@ FOUNDATION_EXPORT const unsigned char MapboxVersionString[];
#import "MGLBackgroundStyleLayer.h"
#import "MGLOpenGLStyleLayer.h"
#import "MGLSource.h"
+#import "MGLTileSource.h"
#import "MGLVectorSource.h"
#import "MGLShapeSource.h"
#import "MGLRasterSource.h"
@@ -49,3 +50,4 @@ FOUNDATION_EXPORT const unsigned char MapboxVersionString[];
#import "NSValue+MGLAdditions.h"
#import "NSValue+MGLStyleEnumAttributeAdditions.h"
#import "MGLStyleValue.h"
+#import "MGLAttributionInfo.h"