diff --git a/.swiftpm/xcode/xcshareddata/xcschemes/MapboxNavigation.xcscheme b/.swiftpm/xcode/xcshareddata/xcschemes/MapboxNavigation.xcscheme index 730db16d9d4..61a09e03161 100644 --- a/.swiftpm/xcode/xcshareddata/xcschemes/MapboxNavigation.xcscheme +++ b/.swiftpm/xcode/xcshareddata/xcschemes/MapboxNavigation.xcscheme @@ -28,6 +28,16 @@ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES"> + + + + Drive northwest on West 47th Street. Then, in 200 meters, Turn right onto 8th Avenue.", + "announcement": "Drive northwest on West 47th Street. Then, in 200 meters, Turn right onto 8th Avenue.", + "distanceAlongGeometry": 235.775 + }, + { + "ssmlAnnouncement": "Turn right onto 8th Avenue.", + "announcement": "Turn right onto 8th Avenue.", + "distanceAlongGeometry": 61.667 + } + ], + "intersections": [ + { + "entry": [ + true + ], + "bearings": [ + 299 + ], + "duration": 4.925, + "mapbox_streets_v8": { + "class": "street" + }, + "is_urban": true, + "admin_index": 0, + "out": 0, + "weight": 4.925, + "geometry_index": 0, + "location": [ + -73.985023, + 40.759391 + ] + }, + { + "lanes": [ + { + "indications": [ + "straight" + ], + "valid": false, + "active": false + }, + { + "indications": [ + "straight" + ], + "valid_indication": "straight", + "valid": true, + "active": true + } + ], + "mapbox_streets_v8": { + "class": "street" + }, + "location": [ + -73.985137, + 40.759438 + ], + "geometry_index": 1, + "admin_index": 0, + "weight": 2.202, + "is_urban": true, + "traffic_signal": true, + "turn_duration": 0.505, + "turn_weight": 0.2, + "duration": 2.508, + "bearings": [ + 15, + 119, + 298 + ], + "out": 2, + "in": 1, + "entry": [ + false, + false, + true + ] + }, + { + "entry": [ + false, + false, + false, + true + ], + "in": 1, + "bearings": [ + 15, + 118, + 194, + 298 + ], + "duration": 53.434, + "turn_weight": 2, + "turn_duration": 0.002, + "mapbox_streets_v8": { + "class": "street" + }, + "is_urban": true, + "admin_index": 0, + "out": 3, + "weight": 55.432, + "geometry_index": 2, + "location": [ + -73.985207, + 40.759466 + ] + }, + { + "entry": [ + true, + false, + true + ], + "in": 1, + "bearings": [ + 27, + 119, + 299 + ], + "duration": 6.208, + "turn_weight": 0.2, + "turn_duration": 0.005, + "mapbox_streets_v8": { + "class": "street" + }, + "is_urban": true, + "admin_index": 0, + "out": 2, + "weight": 6.403, + "geometry_index": 4, + "location": [ + -73.98706, + 40.760234 + ] + }, + { + "bearings": [ + 31, + 119, + 213, + 299 + ], + "entry": [ + false, + false, + false, + true + ], + "in": 1, + "turn_weight": 2, + "turn_duration": 0.005, + "mapbox_streets_v8": { + "class": "street" + }, + "is_urban": true, + "admin_index": 0, + "out": 3, + "geometry_index": 5, + "location": [ + -73.987346, + 40.760354 + ] + } + ], + "bannerInstructions": [ + { + "primary": { + "components": [ + { + "type": "text", + "text": "8th Avenue" + } + ], + "type": "turn", + "modifier": "right", + "text": "8th Avenue" + }, + "distanceAlongGeometry": 235.775 + } + ], + "speedLimitUnit": "mph", + "maneuver": { + "type": "depart", + "instruction": "Drive northwest on West 47th Street.", + "bearing_after": 299, + "bearing_before": 0, + "location": [ + -73.985023, + 40.759391 + ] + }, + "speedLimitSign": "mutcd", + "name": "West 47th Street", + "weight_typical": 57.449, + "duration_typical": 53.567, + "duration": 69.888, + "distance": 235.775, + "driving_side": "right", + "weight": 73.77, + "mode": "driving", + "geometry": "}dwvlA|~tblC}AbFw@jCoBtGok@bjBoFzPmB`G" + }, + { + "voiceInstructions": [ + { + "ssmlAnnouncement": "In 200 meters, Turn right onto West 50th Street.", + "announcement": "In 200 meters, Turn right onto West 50th Street.", + "distanceAlongGeometry": 226.377 + }, + { + "ssmlAnnouncement": "Turn right onto West 50th Street.", + "announcement": "Turn right onto West 50th Street.", + "distanceAlongGeometry": 71.111 + } + ], + "intersections": [ + { + "mapbox_streets_v8": { + "class": "secondary" + }, + "location": [ + -73.987475, + 40.760409 + ], + "geometry_index": 6, + "admin_index": 0, + "weight": 7.46, + "is_urban": true, + "traffic_signal": true, + "turn_duration": 6.158, + "turn_weight": 6, + "duration": 7.618, + "bearings": [ + 29, + 119, + 208, + 298 + ], + "out": 0, + "in": 1, + "entry": [ + true, + false, + false, + true + ] + }, + { + "lanes": [ + { + "indications": [ + "straight" + ], + "valid": false, + "active": false + }, + { + "indications": [ + "straight" + ], + "valid_indication": "straight", + "valid": true, + "active": true + }, + { + "indications": [ + "straight" + ], + "valid_indication": "straight", + "valid": true, + "active": true + } + ], + "location": [ + -73.987429, + 40.760473 + ], + "geometry_index": 7, + "admin_index": 0, + "weight": 12.633, + "is_urban": true, + "mapbox_streets_v8": { + "class": "secondary" + }, + "turn_duration": 0.012, + "turn_weight": 1, + "duration": 11.645, + "bearings": [ + 29, + 118, + 209, + 298 + ], + "out": 0, + "in": 2, + "entry": [ + true, + false, + false, + false + ] + }, + { + "lanes": [ + { + "indications": [ + "straight" + ], + "valid": false, + "active": false + }, + { + "indications": [ + "straight" + ], + "valid_indication": "straight", + "valid": true, + "active": true + }, + { + "indications": [ + "straight" + ], + "valid_indication": "straight", + "valid": true, + "active": true + } + ], + "location": [ + -73.987058, + 40.760981 + ], + "geometry_index": 8, + "admin_index": 0, + "weight": 2.258, + "is_urban": true, + "mapbox_streets_v8": { + "class": "secondary" + }, + "turn_duration": 0.012, + "turn_weight": 1, + "duration": 1.27, + "bearings": [ + 29, + 121, + 209, + 301 + ], + "out": 0, + "in": 2, + "entry": [ + true, + false, + false, + false + ] + }, + { + "lanes": [ + { + "indications": [ + "straight" + ], + "valid": false, + "active": false + }, + { + "indications": [ + "straight" + ], + "valid_indication": "straight", + "valid": true, + "active": true + }, + { + "indications": [ + "straight" + ], + "valid_indication": "straight", + "valid": true, + "active": true + } + ], + "mapbox_streets_v8": { + "class": "secondary" + }, + "location": [ + -73.987018, + 40.761036 + ], + "geometry_index": 9, + "admin_index": 0, + "weight": 2.577, + "is_urban": true, + "traffic_signal": true, + "turn_duration": 3.012, + "turn_weight": 1, + "duration": 4.589, + "bearings": [ + 29, + 120, + 209, + 298 + ], + "out": 0, + "in": 2, + "entry": [ + true, + true, + false, + false + ] + }, + { + "entry": [ + true, + false, + false, + false + ], + "in": 2, + "bearings": [ + 27, + 118, + 209, + 296 + ], + "duration": 4.451, + "turn_weight": 1, + "turn_duration": 0.029, + "mapbox_streets_v8": { + "class": "secondary" + }, + "is_urban": true, + "admin_index": 0, + "out": 0, + "weight": 5.423, + "geometry_index": 10, + "location": [ + -73.986968, + 40.761105 + ] + }, + { + "entry": [ + true, + false + ], + "in": 1, + "bearings": [ + 29, + 207 + ], + "duration": 5.257, + "mapbox_streets_v8": { + "class": "secondary" + }, + "is_urban": true, + "admin_index": 0, + "out": 0, + "weight": 5.257, + "geometry_index": 11, + "location": [ + -73.986834, + 40.761301 + ] + }, + { + "entry": [ + true, + false + ], + "in": 1, + "bearings": [ + 29, + 209 + ], + "duration": 1.886, + "mapbox_streets_v8": { + "class": "secondary" + }, + "is_urban": true, + "admin_index": 0, + "out": 0, + "weight": 1.886, + "geometry_index": 12, + "location": [ + -73.986665, + 40.76153 + ] + }, + { + "entry": [ + true, + false, + false, + false + ], + "in": 2, + "bearings": [ + 27, + 120, + 209, + 300 + ], + "duration": 1.29, + "turn_weight": 1, + "turn_duration": 0.029, + "mapbox_streets_v8": { + "class": "secondary" + }, + "is_urban": true, + "admin_index": 0, + "out": 0, + "weight": 2.262, + "geometry_index": 13, + "location": [ + -73.986604, + 40.761612 + ] + }, + { + "mapbox_streets_v8": { + "class": "secondary" + }, + "location": [ + -73.986566, + 40.761668 + ], + "geometry_index": 14, + "admin_index": 0, + "weight": 1.904, + "is_urban": true, + "traffic_signal": true, + "turn_duration": 3.013, + "turn_weight": 1, + "duration": 3.917, + "bearings": [ + 29, + 120, + 207, + 298 + ], + "out": 0, + "in": 2, + "entry": [ + true, + false, + false, + true + ] + }, + { + "entry": [ + true, + false, + false, + false + ], + "in": 2, + "bearings": [ + 29, + 120, + 209, + 300 + ], + "duration": 8.37, + "turn_weight": 1, + "turn_duration": 0.012, + "mapbox_streets_v8": { + "class": "secondary" + }, + "is_urban": true, + "admin_index": 0, + "out": 0, + "weight": 9.358, + "geometry_index": 15, + "location": [ + -73.986525, + 40.761723 + ] + }, + { + "bearings": [ + 29, + 118, + 209, + 298 + ], + "entry": [ + true, + false, + false, + false + ], + "in": 2, + "turn_weight": 1, + "turn_duration": 0.012, + "mapbox_streets_v8": { + "class": "secondary" + }, + "is_urban": true, + "admin_index": 0, + "out": 0, + "geometry_index": 16, + "location": [ + -73.986147, + 40.762232 + ] + } + ], + "bannerInstructions": [ + { + "primary": { + "components": [ + { + "type": "text", + "text": "West 50th Street" + } + ], + "type": "turn", + "modifier": "right", + "text": "West 50th Street" + }, + "distanceAlongGeometry": 239.711 + } + ], + "speedLimitUnit": "mph", + "maneuver": { + "type": "turn", + "instruction": "Turn right onto 8th Avenue.", + "modifier": "right", + "bearing_after": 29, + "bearing_before": 299, + "location": [ + -73.987475, + 40.760409 + ] + }, + "speedLimitSign": "mutcd", + "name": "8th Avenue", + "weight_typical": 54.716, + "duration_typical": 53.004, + "duration": 51.323, + "distance": 239.711, + "driving_side": "right", + "weight": 53.036, + "mode": "driving", + "geometry": "qdyvlAdxyblC_C{Aw^eVmBoAiCcBgKkGiMqIcDyBoBkAmBqAy^sV{B{A" + }, + { + "voiceInstructions": [ + { + "ssmlAnnouncement": "In 500 meters, You will arrive at Dropped Pin #1.", + "announcement": "In 500 meters, You will arrive at Dropped Pin #1.", + "distanceAlongGeometry": 534.378 + }, + { + "ssmlAnnouncement": "You have arrived at Dropped Pin #1.", + "announcement": "You have arrived at Dropped Pin #1.", + "distanceAlongGeometry": 55.556 + } + ], + "intersections": [ + { + "mapbox_streets_v8": { + "class": "secondary" + }, + "location": [ + -73.986101, + 40.762294 + ], + "geometry_index": 17, + "admin_index": 0, + "weight": 7.525, + "is_urban": true, + "traffic_signal": true, + "turn_duration": 6.472, + "turn_weight": 4, + "duration": 9.997, + "bearings": [ + 30, + 119, + 209, + 298 + ], + "out": 1, + "in": 2, + "entry": [ + true, + true, + false, + false + ] + }, + { + "entry": [ + false, + true, + false, + false + ], + "in": 3, + "bearings": [ + 28, + 119, + 208, + 299 + ], + "duration": 15.829, + "turn_weight": 1, + "turn_duration": 0.012, + "mapbox_streets_v8": { + "class": "secondary" + }, + "is_urban": true, + "admin_index": 0, + "out": 1, + "weight": 16.818, + "geometry_index": 18, + "location": [ + -73.985959, + 40.762234 + ] + }, + { + "entry": [ + true, + true, + false + ], + "in": 2, + "bearings": [ + 119, + 208, + 299 + ], + "duration": 18.086, + "turn_weight": 0.1, + "turn_duration": 0.012, + "mapbox_streets_v8": { + "class": "secondary" + }, + "is_urban": true, + "admin_index": 0, + "out": 0, + "weight": 18.174, + "geometry_index": 20, + "location": [ + -73.985321, + 40.761966 + ] + }, + { + "entry": [ + false, + true, + false, + false + ], + "in": 3, + "bearings": [ + 27, + 120, + 207, + 299 + ], + "duration": 1.254, + "turn_weight": 1, + "turn_duration": 0.012, + "mapbox_streets_v8": { + "class": "secondary" + }, + "is_urban": true, + "admin_index": 0, + "out": 1, + "weight": 2.242, + "geometry_index": 22, + "location": [ + -73.984176, + 40.761484 + ] + }, + { + "mapbox_streets_v8": { + "class": "secondary" + }, + "location": [ + -73.984098, + 40.76145 + ], + "geometry_index": 23, + "admin_index": 0, + "weight": 5.092, + "is_urban": true, + "traffic_signal": true, + "turn_duration": 3.031, + "turn_weight": 1, + "duration": 7.123, + "bearings": [ + 25, + 118, + 207, + 300 + ], + "out": 1, + "in": 3, + "entry": [ + false, + true, + true, + false + ] + }, + { + "entry": [ + false, + true, + false, + false + ], + "in": 3, + "bearings": [ + 28, + 119, + 207, + 298 + ], + "duration": 6.12, + "turn_weight": 1, + "turn_duration": 0.012, + "mapbox_streets_v8": { + "class": "secondary" + }, + "is_urban": true, + "admin_index": 0, + "out": 1, + "weight": 7.108, + "geometry_index": 25, + "location": [ + -73.983932, + 40.761382 + ] + }, + { + "entry": [ + true, + false + ], + "in": 1, + "bearings": [ + 119, + 299 + ], + "duration": 7.211, + "mapbox_streets_v8": { + "class": "secondary" + }, + "is_urban": true, + "admin_index": 0, + "out": 0, + "weight": 7.211, + "geometry_index": 26, + "location": [ + -73.983686, + 40.761278 + ] + }, + { + "entry": [ + false, + true, + false, + false + ], + "in": 3, + "bearings": [ + 30, + 119, + 208, + 299 + ], + "duration": 3.608, + "turn_weight": 1, + "turn_duration": 0.012, + "mapbox_streets_v8": { + "class": "secondary" + }, + "is_urban": true, + "admin_index": 0, + "out": 1, + "weight": 4.596, + "geometry_index": 28, + "location": [ + -73.983395, + 40.761156 + ] + }, + { + "mapbox_streets_v8": { + "class": "secondary" + }, + "location": [ + -73.98325, + 40.761095 + ], + "geometry_index": 29, + "admin_index": 0, + "weight": 4.255, + "is_urban": true, + "traffic_signal": true, + "turn_duration": 3.012, + "turn_weight": 1, + "duration": 6.267, + "bearings": [ + 28, + 120, + 208, + 299 + ], + "out": 1, + "in": 3, + "entry": [ + false, + true, + true, + false + ] + }, + { + "entry": [ + false, + true, + false, + false + ], + "in": 3, + "bearings": [ + 30, + 119, + 208, + 300 + ], + "duration": 25.647, + "turn_weight": 1, + "turn_duration": 0.01, + "mapbox_streets_v8": { + "class": "secondary" + }, + "is_urban": true, + "admin_index": 0, + "out": 1, + "weight": 26.637, + "geometry_index": 30, + "location": [ + -73.983138, + 40.761047 + ] + }, + { + "entry": [ + true, + false, + false + ], + "in": 2, + "bearings": [ + 119, + 208, + 299 + ], + "duration": 49.014, + "turn_weight": 0.1, + "turn_duration": 0.012, + "mapbox_streets_v8": { + "class": "secondary" + }, + "is_urban": true, + "admin_index": 0, + "out": 0, + "weight": 49.102, + "geometry_index": 31, + "location": [ + -73.98225, + 40.760677 + ] + }, + { + "bearings": [ + 32, + 119, + 213, + 299 + ], + "entry": [ + false, + true, + false, + false + ], + "in": 3, + "turn_weight": 1, + "turn_duration": 0.012, + "mapbox_streets_v8": { + "class": "secondary" + }, + "is_urban": true, + "admin_index": 0, + "out": 1, + "geometry_index": 33, + "location": [ + -73.980554, + 40.759968 + ] + } + ], + "bannerInstructions": [ + { + "primary": { + "components": [ + { + "type": "text", + "text": "You will arrive at Dropped Pin #1" + } + ], + "type": "arrive", + "modifier": "straight", + "text": "You will arrive at Dropped Pin #1" + }, + "distanceAlongGeometry": 547.712 + }, + { + "primary": { + "components": [ + { + "type": "text", + "text": "You have arrived at Dropped Pin #1" + } + ], + "type": "arrive", + "modifier": "straight", + "text": "You have arrived at Dropped Pin #1" + }, + "distanceAlongGeometry": 55.556 + } + ], + "speedLimitUnit": "mph", + "maneuver": { + "type": "turn", + "instruction": "Turn right onto West 50th Street.", + "modifier": "right", + "bearing_after": 119, + "bearing_before": 29, + "location": [ + -73.986101, + 40.762294 + ] + }, + "speedLimitSign": "mutcd", + "name": "West 50th Street", + "weight_typical": 126.873, + "duration_typical": 127.281, + "duration": 154.1, + "distance": 547.712, + "driving_side": "right", + "weight": 153.692, + "mode": "driving", + "geometry": "kz|vlAhbwblCvB{GlBeGhLu^b@sA~[}cAbA{Cz@uCjAuDnEkNdEyMl@kBxBaH~A_FbVov@pJuZv_@imApBoG" + }, + { + "voiceInstructions": [], + "intersections": [ + { + "bearings": [ + 299 + ], + "entry": [ + true + ], + "in": 0, + "admin_index": 0, + "geometry_index": 34, + "location": [ + -73.980418, + 40.759911 + ] + } + ], + "bannerInstructions": [], + "speedLimitUnit": "mph", + "maneuver": { + "type": "arrive", + "instruction": "You have arrived at Dropped Pin #1.", + "bearing_after": 0, + "bearing_before": 119, + "location": [ + -73.980418, + 40.759911 + ] + }, + "speedLimitSign": "mutcd", + "name": "West 50th Street", + "weight_typical": 0, + "duration_typical": 0, + "duration": 0, + "distance": 0, + "driving_side": "right", + "weight": 0, + "mode": "driving", + "geometry": "mexvlAb_lblC??" + } + ], + "distance": 1023.197, + "summary": "8th Avenue, West 50th Street" + } + ], + "geometry": "}dwvlA|~tblC}AbFw@jCoBtGok@bjBoFzPmB`G_C{Aw^eVmBoAiCcBgKkGiMqIcDyBoBkAmBqAy^sV{B{AvB{GlBeGhLu^b@sA~[}cAbA{Cz@uCjAuDnEkNdEyMl@kBxBaH~A_FbVov@pJuZv_@imApBoG", + "voiceLocale": "en-US", + "refresh_ttl": 21600 + }, + { + "weight_typical": 277.958, + "duration_typical": 241.305, + "weight_name": "auto", + "weight": 296.94, + "duration": 260.288, + "distance": 1024.206, + "legs": [ + { + "via_waypoints": [], + "admins": [ + { + "iso_3166_1_alpha3": "USA", + "iso_3166_1": "US" + } + ], + "annotation": { + "maxspeed": [ + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + } + ], + "congestion_numeric": [ + null, + null, + null, + null, + null, + null, + 0, + 0, + 0, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 4, + 4, + 4, + 0, + 0, + 0 + ], + "duration": [ + 4.925, + 2.508, + 3.984, + 49.449, + 6.208, + 2.814, + 7.618, + 11.645, + 1.27, + 3.579, + 28.5, + 8.236, + 0.773, + 1.63, + 0.748, + 1.587, + 1.65, + 8.403, + 2.889, + 3.9, + 26.011, + 2.774, + 16.977, + 12.564, + 2.781, + 13.117, + 16.716, + 1.845, + 7.744, + 6.162, + 1.283 + ] + }, + "weight_typical": 277.958, + "duration_typical": 241.305, + "weight": 296.94, + "duration": 260.288, + "steps": [ + { + "voiceInstructions": [ + { + "ssmlAnnouncement": "Drive northwest on West 47th Street. Then, in 200 meters, Turn right onto 8th Avenue.", + "announcement": "Drive northwest on West 47th Street. Then, in 200 meters, Turn right onto 8th Avenue.", + "distanceAlongGeometry": 235.775 + }, + { + "ssmlAnnouncement": "Turn right onto 8th Avenue. Then Turn right onto West 48th Street.", + "announcement": "Turn right onto 8th Avenue. Then Turn right onto West 48th Street.", + "distanceAlongGeometry": 78.111 + } + ], + "intersections": [ + { + "entry": [ + true + ], + "bearings": [ + 299 + ], + "duration": 4.925, + "mapbox_streets_v8": { + "class": "street" + }, + "is_urban": true, + "admin_index": 0, + "out": 0, + "weight": 4.925, + "geometry_index": 0, + "location": [ + -73.985023, + 40.759391 + ] + }, + { + "lanes": [ + { + "indications": [ + "straight" + ], + "valid": false, + "active": false + }, + { + "indications": [ + "straight" + ], + "valid_indication": "straight", + "valid": true, + "active": true + } + ], + "mapbox_streets_v8": { + "class": "street" + }, + "location": [ + -73.985137, + 40.759438 + ], + "geometry_index": 1, + "admin_index": 0, + "weight": 2.202, + "is_urban": true, + "traffic_signal": true, + "turn_duration": 0.505, + "turn_weight": 0.2, + "duration": 2.508, + "bearings": [ + 15, + 119, + 298 + ], + "out": 2, + "in": 1, + "entry": [ + false, + false, + true + ] + }, + { + "entry": [ + false, + false, + false, + true + ], + "in": 1, + "bearings": [ + 15, + 118, + 194, + 298 + ], + "duration": 53.434, + "turn_weight": 2, + "turn_duration": 0.002, + "mapbox_streets_v8": { + "class": "street" + }, + "is_urban": true, + "admin_index": 0, + "out": 3, + "weight": 55.432, + "geometry_index": 2, + "location": [ + -73.985207, + 40.759466 + ] + }, + { + "entry": [ + true, + false, + true + ], + "in": 1, + "bearings": [ + 27, + 119, + 299 + ], + "duration": 6.208, + "turn_weight": 0.2, + "turn_duration": 0.005, + "mapbox_streets_v8": { + "class": "street" + }, + "is_urban": true, + "admin_index": 0, + "out": 2, + "weight": 6.403, + "geometry_index": 4, + "location": [ + -73.98706, + 40.760234 + ] + }, + { + "bearings": [ + 31, + 119, + 213, + 299 + ], + "entry": [ + false, + false, + false, + true + ], + "in": 1, + "turn_weight": 2, + "turn_duration": 0.005, + "mapbox_streets_v8": { + "class": "street" + }, + "is_urban": true, + "admin_index": 0, + "out": 3, + "geometry_index": 5, + "location": [ + -73.987346, + 40.760354 + ] + } + ], + "bannerInstructions": [ + { + "sub": { + "components": [ + { + "type": "text", + "text": "West 48th Street" + } + ], + "type": "turn", + "modifier": "right", + "text": "West 48th Street" + }, + "primary": { + "components": [ + { + "type": "text", + "text": "8th Avenue" + } + ], + "type": "turn", + "modifier": "right", + "text": "8th Avenue" + }, + "distanceAlongGeometry": 235.775 + } + ], + "speedLimitUnit": "mph", + "maneuver": { + "type": "depart", + "instruction": "Drive northwest on West 47th Street.", + "bearing_after": 299, + "bearing_before": 0, + "location": [ + -73.985023, + 40.759391 + ] + }, + "speedLimitSign": "mutcd", + "name": "West 47th Street", + "weight_typical": 57.449, + "duration_typical": 53.567, + "duration": 69.888, + "distance": 235.775, + "driving_side": "right", + "weight": 73.77, + "mode": "driving", + "geometry": "}dwvlA|~tblC}AbFw@jCoBtGok@bjBoFzPmB`G" + }, + { + "voiceInstructions": [ + { + "ssmlAnnouncement": "Turn right onto West 48th Street.", + "announcement": "Turn right onto West 48th Street.", + "distanceAlongGeometry": 71.111 + } + ], + "intersections": [ + { + "mapbox_streets_v8": { + "class": "secondary" + }, + "location": [ + -73.987475, + 40.760409 + ], + "geometry_index": 6, + "admin_index": 0, + "weight": 7.46, + "is_urban": true, + "traffic_signal": true, + "turn_duration": 6.158, + "turn_weight": 6, + "duration": 7.618, + "bearings": [ + 29, + 119, + 208, + 298 + ], + "out": 0, + "in": 1, + "entry": [ + true, + false, + false, + true + ] + }, + { + "lanes": [ + { + "indications": [ + "straight" + ], + "valid": false, + "active": false + }, + { + "indications": [ + "straight" + ], + "valid": false, + "active": false + }, + { + "indications": [ + "straight" + ], + "valid_indication": "straight", + "valid": true, + "active": true + } + ], + "location": [ + -73.987429, + 40.760473 + ], + "geometry_index": 7, + "admin_index": 0, + "weight": 12.633, + "is_urban": true, + "mapbox_streets_v8": { + "class": "secondary" + }, + "turn_duration": 0.012, + "turn_weight": 1, + "duration": 11.645, + "bearings": [ + 29, + 118, + 209, + 298 + ], + "out": 0, + "in": 2, + "entry": [ + true, + false, + false, + false + ] + }, + { + "bearings": [ + 29, + 121, + 209, + 301 + ], + "entry": [ + true, + false, + false, + false + ], + "in": 2, + "turn_weight": 1, + "lanes": [ + { + "indications": [ + "straight" + ], + "valid": false, + "active": false + }, + { + "indications": [ + "straight" + ], + "valid": false, + "active": false + }, + { + "indications": [ + "straight" + ], + "valid_indication": "straight", + "valid": true, + "active": true + } + ], + "turn_duration": 0.012, + "mapbox_streets_v8": { + "class": "secondary" + }, + "is_urban": true, + "admin_index": 0, + "out": 0, + "geometry_index": 8, + "location": [ + -73.987058, + 40.760981 + ] + } + ], + "bannerInstructions": [ + { + "primary": { + "components": [ + { + "type": "text", + "text": "West 48th Street" + } + ], + "type": "turn", + "modifier": "right", + "text": "West 48th Street" + }, + "distanceAlongGeometry": 79.728 + } + ], + "speedLimitUnit": "mph", + "maneuver": { + "type": "turn", + "instruction": "Turn right onto 8th Avenue.", + "modifier": "right", + "bearing_after": 29, + "bearing_before": 299, + "location": [ + -73.987475, + 40.760409 + ] + }, + "speedLimitSign": "mutcd", + "name": "8th Avenue", + "weight_typical": 23.106, + "duration_typical": 21.288, + "duration": 20.533, + "distance": 79.728, + "driving_side": "right", + "weight": 22.351, + "mode": "driving", + "geometry": "qdyvlAdxyblC_C{Aw^eVmBoA" + }, + { + "voiceInstructions": [ + { + "ssmlAnnouncement": "In 500 meters, Turn left onto 6th Avenue.", + "announcement": "In 500 meters, Turn left onto 6th Avenue.", + "distanceAlongGeometry": 534.376 + }, + { + "ssmlAnnouncement": "Turn left onto 6th Avenue, Avenue of the Americas.", + "announcement": "Turn left onto 6th Avenue, Avenue of the Americas.", + "distanceAlongGeometry": 78.111 + } + ], + "intersections": [ + { + "mapbox_streets_v8": { + "class": "street" + }, + "location": [ + -73.987018, + 40.761036 + ], + "geometry_index": 9, + "admin_index": 0, + "weight": 10.5, + "is_urban": true, + "traffic_signal": true, + "turn_duration": 1.079, + "turn_weight": 8, + "duration": 3.579, + "bearings": [ + 30, + 119, + 209, + 298 + ], + "out": 1, + "in": 2, + "entry": [ + true, + true, + false, + false + ] + }, + { + "entry": [ + false, + true, + false, + false + ], + "in": 3, + "bearings": [ + 31, + 119, + 210, + 299 + ], + "duration": 28.5, + "turn_weight": 2, + "turn_duration": 0.002, + "mapbox_streets_v8": { + "class": "street" + }, + "is_urban": true, + "admin_index": 0, + "out": 1, + "weight": 30.499, + "geometry_index": 10, + "location": [ + -73.986888, + 40.760982 + ] + }, + { + "entry": [ + true, + true, + false + ], + "in": 2, + "bearings": [ + 31, + 119, + 299 + ], + "duration": 9.01, + "turn_weight": 0.2, + "turn_duration": 0.002, + "mapbox_streets_v8": { + "class": "street" + }, + "is_urban": true, + "admin_index": 0, + "out": 1, + "weight": 9.208, + "geometry_index": 11, + "location": [ + -73.985411, + 40.76036 + ] + }, + { + "entry": [ + false, + true, + false, + false + ], + "in": 3, + "bearings": [ + 15, + 120, + 196, + 299 + ], + "duration": 1.63, + "turn_weight": 2, + "turn_duration": 0.002, + "mapbox_streets_v8": { + "class": "street" + }, + "is_urban": true, + "admin_index": 0, + "out": 1, + "weight": 3.628, + "geometry_index": 13, + "location": [ + -73.984943, + 40.760165 + ] + }, + { + "entry": [ + true, + false + ], + "in": 1, + "bearings": [ + 118, + 300 + ], + "duration": 0.748, + "mapbox_streets_v8": { + "class": "street" + }, + "is_urban": true, + "admin_index": 0, + "out": 0, + "weight": 0.748, + "geometry_index": 14, + "location": [ + -73.984859, + 40.760129 + ] + }, + { + "mapbox_streets_v8": { + "class": "street" + }, + "location": [ + -73.98482, + 40.760113 + ], + "geometry_index": 15, + "admin_index": 0, + "weight": 4.734, + "is_urban": true, + "traffic_signal": true, + "turn_duration": 0.502, + "turn_weight": 2, + "duration": 3.236, + "bearings": [ + 46, + 119, + 158, + 232, + 298 + ], + "out": 1, + "in": 4, + "entry": [ + false, + true, + true, + true, + false + ] + }, + { + "lanes": [ + { + "indications": [ + "straight" + ], + "valid_indication": "straight", + "valid": true, + "active": true + }, + { + "indications": [ + "straight" + ], + "valid": false, + "active": false + }, + { + "indications": [ + "right" + ], + "valid": false, + "active": false + } + ], + "location": [ + -73.984694, + 40.76006 + ], + "geometry_index": 17, + "admin_index": 0, + "weight": 10.401, + "is_urban": true, + "mapbox_streets_v8": { + "class": "street" + }, + "turn_duration": 0.002, + "turn_weight": 2, + "duration": 8.403, + "bearings": [ + 18, + 119, + 199, + 299 + ], + "out": 1, + "in": 3, + "entry": [ + false, + true, + false, + false + ] + }, + { + "lanes": [ + { + "indications": [ + "straight" + ], + "valid_indication": "straight", + "valid": true, + "active": true + }, + { + "indications": [ + "straight" + ], + "valid": false, + "active": false + }, + { + "indications": [ + "right" + ], + "valid": false, + "active": false + } + ], + "location": [ + -73.984307, + 40.759897 + ], + "geometry_index": 18, + "admin_index": 0, + "weight": 4.887, + "is_urban": true, + "mapbox_streets_v8": { + "class": "street" + }, + "turn_duration": 0.002, + "turn_weight": 2, + "duration": 2.889, + "bearings": [ + 31, + 119, + 210, + 299 + ], + "out": 1, + "in": 3, + "entry": [ + false, + true, + false, + false + ] + }, + { + "lanes": [ + { + "indications": [ + "straight" + ], + "valid_indication": "straight", + "valid": true, + "active": true + }, + { + "indications": [ + "straight" + ], + "valid": false, + "active": false + }, + { + "indications": [ + "right" + ], + "valid": false, + "active": false + } + ], + "mapbox_streets_v8": { + "class": "street" + }, + "location": [ + -73.984174, + 40.759841 + ], + "geometry_index": 19, + "admin_index": 0, + "weight": 6.398, + "is_urban": true, + "traffic_signal": true, + "turn_duration": 0.502, + "turn_weight": 3, + "duration": 3.9, + "bearings": [ + 30, + 119, + 208, + 299 + ], + "out": 1, + "in": 3, + "entry": [ + false, + true, + true, + false + ] + }, + { + "entry": [ + false, + true, + false, + false + ], + "in": 3, + "bearings": [ + 27, + 119, + 207, + 299 + ], + "duration": 26.011, + "turn_weight": 2, + "turn_duration": 0.002, + "mapbox_streets_v8": { + "class": "street" + }, + "is_urban": true, + "admin_index": 0, + "out": 1, + "weight": 28.009, + "geometry_index": 20, + "location": [ + -73.984057, + 40.759791 + ] + }, + { + "entry": [ + false, + true, + true, + false + ], + "in": 3, + "bearings": [ + 28, + 119, + 208, + 299 + ], + "duration": 19.751, + "turn_weight": 2, + "turn_duration": 0.002, + "mapbox_streets_v8": { + "class": "street" + }, + "is_urban": true, + "admin_index": 0, + "out": 1, + "weight": 21.749, + "geometry_index": 21, + "location": [ + -73.983161, + 40.759409 + ] + }, + { + "entry": [ + true, + false + ], + "in": 1, + "bearings": [ + 119, + 299 + ], + "duration": 12.564, + "mapbox_streets_v8": { + "class": "street" + }, + "is_urban": true, + "admin_index": 0, + "out": 0, + "weight": 12.564, + "geometry_index": 23, + "location": [ + -73.982136, + 40.75898 + ] + }, + { + "bearings": [ + 28, + 120, + 208, + 299 + ], + "entry": [ + false, + true, + false, + false + ], + "in": 3, + "turn_weight": 2, + "turn_duration": 0.002, + "mapbox_streets_v8": { + "class": "street" + }, + "is_urban": true, + "admin_index": 0, + "out": 1, + "geometry_index": 24, + "location": [ + -73.981484, + 40.758707 + ] + } + ], + "bannerInstructions": [ + { + "primary": { + "components": [ + { + "type": "text", + "text": "6th Avenue" + }, + { + "type": "text", + "text": "/" + }, + { + "type": "text", + "text": "Avenue of the Americas" + } + ], + "type": "turn", + "modifier": "left", + "text": "6th Avenue / Avenue of the Americas" + }, + "distanceAlongGeometry": 547.71 + } + ], + "speedLimitUnit": "mph", + "maneuver": { + "type": "turn", + "instruction": "Turn right onto West 48th Street.", + "modifier": "right", + "bearing_after": 119, + "bearing_before": 29, + "location": [ + -73.987018, + 40.761036 + ] + }, + "speedLimitSign": "mutcd", + "name": "West 48th Street", + "weight_typical": 150.435, + "duration_typical": 125.333, + "duration": 123.001, + "distance": 547.71, + "driving_side": "right", + "weight": 148.102, + "mode": "driving", + "geometry": "wkzvlAr{xblCjBcGze@i{AbJwY`@oAfAgD^mAh@cB~@wCdIeWnBiGbBiFzV_w@vB_H`Vav@`Pwg@zB}G" + }, + { + "voiceInstructions": [ + { + "ssmlAnnouncement": "In 200 meters, You will arrive at Dropped Pin #1.", + "announcement": "In 200 meters, You will arrive at Dropped Pin #1.", + "distanceAlongGeometry": 147.66 + }, + { + "ssmlAnnouncement": "You have arrived at Dropped Pin #1.", + "announcement": "You have arrived at Dropped Pin #1.", + "distanceAlongGeometry": 55.556 + } + ], + "intersections": [ + { + "mapbox_streets_v8": { + "class": "secondary" + }, + "location": [ + -73.981341, + 40.758645 + ], + "geometry_index": 25, + "admin_index": 0, + "weight": 17.025, + "is_urban": true, + "traffic_signal": true, + "turn_duration": 11.092, + "turn_weight": 15, + "duration": 13.117, + "bearings": [ + 29, + 120, + 208, + 300 + ], + "out": 0, + "in": 3, + "entry": [ + true, + true, + false, + false + ] + }, + { + "entry": [ + true, + false, + false, + false + ], + "in": 2, + "bearings": [ + 29, + 120, + 209, + 298 + ], + "duration": 16.716, + "turn_weight": 1, + "turn_duration": 0.012, + "mapbox_streets_v8": { + "class": "secondary" + }, + "is_urban": true, + "admin_index": 0, + "out": 0, + "weight": 17.704, + "geometry_index": 26, + "location": [ + -73.981296, + 40.758707 + ] + }, + { + "entry": [ + true, + false, + false, + false + ], + "in": 2, + "bearings": [ + 29, + 120, + 209, + 298 + ], + "duration": 1.845, + "turn_weight": 1, + "turn_duration": 0.012, + "mapbox_streets_v8": { + "class": "secondary" + }, + "is_urban": true, + "admin_index": 0, + "out": 0, + "weight": 2.833, + "geometry_index": 27, + "location": [ + -73.980924, + 40.759218 + ] + }, + { + "mapbox_streets_v8": { + "class": "secondary" + }, + "location": [ + -73.980883, + 40.759274 + ], + "geometry_index": 28, + "admin_index": 0, + "weight": 5.732, + "is_urban": true, + "traffic_signal": true, + "turn_duration": 3.012, + "turn_weight": 1, + "duration": 7.744, + "bearings": [ + 29, + 120, + 209, + 298 + ], + "out": 0, + "in": 2, + "entry": [ + true, + false, + false, + true + ] + }, + { + "entry": [ + true, + false, + false, + false + ], + "in": 2, + "bearings": [ + 29, + 120, + 209, + 300 + ], + "duration": 6.162, + "turn_weight": 1, + "turn_duration": 0.012, + "mapbox_streets_v8": { + "class": "secondary" + }, + "is_urban": true, + "admin_index": 0, + "out": 0, + "weight": 7.15, + "geometry_index": 29, + "location": [ + -73.980702, + 40.759522 + ] + }, + { + "bearings": [ + 28, + 120, + 209, + 300 + ], + "entry": [ + true, + false, + false, + false + ], + "in": 2, + "turn_weight": 1, + "turn_duration": 0.01, + "mapbox_streets_v8": { + "class": "secondary" + }, + "is_urban": true, + "admin_index": 0, + "out": 0, + "geometry_index": 30, + "location": [ + -73.980466, + 40.759844 + ] + } + ], + "bannerInstructions": [ + { + "primary": { + "components": [ + { + "type": "text", + "text": "You will arrive at Dropped Pin #1" + } + ], + "type": "arrive", + "modifier": "straight", + "text": "You will arrive at Dropped Pin #1" + }, + "distanceAlongGeometry": 160.993 + }, + { + "primary": { + "components": [ + { + "type": "text", + "text": "You have arrived at Dropped Pin #1" + } + ], + "type": "arrive", + "modifier": "straight", + "text": "You have arrived at Dropped Pin #1" + }, + "distanceAlongGeometry": 55.556 + } + ], + "speedLimitUnit": "mph", + "maneuver": { + "type": "turn", + "instruction": "Turn left onto 6th Avenue/Avenue of the Americas.", + "modifier": "left", + "bearing_after": 29, + "bearing_before": 120, + "location": [ + -73.981341, + 40.758645 + ] + }, + "speedLimitSign": "mutcd", + "name": "6th Avenue; Avenue of the Americas", + "weight_typical": 46.967, + "duration_typical": 41.117, + "duration": 46.867, + "distance": 160.993, + "driving_side": "right", + "weight": 52.717, + "mode": "driving", + "geometry": "ivuvlAxxmblC{ByA}^gVoBqAoNiJcSwMeC_B" + }, + { + "voiceInstructions": [], + "intersections": [ + { + "bearings": [ + 208 + ], + "entry": [ + true + ], + "in": 0, + "admin_index": 0, + "geometry_index": 31, + "location": [ + -73.980418, + 40.759911 + ] + } + ], + "bannerInstructions": [], + "speedLimitUnit": "mph", + "maneuver": { + "type": "arrive", + "instruction": "You have arrived at Dropped Pin #1.", + "bearing_after": 0, + "bearing_before": 28, + "location": [ + -73.980418, + 40.759911 + ] + }, + "speedLimitSign": "mutcd", + "name": "6th Avenue; Avenue of the Americas", + "weight_typical": 0, + "duration_typical": 0, + "duration": 0, + "distance": 0, + "driving_side": "right", + "weight": 0, + "mode": "driving", + "geometry": "mexvlAb_lblC??" + } + ], + "distance": 1024.206, + "summary": "West 47th Street, West 48th Street" + } + ], + "geometry": "}dwvlA|~tblC}AbFw@jCoBtGok@bjBoFzPmB`G_C{Aw^eVmBoAjBcGze@i{AbJwY`@oAfAgD^mAh@cB~@wCdIeWnBiGbBiFzV_w@vB_H`Vav@`Pwg@zB}G{ByA}^gVoBqAoNiJcSwMeC_B", + "voiceLocale": "en-US", + "refresh_ttl": 21600 + } + ], + "waypoints": [ + { + "time_zone": { + "abbreviation": "EDT", + "identifier": "America/New_York", + "offset": "-04:00" + }, + "distance": 0.202, + "name": "West 47th Street", + "location": [ + -73.985023, + 40.759391 + ] + }, + { + "time_zone": { + "abbreviation": "EDT", + "identifier": "America/New_York", + "offset": "-04:00" + }, + "distance": 2.511, + "name": "West 50th Street", + "location": [ + -73.980418, + 40.759911 + ] + } + ], + "code": "Ok", + "uuid": "qwm5vFrFhdXrygmsyXdBwMlRafY1goGte1E89oqgN15Yipdmh0E77g==_eu-west-1" +} diff --git a/Sources/TestHelper/Fixtures/profile-route-refresh.json b/Sources/TestHelper/Fixtures/profile-route-refresh.json new file mode 100644 index 00000000000..171981d7941 --- /dev/null +++ b/Sources/TestHelper/Fixtures/profile-route-refresh.json @@ -0,0 +1,222 @@ +{ + "code": "Ok", + "route": { + "legs": [ + { + "annotation": { + "maxspeed": [ + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + }, + { + "speed": 40, + "unit": "km/h" + } + ], + "congestion_numeric": [ + null, + null, + null, + null, + null, + null, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "duration": [ + 2.814, + 2.508, + 3.984, + 49.449, + 8.276, + 3.75, + 7.618, + 11.645, + 1.27, + 4.589, + 4.451, + 5.257, + 1.886, + 1.29, + 3.917, + 8.37, + 1.03, + 8.715, + 2.078, + 7.999, + 0.678, + 17.408, + 1.254, + 4.87, + 2.253, + 6.12, + 5.868, + 1.343, + 3.608, + 5.182, + 17.102, + 8.543, + 24.137, + 2.633 + ] + } + } + ], + "refresh_ttl": 86282 + } +} \ No newline at end of file diff --git a/Tests/MapboxCoreNavigationIntegrationTests/RouteRefreshIntegrationTests.swift b/Tests/MapboxCoreNavigationIntegrationTests/RouteRefreshIntegrationTests.swift new file mode 100644 index 00000000000..d38d89c8cd3 --- /dev/null +++ b/Tests/MapboxCoreNavigationIntegrationTests/RouteRefreshIntegrationTests.swift @@ -0,0 +1,253 @@ +import XCTest +import CoreLocation +import MapboxDirections +import Turf +@testable import TestHelper +@testable import MapboxCoreNavigation +import OHHTTPStubs + +class RouteRefreshIntegrationTests: TestCase { + override func setUp() { + super.setUp() + HTTPStubs.stubRequests( + passingTest: { request -> Bool in + request.url?.absoluteString.contains("directions-refresh") ?? false + }) { request -> HTTPStubsResponse in + HTTPStubsResponse( + data: Fixture.JSONFromFileNamed(name: "profile-route-refresh"), + statusCode: 200, + headers: ["Content-Type":"application/json"] + ) + } + } + + override func tearDown() { + HTTPStubs.removeAllStubs() + MapboxRoutingProvider.__testRoutesStub = nil + super.tearDown() + } + + func testRouteRefreshWithDefaultDrivingTrafficProfile() { + simulateAndTestOnRoute(with: .automobileAvoidingTraffic, shouldRefresh: true) + } + + func testRouteRefreshWithCustomDrivingTrafficProfile() { + simulateAndTestOnRoute(with: .customDrivingTraffic, shouldRefresh: true) + } + + func testRouteRefreshWithDefaultAutomobileProfile() { + simulateAndTestOnRoute(with: .automobile, shouldRefresh: false) + } + + func testRouteRefreshWithWalkingProfile() { + simulateAndTestOnRoute(with: .walking, shouldRefresh: false) + } + + func testReRouteDefaultParametersDefaultDrivingTrafficProfile() { + simulateAndTestOffRoute( + with: .mockedOptions(.automobileAvoidingTraffic), + expectationKey: "RerouteDefaultParametersDefaultProfile") { options in + XCTAssert(options.profileIdentifier == .automobileAvoidingTraffic) + } + } + + func testReRouteCustomParametersCustomDrivingTrafficProfile() { + simulateAndTestOffRoute( + with: .mockedCustomOptions(.customDrivingTraffic), + expectationKey: "RerouteCustomParametersDefaultProfile") { options in + let customOptions = options as! CustomRouteOptions + XCTAssert(customOptions.profileIdentifier == .customDrivingTraffic) + XCTAssert(customOptions.urlQueryItems.contains(.customItem)) + } + } + + func testReRouteCustomParametersDefaultDrivingTrafficProfile() { + simulateAndTestOffRoute( + with: .mockedCustomOptions(.automobileAvoidingTraffic), + expectationKey: "RerouteCustomParametersCustomProfile") { options in + let customOptions = options as! CustomRouteOptions + XCTAssert(customOptions.profileIdentifier == .automobileAvoidingTraffic) + XCTAssert(customOptions.urlQueryItems.contains(.customItem)) + } + } + + private func simulateAndTestOnRoute(with profile: ProfileIdentifier, shouldRefresh: Bool = true) { + let indexedRouteResponse = RouteResponse.mockedIndexRouteResponse(profile: profile) + let simulationLocations = indexedRouteResponse.routeResponse.routes![0].simulationOnRouteLocations + let (locationManager, navigation) = navigatorAndLocationManager( + with: indexedRouteResponse, + simulationLocations: simulationLocations + ) + let refreshExpectation = expectation( + forNotification: .routeControllerDidRefreshRoute, + object: navigation.router + ) { (notification) -> Bool in + return true + } + + refreshExpectation.isInverted = !shouldRefresh + + expectation( + forNotification: .routeControllerDidUpdateAlternatives, + object: navigation.router + ) { (notification) -> Bool in + return true + } + + navigation.start() + locationManager.startUpdatingLocation() + waitForExpectations(timeout: .defaultDelay) { XCTAssertNil($0) } + } + + private func simulateAndTestOffRoute( + with options: NavigationRouteOptions, + expectationKey: String, + validation: @escaping (NavigationRouteOptions) -> Void + ) { + let response = RouteResponse.mockedIndexRouteResponse(options: options) + let simulationLocations = response.routeResponse.routes![0].simulationOffRouteLocations + let (locationManager, navigation) = navigatorAndLocationManager( + with: response, + simulationLocations: simulationLocations + ) + + let expection = expectation(description: expectationKey) + MapboxRoutingProvider.__testRoutesStub = { (options, completionHandler) in + validation(options as! NavigationRouteOptions) + expection.fulfill() + return nil + } + + navigation.start() + locationManager.startUpdatingLocation() + waitForExpectations(timeout: .defaultDelay) { XCTAssertNil($0) } + } + + private func navigatorAndLocationManager( + with indexedRouteResponse: IndexedRouteResponse, + simulationLocations: [CLLocation] + ) -> (ReplayLocationManager, MapboxNavigationService) { + RouteControllerProactiveReroutingInterval = 2 + let locationManager = ReplayLocationManager(locations: simulationLocations) + locationManager.speedMultiplier = 5 + let navigation = MapboxNavigationService( + indexedRouteResponse: indexedRouteResponse, + customRoutingProvider: MapboxRoutingProvider(.online), + credentials: Fixture.credentials, + locationSource: locationManager, + simulating: .never + ) + return (locationManager, navigation) + } +} + +fileprivate extension Route { + var simulationOnRouteLocations: [CLLocation] { + shape! + .coordinates + .map { CLLocation(latitude: $0.latitude, longitude: $0.longitude) } + .shiftedToPresent() + .qualified() + } + + var simulationOffRouteLocations: [CLLocation] { + let stepCoordiantes = legs[0].steps[0].shape!.coordinates + let stepFirstLocation = stepCoordiantes.first! + let stepLastLocation = stepCoordiantes.last! + let stepDirection = stepFirstLocation.direction(to: stepLastLocation) + + let offRouteCoordiantes = [20, 30, 40].map { stepLastLocation.coordinate(at: $0, facing: stepDirection) } + let coordinates = stepCoordiantes + offRouteCoordiantes + return coordinates + .map { CLLocation(latitude: $0.latitude, longitude: $0.longitude) } + .shiftedToPresent() + .qualified() + } +} + +fileprivate extension NavigationRouteOptions { + static func mockedOptions( + _ profile: ProfileIdentifier + ) -> NavigationRouteOptions { + NavigationRouteOptions( + coordinates: [ + .origin, + .destiantion + ], + profileIdentifier: profile + ) + } + + static func mockedCustomOptions( + _ profile: ProfileIdentifier + ) -> NavigationRouteOptions { + let options = CustomRouteOptions( + waypoints: [ + .init(coordinate: .origin), + .init(coordinate: .destiantion), + ], + profileIdentifier: profile + ) + options.custom = URLQueryItem.customItem.value + return options + } +} + +fileprivate extension RouteResponse { + static func mockedResponse(profile: ProfileIdentifier) -> RouteResponse { + Fixture.routeResponse( + from: "profile-route-original", + options: NavigationRouteOptions.mockedOptions(profile) + ) + } + + static func mockedIndexRouteResponse( + profile: ProfileIdentifier + ) -> IndexedRouteResponse { + IndexedRouteResponse( + routeResponse: mockedResponse(profile: profile), + routeIndex: 0 + ) + } + + static func mockedResponse(options: NavigationRouteOptions) -> RouteResponse { + Fixture.routeResponse( + from: "profile-route-original", + options: options + ) + } + + static func mockedIndexRouteResponse( + options: NavigationRouteOptions + ) -> IndexedRouteResponse { + IndexedRouteResponse( + routeResponse: mockedResponse(options: options), + routeIndex: 0 + ) + } +} + +fileprivate extension CLLocationCoordinate2D { + static var origin: CLLocationCoordinate2D { + .init(latitude: -73.98778274913309, longitude: 40.76050975068355) + } + + static var destiantion: CLLocationCoordinate2D { + .init(latitude: -73.98039053825985, longitude: 40.75988085727627) + } +} + +fileprivate extension TimeInterval { + static let defaultDelay: Self = 5 +} + +fileprivate extension ProfileIdentifier { + static let customDrivingTraffic: ProfileIdentifier = .init(rawValue: "custom/driving-traffic") +} + +fileprivate extension URLQueryItem { + static let customItem: URLQueryItem = .init( + name: CustomRouteOptions.CodingKeys.custom.stringValue, + value: "foobar" + ) +}