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

Add support for congestion numeric attribute #3325

Merged
merged 9 commits into from Sep 9, 2021
Merged

Conversation

chezzdev
Copy link
Contributor

@chezzdev chezzdev commented Sep 3, 2021

Fixes mapbox/navigation-sdks#892.
Depends on mapbox/mapbox-directions-swift#575.

Based on discussions in the team, it's decided to make congestion numeric usage compatible with regular congestion levels.
For that reason, numeric values are matched to congestion levels using pre-defined ranges and then used as usual.

  • Match numeric values to congestion levels
  • Provide a way to override default ranges
  • Prefer numericCongestionLevel attribute over .congestionLevel one in RouteLeg
  • Use .numericCongestionLevel instead of .congestionLevel in NavigationRouteOptions
  • Tests
  • Docs
  • Switch to released Directions with Add congestion_numeric attribute support mapbox-directions-swift#575 merged

@chezzdev chezzdev requested a review from a team September 3, 2021 23:29
@chezzdev chezzdev self-assigned this Sep 3, 2021
Copy link
Contributor

@bamx23 bamx23 left a comment

Choose a reason for hiding this comment

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

Looks good (with some NITs)

Sources/MapboxCoreNavigation/CongestionLevel.swift Outdated Show resolved Hide resolved
Sources/MapboxCoreNavigation/CongestionLevel.swift Outdated Show resolved Hide resolved
Tests/MapboxCoreNavigationTests/CongestionLevelTests.swift Outdated Show resolved Hide resolved
Comment on lines +13 to +37
precondition(low.lowerBound >= 0, "Congestion level ranges can't include negative values.")
precondition(low.upperBound <= moderate.lowerBound, "Values from the moderate congestion level range can't intersect with or be lower than ones from the low congestion level range.")
precondition(moderate.upperBound <= heavy.lowerBound, "Values from the heavy congestion level range can't intersect with or be lower than ones from the moderate congestion level range.")
precondition(heavy.upperBound <= severe.lowerBound, "Values from the severe congestion level range can't intersect with or be lower than ones from the heavy congestion level range.")
precondition(severe.upperBound <= CongestionRangeSevere.upperBound, "Congestion level ranges can't include values greater than 100.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Will it be correct if there's a gap between subsequent congestion levels? Should we instead verify if low.upperBound == moderate.lowerBound? Otherwise it seems that it will treat those gaps as "unknown" congestion?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure, what would be the use case for the gaps in intervals, but the "unknown" level of congestion for a value that you haven't defined for some reason looks semantically correct.

@chezzdev chezzdev marked this pull request as ready for review September 7, 2021 15:14
@1ec5 1ec5 modified the milestones: v2.1 (RC), v2.0.0 (RC) Sep 8, 2021
@chezzdev chezzdev requested a review from Udumft September 8, 2021 13:19
@chezzdev chezzdev force-pushed the pad-congestion-numeric branch 2 times, most recently from 5305c20 to 585d9ec Compare September 8, 2021 13:34
Copy link
Contributor

@Udumft Udumft left a comment

Choose a reason for hiding this comment

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

LGTM

@Udumft Udumft merged commit 007d562 into main Sep 9, 2021
@Udumft Udumft deleted the pad-congestion-numeric branch September 9, 2021 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants