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

Serialize speed limit annotations #250

Merged
merged 23 commits into from
Dec 26, 2019
Merged

Serialize speed limit annotations #250

merged 23 commits into from
Dec 26, 2019

Conversation

bsudekum
Copy link

This adds a new annotation attribute, segmentMaximumSpeedLimits which represents the maximum speed limit for a segment.

/cc @mapbox/navigation-ios @karenzshea

MapboxDirections/Attributes/MBSpeedLimit.swift Outdated Show resolved Hide resolved
MapboxDirections/Attributes/MBSpeedLimit.swift Outdated Show resolved Hide resolved
MapboxDirections/Attributes/MBSpeedLimit.swift Outdated Show resolved Hide resolved
MapboxDirections/Attributes/MBSpeedLimit.swift Outdated Show resolved Hide resolved
MapboxDirections/Attributes/MBSpeedLimit.swift Outdated Show resolved Hide resolved
MapboxDirections/Attributes/MBSpeedLimit.swift Outdated Show resolved Hide resolved
MapboxDirections/MBRouteLeg.swift Outdated Show resolved Hide resolved
MapboxDirections/MBRouteLeg.swift Outdated Show resolved Hide resolved
@1ec5
Copy link
Contributor

1ec5 commented Apr 16, 2019

The saga continues in #367.

@1ec5 1ec5 added improvement Improvement for an existing feature. ⚠️ DO NOT MERGE labels Aug 7, 2019
@1ec5
Copy link
Contributor

1ec5 commented Aug 7, 2019

I revived this PR because it already had tests and handled Autobahns correctly, unlike #367.

@1ec5 1ec5 changed the title Add segmentMaximumSpeedLimits Serialize speed limit annotations Aug 7, 2019
@1ec5
Copy link
Contributor

1ec5 commented Aug 7, 2019

To do before merging:

Add support for speed limits via maxspeed annotations.
@1ec5 1ec5 mentioned this pull request Aug 7, 2019
@1ec5
Copy link
Contributor

1ec5 commented Aug 20, 2019

The SPM build is failing with:

/Users/distiller/project/Sources/MapboxDirections/Extensions/Measurement.swift:3:11: error: 'Measurement' is only available on OS X 10.12 or newer
extension Measurement where UnitType: UnitSpeed {
          ^

which is weird, because I just merged in #379, which requires macOS 10.12 and above.

@frederoni
Copy link
Contributor

SPM doesn't depend on Xcode, it has its own place to specify supported platforms which I took the liberty of adding to this PR here.

@1ec5
Copy link
Contributor

1ec5 commented Oct 30, 2019

Ideally MapboxDirections.swift would be responsible for cleaning up the model so that the speed limit attributes are readily usable in UI. Unfortunately, it’s a challenge to associate attributes with steps. Currently the navigation SDK associates congestion attributes with steps, but that’s memory intensive and a lot of inconvenient code.

@1ec5 1ec5 self-assigned this Dec 21, 2019
@1ec5
Copy link
Contributor

1ec5 commented Dec 26, 2019

87ee659 introduces a new property, RouteLeg.segmentRangesByStep, that makes it easier to get the elements in the segment* properties that correspond to a given step. That mostly addresses the concerns in #250 (comment). For speed limits, the navigation SDK can now use code like this to efficiently determine the speed limit to display:

let distanceTraveled = legProgress.currentStepProgress.distanceTraveled
let index = legProgress.currentStep.shape!.indexedCoordinateFromStart(distance: distanceTraveled).index
// or: let index = legProgress.currentStep.shape!.closestCoordinate(to: coordinate)!.index
let legProgress = routeProgress.currentLegProgress
let range = legProgress.leg.segmentRangesByStep[legProgress.stepIndex]
let speedUnit = legProgress.currentStep.speedLimitUnit!
let speedLimit = legProgress.leg.segmentMaximumSpeedLimits[range][index].converted(to: speedUnit)
let speedLimitSignStandard = legProgress.currentStep.speedLimitSignStandard

@1ec5 1ec5 merged commit 93a790a into master Dec 26, 2019
@1ec5 1ec5 deleted the maxspeeds branch December 26, 2019 23:27
@1ec5 1ec5 added this to the v1.0 milestone Dec 26, 2019
@1ec5 1ec5 mentioned this pull request Apr 9, 2020
@1ec5 1ec5 modified the milestones: v1.0.0, v0.31.0 (v0.40) Apr 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improvement for an existing feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants