Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Update MGLVectorTileSource for Mapbox Streets v8 compatibility #11867

Closed
5 of 7 tasks
1ec5 opened this issue May 8, 2018 · 6 comments
Closed
5 of 7 tasks

Update MGLVectorTileSource for Mapbox Streets v8 compatibility #11867

1ec5 opened this issue May 8, 2018 · 6 comments
Labels
accessibility Integration with screen readers and other assistive technology archived Archived because of inactivity gl-ios iOS Mapbox Maps SDK for iOS localization Human language support and internationalization macOS Mapbox Maps SDK for macOS refactor

Comments

@1ec5
Copy link
Contributor

1ec5 commented May 8, 2018

MGLVectorTileSource currently hard-codes compatibility with Mapbox Streets source v6 and v7, particularly for the built-in label localization functionality. When v8 comes out, we’ll need to update MGLVectorTileSource to handle this version as well. In addition to rote version bumping, we’ll also have to account for the fact that name_* fields in v8 may be unset if the value would be identical to name or name_en (need to confirm the details). Finally, the VoiceOver accessibility code may need updates to recognize any new or renamed fields in v8.

- (BOOL)isMapboxStreets {
NSURL *url = self.configurationURL;
if (![url.scheme isEqualToString:@"mapbox"]) {
return NO;
}
NSArray *identifiers = [url.host componentsSeparatedByString:@","];
return [identifiers containsObject:@"mapbox.mapbox-streets-v7"] || [identifiers containsObject:@"mapbox.mapbox-streets-v6"];
}

/**
An array of locale codes with dedicated name fields in the Mapbox Streets
source.
https://www.mapbox.com/vector-tiles/mapbox-streets-v7/#overview
*/
static NSArray * const MGLMapboxStreetsLanguages = @[
@"ar", @"de", @"en", @"es", @"fr", @"pt", @"ru", @"zh", @"zh-Hans",
];
/**
Like `MGLMapboxStreetsLanguages`, but deanglicized for use with
`+[NSBundle preferredLocalizationsFromArray:forPreferences:]`.
*/
static NSArray * const MGLMapboxStreetsAlternativeLanguages = @[
@"mul", @"ar", @"de", @"es", @"fr", @"pt", @"ru", @"zh", @"zh-Hans",
];

// Announce the kind of place or POI.
if (attributes[@"type"]) {
// FIXME: Unfortunately, these types aren’t a closed set that can be
// localized, since they’re based on OpenStreetMap tags.
NSString *type = [attributes[@"type"] stringByReplacingOccurrencesOfString:@"_"
withString:@" "];
[facts addObject:type];
}
// Announce the kind of airport, rail station, or mountain based on its
// Maki image name.
else if (attributes[@"maki"]) {
// TODO: Localize Maki image names.
[facts addObject:attributes[@"maki"]];
}

This work is not blocked by v8 launching; in fact, we should have it in place and released ahead of the launch, so that styles using v8 can take advantage of label localization.

/cc @fabian-guerra @friedbunny @nickidlugash

@1ec5 1ec5 added iOS Mapbox Maps SDK for iOS refactor macOS Mapbox Maps SDK for macOS runtime styling localization Human language support and internationalization accessibility Integration with screen readers and other assistive technology and removed runtime styling labels May 8, 2018
@1ec5 1ec5 added this to the ios-v4.1.0 milestone May 16, 2018
@1ec5 1ec5 modified the milestones: ios-v4.1.0, ios-v4.2.0 Jun 20, 2018
@1ec5
Copy link
Contributor Author

1ec5 commented Jul 17, 2018

When v8 comes out, we’ll need to update MGLVectorTileSource to handle this version as well. In addition to rote version bumping, we’ll also have to account for the fact that name_* fields in v8 may be unset if the value would be identical to name or name_en (need to confirm the details).

#12387 uses a coalescing expression to fall back from name_* to name. I think that’ll get us into a good spot for basic Streets source v8 usage. However, it’s also possible that a future style would take advantage of expressions to implement bilingual labels like London (Londres). In that case, we’ll have to be a bit less aggressive in localizing conditional expressions and string-concatenating expressions. But we can worry about that in a second pass, after addressing basic usage.

/cc @lloydsheng

@1ec5
Copy link
Contributor Author

1ec5 commented Aug 2, 2018

#12387 landed. #12387 (comment) describes how to more gracefully handle the case where a layer gets relocalized, which could be important for performance. The remaining work for this issue is tracked in the to-do list above.

@1ec5
Copy link
Contributor Author

1ec5 commented Nov 26, 2018

Here’s a gist where I had made some baby steps. The main task was allowing for multiple languages to be “preferred” on the client side. Hopefully these changes hook into the changes made in #12164.

@friedbunny
Copy link
Contributor

friedbunny commented Dec 7, 2018

Update MGLMapAccessibilityElement.mm with v8 field names

Looking at the Streets-v8 changelog, attributes have been moved around and added, but it doesn’t appear to me that anything will break.

  • elevation_m & elevation_ft are unchanged.
  • road_label has been merged into road, but keeps the same attribute names.

Update: whoops, spoke before I saw these:

- (NSArray<MGLStyleLayer *> *)placeStyleLayers {
NSSet *streetsSourceIdentifiers = [self.mapboxStreetsSources valueForKey:@"identifier"];
NSSet *placeSourceLayerIdentifiers = [NSSet setWithObjects:@"marine_label", @"country_label", @"state_label", @"place_label", @"water_label", @"poi_label", @"rail_station_label", @"mountain_peak_label", nil];
NSPredicate *isPlacePredicate = [NSPredicate predicateWithBlock:^BOOL (MGLVectorStyleLayer * _Nullable layer, NSDictionary<NSString *, id> * _Nullable bindings) {
return [layer isKindOfClass:[MGLVectorStyleLayer class]] && [streetsSourceIdentifiers containsObject:layer.sourceIdentifier] && [placeSourceLayerIdentifiers containsObject:layer.sourceLayerIdentifier];
}];
return [self.layers filteredArrayUsingPredicate:isPlacePredicate];
}
- (NSArray<MGLStyleLayer *> *)roadStyleLayers {
NSSet *streetsSourceIdentifiers = [self.mapboxStreetsSources valueForKey:@"identifier"];
NSPredicate *isPlacePredicate = [NSPredicate predicateWithBlock:^BOOL (MGLVectorStyleLayer * _Nullable layer, NSDictionary<NSString *, id> * _Nullable bindings) {
return [layer isKindOfClass:[MGLVectorStyleLayer class]] && [streetsSourceIdentifiers containsObject:layer.sourceIdentifier] && [layer.sourceLayerIdentifier isEqualToString:@"road_label"];
}];
return [self.layers filteredArrayUsingPredicate:isPlacePredicate];
}

@1ec5
Copy link
Contributor Author

1ec5 commented Dec 18, 2018

#13481 and #13525 have implemented the bulk of the work for this issue. The following task is unfinished, but it seems lower in priority:

Avoid making expressions too complex when relocalizing: #12387 (comment)

@1ec5 1ec5 removed this from the release-iowaska milestone Dec 18, 2018
@friedbunny friedbunny removed their assignment May 28, 2019
@stale stale bot added the archived Archived because of inactivity label May 20, 2020
@stale
Copy link

stale bot commented May 23, 2020

This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

@stale stale bot closed this as completed May 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accessibility Integration with screen readers and other assistive technology archived Archived because of inactivity gl-ios iOS Mapbox Maps SDK for iOS localization Human language support and internationalization macOS Mapbox Maps SDK for macOS refactor
Projects
None yet
Development

No branches or pull requests

3 participants