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.

[ios, core] Images used in linePattern are rendered incorrectly. #15472

Closed

Description

@fabian-guerra

According to the lineStyleLayer doc images passed as linePattern should be a factor of 2 width for seamless render.

Passing a 16x16 px image for lower zoom levels and 32x32 px for higher zoom levels renders the image incorrectly.

Steps to reproduce

  1. Add a line style layer.
CLLocationCoordinate2D lineCoordinates[4] = {
        CLLocationCoordinate2DMake(47.6025, -122.3327),
        CLLocationCoordinate2DMake(45.5189, -122.6726),
        CLLocationCoordinate2DMake(37.7790, -122.4177),
        CLLocationCoordinate2DMake(34.0532, -118.2349)
    };
MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"test" shape:nil options:nil];
    MGLPolylineFeature *polylineFeature = [MGLPolylineFeature polylineWithCoordinates:lineCoordinates count:4];
    source.shape = polylineFeature;
    [self.mapView.style addSource:source];
    [self.mapView.style setImage:[UIImage imageNamed:@"lowresolution"] forName:@"lowresolution"];
    [self.mapView.style setImage:[UIImage imageNamed:@"highresolution"] forName:@"highresolution"];
MGLLineStyleLayer *lineStyleLayer = [[MGLLineStyleLayer alloc] initWithIdentifier:@"testterLayer" source:source];
    NSDictionary *stops = @{ @16 : [NSExpression expressionForConstantValue:@"highresolution"] };
    lineStyleLayer.linePattern = [NSExpression mgl_expressionForSteppingExpression:[NSExpression expressionForVariable:@"zoomLevel"]
                                                                    fromExpression:[NSExpression expressionForConstantValue:@"lowresolution"]
                                                                             stops:[NSExpression expressionForConstantValue:stops] ];
    lineStyleLayer.lineCap = [NSExpression expressionForConstantValue:[NSValue valueWithMGLLineCap:MGLLineCapRound]];
    lineStyleLayer.lineJoin = [NSExpression expressionForConstantValue:[NSValue valueWithMGLLineJoin:MGLLineJoinRound]];
    lineStyleLayer.lineWidth = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{ @1: @8, @20: @8 }];
    [self.mapView.style addLayer:lineStyleLayer];

Expected behavior

The image will render correctly
sliced

Actual behavior

This is how is rendered in lower zoom levels.

lowresolution

At higher zoom level.

highresolution

Configuration

Mapbox SDK versions: master
iOS/macOS versions: 12.4
Device/simulator models: Simulator iPhone 8
Xcode version: 10.3

Activity

  1. added
    iOS
    Core
    on Aug 23, 2019
  2. asheemmamoowala commented on Aug 27, 2019

    @asheemmamoowala
    Contributor
  3. karimnaaji commented on Feb 19, 2020

    @karimnaaji
    Contributor

    Some before/after comparisons video in addition to the screenshots from taken from mapbox/mapbox-gl-js#9266.

    Taken from the branch https://github.com/mapbox/mapbox-gl-native/tree/fix-line-pattern in the glfw app, the branch has the potential fix from mapbox/mapbox-gl-js#9266.

    cc @chloekraw

  4. chloekraw commented on Mar 31, 2020

    @chloekraw
    Contributor

    Will be fixed by #16359 -- closing in favour of that ticket!

  5. jaericson commented on Jan 20, 2022

    @jaericson

    @asheemmamoowala @karimnaaji @chloekraw #16359 is linked but was closed as stale. Did a fix for this issue ever make it to the main branch? Thank you!

  6. jaericson commented on Jan 27, 2022

    @jaericson

    @karimnaaji @tobrun @1ec5 @tmpsantos, can you please provide an update as to whether #16359 was ever fixed or not? It's linked but was closed as stale. Thank you!

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

    CorebugiOSruntime styling

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions