mapbox / mapbox-directions-swift

Traffic-aware directions and map matching in Swift on iOS, macOS, tvOS, watchOS, and Linux
https://www.mapbox.com/navigation/
ISC License
186 stars 90 forks source link

Add per-waypoint timestamp option for map matching #294

Open 1ec5 opened 6 years ago

1ec5 commented 6 years ago

The Map Maching API has an optional timestamps query parameter. Currently, this library doesn’t offer a way to specify that parameter. Waypoint should have a timestamp property (of type Date). MatchOptions.getter:params should aggregate the timestamps of the waypoints into the timestamps parameter.

In https://github.com/mapbox/MapboxDirections.swift/pull/236#discussion_r172037100, I had suggested relying on CLLocation.timestamp, but it turns out that Waypoint stores coordinates and headings separately, not as part of a location. That should change, though not necessarily as part of fixing this omission.

It isn’t clear to me what should happen when one waypoint has a timestamp and another does not. Maybe this semicolon-delimited list can contain blank entries.

/ref https://github.com/mapbox/mapbox-navigation-android/issues/875#issuecomment-421332368 /cc @frederoni

richjhart commented 6 years ago

What is the priority of this? It may not be realised that this has quite a high impact. For some reason, a lot of Map Matching requests that do not have any timestamps do not return any results. The same request with any random timestamps returns the expected route.

1ec5 commented 6 years ago

First of all, thank you for bringing up this issue in https://github.com/mapbox/mapbox-navigation-android/issues/875#issuecomment-421332368. It appears to have been an oversight. I’ve flagged this issue for the team to triage.

If you need a workaround in the meantime, you can subclass Directions and override the following method to manually add the semicolon-delimited timestamps property according to this documentation.

https://github.com/mapbox/MapboxDirections.swift/blob/83f415007b8ff73c625bcb86054eb5355318fc10/MapboxDirections/MBDirections.swift#L301-L302

frederoni commented 6 years ago

It isn’t clear to me what should happen when one waypoint has a timestamp, and another does not.

There must be as many timestamps as there are request coordinates, each separated by ; It sounds like we should fail hard if the timestamps are inconsistently annotated.