mapbox / mapbox/mapbox-maps-ios

lineMetrics is required for lineTrimOffset, but it's not documented

Open
#1,927 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

auto-triaged bug :beetle: docs :scroll:
Dominant language
Swift
Stars
601
Forks
196
PR merge metrics
No merged PRs in 30d

Description

Environment

  • Xcode version: 14.2
  • iOS version: 16.2
  • Devices affected: Simulator (iPhone 14 Pro Max)
  • Maps SDK Version: 10.11.1, and #main( #3257f24 )

Observed behavior and steps to reproduce

lineTrimOffset doesn't work without lineMetrics. IMO it makes sense, but it's not documented.

In LineGradientExample.swift comment lineMetrics = true:

- geoJSONSource.lineMetrics = true // MUST be `true` in order to use `lineGradient` expression
+ // geoJSONSource.lineMetrics = true // MUST be `true` in order to use `lineGradient` expression

Also comment out the lineGradient part:

- lineLayer.lineGradient = .expression(
+ /* lineLayer.lineGradient = .expression( 

If you press Increase time offset the line will disappear and I see the following in the logs:

2023-03-11 19:32:04.835663+0100 Examples[40954:4605738] Failed to create render pipeline: Error Domain=CompilerError Code=2 "Vertex attribute a_packed(2) is missing from the vertex descriptor" UserInfo={NSLocalizedDescription=Vertex attribute a_packed(2) is missing from the vertex descriptor}
2023-03-11 19:32:04.836487+0100 Examples[40954:4605738] Can't create pipeline for `line` shader

image

Expected behavior

a.) document this at lineTrimOffset
b.) throw a nicer error if possible

Notes / preliminary analysis

Doc for lineMetrics:

/// Whether to calculate line distance metrics. This is required for line layers that specify `line-gradient` values.

Doc for lineTrimOffset:
/// The line part between [trim-start, trim-end] will be marked as transparent to make a route vanishing effect. The line trim-off offset is based on the whole line range [0.0, 1.0].

Additional links and references

#2676

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the lineTrimOffset and lineMetrics API documentation and inspect LineGradientExample.swift, especially the comments and line-gradient configuration. Document that lineMetrics is required for lineTrimOffset, and review whether the reported rendering failure can receive a clearer error without expanding the scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, swift
Domain
documentation, mobile
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.