Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix traffic congestion rendering issues. #2580

Merged
merged 7 commits into from
Sep 2, 2020

Conversation

MaximAlien
Copy link
Contributor

@MaximAlien MaximAlien commented Aug 31, 2020

Closing #2574.

I've slightly re-worked original implementation. Now there are such methods which allow to add route layers:

addMainRouteLayer(_:source:lineGradient:)
addMainRouteCasingLayer(_:source:lineGradient:below:)
addAlternateRoutesLayer(_:source:below:)
addAlternateRoutesCasingLayer(_:source:below:)

Such methods are used to create line gradient:

routeLineGradient(_:fractionTraveled:)
routeCasingGradient(_:)

In case if route layer was already added route line gradient with congestion segments will be retrieved out of it.
For route casing color is always the same (without congestions), but fading is also added depending on route progress.

Current PR also fixes #2423 and #2512.

@MaximAlien MaximAlien added bug Something isn’t working UI Work related to visual components, Android Auto, Camera, 3D, voice, etc. labels Aug 31, 2020
@MaximAlien MaximAlien self-assigned this Aug 31, 2020
@MaximAlien MaximAlien requested a review from 1ec5 August 31, 2020 17:08

@discardableResult func addAlternateRoutesLayer(_ style: MGLStyle, source: MGLSource, below layer: MGLStyleLayer) -> MGLStyleLayer {
let customAlternateRoutesLayer = navigationMapViewDelegate?.navigationMapView(self,
alternativeRouteStyleLayerWithIdentifier: StyleLayerIdentifier.alternateRoutes,
Copy link
Contributor Author

@MaximAlien MaximAlien Aug 31, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this point we use NavigationMapViewDelegate.navigationMapView(_:alternativeRouteStyleLayerWithIdentifier:source:) and NavigationMapViewDelegate.navigationMapView(_:alternateRouteCasingStyleLayerWithIdentifier:source:). @1ec5, maybe it'd be better to use the same convention here? As I can see alternate is mostly used in NavigationMapView, maybe we should use the same naming in public API method?

Suggested change
alternativeRouteStyleLayerWithIdentifier: StyleLayerIdentifier.alternateRoutes,
alternateRouteStyleLayerWithIdentifier: StyleLayerIdentifier.alternateRoutes,

Copy link
Contributor

@1ec5 1ec5 Sep 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be “alternative” consistently. “Alternate” is easily read as a verb in this context, and it has a slightly different meaning anyways.

@1ec5 1ec5 added this to the v1.0.0 milestone Sep 1, 2020
let mainRouteCasingShape = navigationMapViewDelegate?.navigationMapView(self, shapeFor: [mainRoute]) ?? shape(for: [mainRoute], legIndex: legIndex)
let mainRouteCasingSource = addMainRouteCasingSource(style, shape: mainRouteCasingShape)

let mainRouteLayer = addMainRouteLayer(style, source: allRoutesSource, lineGradient: routeLineGradient(mainRoute, fractionTraveled: 0.0))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new helper methods make this method much easier to follow, thanks!

@MaximAlien MaximAlien merged commit 4aaf88c into master Sep 2, 2020
@MaximAlien MaximAlien deleted the maxim/2574-fix-traffic-congestion branch September 2, 2020 19:21
@MaximAlien MaximAlien linked an issue Sep 2, 2020 that may be closed by this pull request
MaximAlien added a commit that referenced this pull request Sep 3, 2020
Fix traffic congestion rendering issues.

(cherry picked from commit 4aaf88c)
MaximAlien added a commit that referenced this pull request Sep 3, 2020
* Update to MapboxDirections v0.33.2. (#2585)

(cherry picked from commit 6e54f9d)

* Merge pull request #2586 from mapbox/maxim/2584-update-navigation-styles

Update day/night style URLs.

(cherry picked from commit 24c83ea)

* Merge pull request #2580 from mapbox/maxim/2574-fix-traffic-congestion

Fix traffic congestion rendering issues.

(cherry picked from commit 4aaf88c)

* Merge pull request #2581 from mapbox/maxim/2526-make-fade-route-public

Make updateRoute(_:) public.

(cherry picked from commit bfed4ac)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn’t working UI Work related to visual components, Android Auto, Camera, 3D, voice, etc.
Projects
None yet
2 participants