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

Update MGLVectorTileSource for Mapbox Streets v8 compatibility #11867

Closed

Description

@1ec5

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

Activity

  1. added
    iOS
    macOS
    localization
    accessibility
    and removed on May 8, 2018
  2. added this to the milestone on May 16, 2018
  3. modified the milestones: ios-v4.1.0, ios-v4.2.0 on Jun 20, 2018
  4. 1ec5 commented on Jul 17, 2018

    @1ec5
    ContributorAuthor

    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

  5. modified the milestones: ios-v4.2.0, ios-v4.3.0 on Jul 18, 2018
  6. 1ec5 commented on Aug 2, 2018

    @1ec5
    ContributorAuthor

    #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.

  7. removed this from the ios-v4.3.0-espresso milestone on Oct 31, 2018
  8. self-assigned this
    on Nov 7, 2018
  9. 1ec5 commented on Nov 26, 2018

    @1ec5
    ContributorAuthor

    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.

  10. added this to the release-iowaska milestone on Nov 29, 2018
  11. friedbunny commented on Dec 7, 2018

    @friedbunny
    Contributor

    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];
    }

  12. 1ec5 commented on Dec 18, 2018

    @1ec5
    ContributorAuthor

    #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)

  13. removed this from the release-iowaska milestone on Dec 18, 2018
  14. removed their assignment
    on May 28, 2019
  15. added
    archived
    on May 20, 2020
  16. stale commented on May 23, 2020

    @stale

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    accessibilityarchivedgl-iosiOSlocalizationmacOSrefactor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions