summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Guerra Soto <fabian.guerra@mapbox.com>2017-09-15 17:00:54 -0400
committerGitHub <noreply@github.com>2017-09-15 17:00:54 -0400
commitb2e33a452d2ccc36c5c281d2090182f1395fc1b4 (patch)
tree35b780cc47740833de1ff5590a62b5ac7746aeea
parenta6224abc33f599f0352682c411b3831b896fb97c (diff)
downloadqtlocation-mapboxgl-b2e33a452d2ccc36c5c281d2090182f1395fc1b4.tar.gz
[ios, macos] Deprecate trafficDayStyleURL and trafficNightStyleURL (#9918)
* [ios, macos] Deprecate trafficDayStyleURL and trafficNightStyleURL * [ios, macos] Update changelogs. * [ios, macos] Update trafficDayStyleURL and trafficNightStyleURL tests in MGLStyleTests.
-rw-r--r--platform/darwin/src/MGLStyle.h46
-rw-r--r--platform/darwin/src/MGLStyle.mm31
-rw-r--r--platform/darwin/test/MGLStyleTests.mm5
-rw-r--r--platform/ios/CHANGELOG.md1
-rw-r--r--platform/ios/app/MBXViewController.m5
-rw-r--r--platform/macos/CHANGELOG.md1
-rw-r--r--platform/macos/app/MapDocument.m8
7 files changed, 51 insertions, 46 deletions
diff --git a/platform/darwin/src/MGLStyle.h b/platform/darwin/src/MGLStyle.h
index 8c009d22c6..4bf1f6a4dc 100644
--- a/platform/darwin/src/MGLStyle.h
+++ b/platform/darwin/src/MGLStyle.h
@@ -270,66 +270,38 @@ MGL_EXPORT
+ (NSURL *)satelliteStreetsStyleURLWithVersion:(NSInteger)version;
/**
- Returns the URL to the current version of the
+ Returns the URL to version 2 of the
<a href="https://www.mapbox.com/blog/live-traffic-maps/">Mapbox Traffic Day</a>
style.
- Traffic Day color-codes roads based on live traffic congestion data. Traffic
- data is currently available in
- <a href="https://www.mapbox.com/api-documentation/pages/traffic-countries.html">these select countries</a>.
-
- @warning The return value may change in a future release of the SDK. If you use
- any feature that depends on a specific aspect of a default style – for
- instance, the minimum zoom level that includes roads – use the
- `-trafficDayStyleURLWithVersion:` method instead. Such details may change
- significantly from version to version.
*/
-+ (NSURL *)trafficDayStyleURL;
++ (NSURL *)trafficDayStyleURL __attribute__((deprecated("Create an NSURL object with the string “mapbox://styles/mapbox/traffic-day-v2”.")));
/**
Returns the URL to the given version of the
<a href="https://www.mapbox.com/blog/live-traffic-maps/">Mapbox Traffic Day</a>
style as of publication.
-
- Traffic Day color-codes roads based on live traffic congestion data. Traffic
- data is currently available in
- <a href="https://www.mapbox.com/api-documentation/pages/traffic-countries.html">these select countries</a>.
-
+
@param version A specific version of the style.
*/
-+ (NSURL *)trafficDayStyleURLWithVersion:(NSInteger)version;
++ (NSURL *)trafficDayStyleURLWithVersion:(NSInteger)version __attribute__((deprecated("Create an NSURL object with the string “mapbox://styles/mapbox/traffic-day-v2”.")));;
/**
- Returns the URL to the current version of the
+ Returns the URL to the version 2 of the
<a href="https://www.mapbox.com/blog/live-traffic-maps/">Mapbox Traffic Night</a>
style.
- Traffic Night color-codes roads based on live traffic congestion data and is
- designed to maximize legibility in low-light situations. Traffic data is
- currently available in
- <a href="https://www.mapbox.com/api-documentation/pages/traffic-countries.html">these select countries</a>.
-
- @warning The return value may change in a future release of the SDK. If you use
- any feature that depends on a specific aspect of a default style – for
- instance, the minimum zoom level that includes roads – use the
- `-trafficNightStyleURLWithVersion:` method instead. Such details may change
- significantly from version to version.
*/
-+ (NSURL *)trafficNightStyleURL;
++ (NSURL *)trafficNightStyleURL __attribute__((deprecated("Create an NSURL object with the string “mapbox://styles/mapbox/traffic-night-v2”.")));
/**
- Returns the URL to the given version of the
+ Returns the URL to to the version 2 of the
<a href="https://www.mapbox.com/blog/live-traffic-maps/">Mapbox Traffic Night</a>
style as of publication.
-
- Traffic Night color-codes roads based on live traffic congestion data and is
- designed to maximize legibility in low-light situations. Traffic data is
- currently available in
- <a href="https://www.mapbox.com/api-documentation/pages/traffic-countries.html">these select countries</a>.
-
+
@param version A specific version of the style.
*/
-+ (NSURL *)trafficNightStyleURLWithVersion:(NSInteger)version;
++ (NSURL *)trafficNightStyleURLWithVersion:(NSInteger)version __attribute__((deprecated("Create an NSURL object with the string “mapbox://styles/mapbox/traffic-night-v2”.")));
#pragma mark Accessing Metadata About the Style
diff --git a/platform/darwin/src/MGLStyle.mm b/platform/darwin/src/MGLStyle.mm
index d8aa014341..23e75f211c 100644
--- a/platform/darwin/src/MGLStyle.mm
+++ b/platform/darwin/src/MGLStyle.mm
@@ -106,8 +106,6 @@ MGL_DEFINE_STYLE(light, light)
MGL_DEFINE_STYLE(dark, dark)
MGL_DEFINE_STYLE(satellite, satellite)
MGL_DEFINE_STYLE(satelliteStreets, satellite-streets)
-MGL_DEFINE_STYLE(trafficDay, traffic-day)
-MGL_DEFINE_STYLE(trafficNight, traffic-night)
// Make sure all the styles listed in mbgl::util::default_styles::orderedStyles
// are defined above and also declared in MGLStyle.h.
@@ -134,6 +132,35 @@ static NSURL *MGLStyleURL_emerald;
return MGLStyleURL_emerald;
}
+// Traffic Day is no longer getting new versions as a default style, so the current version is hard-coded here.
+static NSURL *MGLStyleURL_trafficDay;
++ (NSURL *)trafficDayStyleURL {
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ MGLStyleURL_trafficDay = [NSURL URLWithString:@"mapbox://styles/mapbox/traffic-day-v2"];
+ });
+ return MGLStyleURL_trafficDay;
+}
+
++ (NSURL *)trafficDayStyleURLWithVersion:(NSInteger)version {
+ return [NSURL URLWithString:[@"mapbox://styles/mapbox/traffic-day-v" stringByAppendingFormat:@"%li", (long)version]];
+}
+
+// Traffic Night is no longer getting new versions as a default style, so the current version is hard-coded here.
+static NSURL *MGLStyleURL_trafficNight;
++ (NSURL *)trafficNightStyleURL {
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ MGLStyleURL_trafficNight = [NSURL URLWithString:@"mapbox://styles/mapbox/traffic-night-v2"];
+ });
+ return MGLStyleURL_trafficNight;
+}
+
++ (NSURL *)trafficNightStyleURLWithVersion:(NSInteger)version {
+ return [NSURL URLWithString:[@"mapbox://styles/mapbox/traffic-night-v" stringByAppendingFormat:@"%li", (long)version]];
+}
+
+
#pragma mark -
- (instancetype)initWithMapView:(MGLMapView *)mapView {
diff --git a/platform/darwin/test/MGLStyleTests.mm b/platform/darwin/test/MGLStyleTests.mm
index d93483ea6e..0814ceda2d 100644
--- a/platform/darwin/test/MGLStyleTests.mm
+++ b/platform/darwin/test/MGLStyleTests.mm
@@ -99,6 +99,8 @@
@(mbgl::util::default_styles::satelliteStreets.url));
XCTAssertEqualObjects([MGLStyle satelliteStreetsStyleURLWithVersion:99].absoluteString,
@"mapbox://styles/mapbox/satellite-streets-v99");
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
XCTAssertEqualObjects([MGLStyle trafficDayStyleURLWithVersion:mbgl::util::default_styles::trafficDay.currentVersion].absoluteString,
@(mbgl::util::default_styles::trafficDay.url));
XCTAssertEqualObjects([MGLStyle trafficDayStyleURLWithVersion:99].absoluteString,
@@ -107,6 +109,7 @@
@(mbgl::util::default_styles::trafficNight.url));
XCTAssertEqualObjects([MGLStyle trafficNightStyleURLWithVersion:99].absoluteString,
@"mapbox://styles/mapbox/traffic-night-v99");
+#pragma clang diagnostic pop
static_assert(8 == mbgl::util::default_styles::numOrderedStyles,
"MGLStyleTests isn’t testing all the styles in mbgl::util::default_styles.");
@@ -140,7 +143,7 @@
NSString *styleHeader = self.stringWithContentsOfStyleHeader;
NSError *versionedMethodError;
- NSString *versionedMethodExpressionString = @(R"RE(^\+\s*\(NSURL\s*\*\s*\)\s*\w+StyleURLWithVersion\s*:\s*\(\s*NSInteger\s*\)\s*version\s*;)RE");
+ NSString *versionedMethodExpressionString = @(R"RE(^\+\s*\(NSURL\s*\*\s*\)\s*\w+StyleURLWithVersion\s*:\s*\(\s*NSInteger\s*\)\s*version\s*\b)RE");
NSRegularExpression *versionedMethodExpression = [NSRegularExpression regularExpressionWithPattern:versionedMethodExpressionString options:NSRegularExpressionAnchorsMatchLines error:&versionedMethodError];
XCTAssertNil(versionedMethodError, @"Error compiling regular expression to search for versioned methods.");
NSUInteger numVersionedMethodDeclarations = [versionedMethodExpression numberOfMatchesInString:styleHeader options:0 range:NSMakeRange(0, styleHeader.length)];
diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md
index 493870268e..a2c779c8ef 100644
--- a/platform/ios/CHANGELOG.md
+++ b/platform/ios/CHANGELOG.md
@@ -9,6 +9,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT
* Added support for iOS 11 location usage descriptions. ([#9869](https://github.com/mapbox/mapbox-gl-native/pull/9869))
* Fixed an issue where `MGLUserLocation.location` did not follow its documented initialization behavior. This property will now properly return `nil` until the user’s location has been determined. ([#9639](https://github.com/mapbox/mapbox-gl-native/pull/9639))
* `MGLMapView`’s `minimumZoomLevel` and `maximumZoomLevel` properties are now available in Interface Builder’s Attributes inspector. ([#9729](https://github.com/mapbox/mapbox-gl-native/pull/9729))
+* Deprecated `+[MGLStyle trafficDayStyleURL]` and `+[MGLStyle trafficNightStyleURL]` with no replacement method. To use the Traffic Day and Traffic Night styles going forward, we recommend that you use the underlying URL. ([#9918](https://github.com/mapbox/mapbox-gl-native/pull/9918))
## 3.6.2 - August 18, 2017
diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m
index 6d9eafc042..cdfdb4efe1 100644
--- a/platform/ios/app/MBXViewController.m
+++ b/platform/ios/app/MBXViewController.m
@@ -1519,8 +1519,9 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
[MGLStyle darkStyleURL],
[MGLStyle satelliteStyleURL],
[MGLStyle satelliteStreetsStyleURL],
- [MGLStyle trafficDayStyleURL],
- [MGLStyle trafficNightStyleURL],
+ [NSURL URLWithString:@"mapbox://styles/mapbox/traffic-day-v2"],
+ [NSURL URLWithString:@"mapbox://styles/mapbox/traffic-night-v2"],
+
];
NSAssert(styleNames.count == styleURLs.count, @"Style names and URLs don’t match.");
diff --git a/platform/macos/CHANGELOG.md b/platform/macos/CHANGELOG.md
index f32ee96259..299bbd23d6 100644
--- a/platform/macos/CHANGELOG.md
+++ b/platform/macos/CHANGELOG.md
@@ -8,6 +8,7 @@ This version of the Mapbox macOS SDK corresponds to version 3.6.3 of the Mapbox
* Fixed an issue that caused `-[MGLShapeSource featuresMatchingPredicate:]` and `-[MGLVectorSource featuresInSourceLayersWithIdentifiers:predicate:]` to always return an empty array. ([#9784](https://github.com/mapbox/mapbox-gl-native/pull/9784))
* `MGLMapView`’s `minimumZoomLevel` and `maximumZoomLevel` properties are now available in Interface Builder’s Attributes inspector. ([#9729](https://github.com/mapbox/mapbox-gl-native/pull/9729))
* Added a Hungarian localization. ([#9945](https://github.com/mapbox/mapbox-gl-native/pull/9945))
+* Deprecated `+[MGLStyle trafficDayStyleURL]` and `+[MGLStyle trafficNightStyleURL]` with no replacement method. To use the Traffic Day and Traffic Night styles going forward, we recommend that you use the underlying URL. ([#9918](https://github.com/mapbox/mapbox-gl-native/pull/9918))
## 0.5.0
diff --git a/platform/macos/app/MapDocument.m b/platform/macos/app/MapDocument.m
index 1d22295f50..f494c91c18 100644
--- a/platform/macos/app/MapDocument.m
+++ b/platform/macos/app/MapDocument.m
@@ -183,10 +183,10 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio
styleURL = [MGLStyle satelliteStreetsStyleURL];
break;
case 7:
- styleURL = [MGLStyle trafficDayStyleURL];
+ styleURL = [NSURL URLWithString:@"mapbox://styles/mapbox/traffic-day-v2"];
break;
case 8:
- styleURL = [MGLStyle trafficNightStyleURL];
+ styleURL = [NSURL URLWithString:@"mapbox://styles/mapbox/traffic-night-v2"];
break;
default:
NSAssert(NO, @"Cannot set style from control with tag %li", (long)tag);
@@ -760,10 +760,10 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio
state = [styleURL isEqual:[MGLStyle satelliteStreetsStyleURL]];
break;
case 7:
- state = [styleURL isEqual:[MGLStyle trafficDayStyleURL]];
+ state = [styleURL isEqual:[NSURL URLWithString:@"mapbox://styles/mapbox/traffic-day-v2"]];
break;
case 8:
- state = [styleURL isEqual:[MGLStyle trafficNightStyleURL]];
+ state = [styleURL isEqual:[NSURL URLWithString:@"mapbox://styles/mapbox/traffic-night-v2"]];
break;
default:
return NO;