1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
//! Auto Costing Options
use serde::Serialize;
#[serde_with::skip_serializing_none]
#[derive(Serialize, Debug, Clone, Default, PartialEq)]
struct AutoCostingOptionsInner {
maneuver_penalty: Option<f32>,
gate_cost: Option<f32>,
gate_penalty: Option<f32>,
private_access_penalty: Option<f32>,
destination_only_penalty: Option<f32>,
toll_booth_cost: Option<f32>,
toll_booth_penalty: Option<f32>,
ferry_cost: Option<f32>,
use_ferry: Option<f32>,
use_highways: Option<f32>,
use_tolls: Option<f32>,
use_living_streets: Option<f32>,
use_tracks: Option<f32>,
service_penalty: Option<f32>,
service_factor: Option<f32>,
country_crossing_cost: Option<f32>,
country_crossing_penalty: Option<f32>,
shortest: Option<bool>,
use_distance: Option<f32>,
disable_hierarchy_pruning: Option<bool>,
top_speed: Option<f32>,
fixed_speed: Option<u32>,
closure_factor: Option<f32>,
ignore_closures: Option<bool>,
ignore_restrictions: Option<bool>,
ignore_oneways: Option<bool>,
ignore_non_vehicular_restrictions: Option<bool>,
ignore_access: Option<bool>,
// -- ↓ auto/taxi/bus only ↓ --
speed_types: Option<UsedSpeedSources>,
height: Option<f32>,
width: Option<f32>,
exclude_unpaved: Option<bool>,
exclude_cash_only_tolls: Option<bool>,
include_hov2: Option<bool>,
include_hov3: Option<bool>,
include_hot: Option<bool>,
}
#[derive(Serialize, Debug, Clone, Default, PartialEq)]
/// Auto Costing Options
pub struct AutoCostingOptions {
auto: AutoCostingOptionsInner,
}
impl AutoCostingOptions {
#[must_use]
/// Creates a new instance of [`AutoCostingOptions`].
pub fn builder() -> Self {
Self::default()
}
/// A cost applied when a [gate](http://wiki.openstreetmap.org/wiki/Tag:barrier%3Dgate) with
/// undefined or private access is encountered.
///
/// This cost is added to the estimated time / elapsed time.
///
/// Default: `30` seconds
pub fn gate_cost(mut self, gate_cost: f32) -> Self {
self.auto.gate_cost = Some(gate_cost);
self
}
/// A penalty applied when a [gate](https://wiki.openstreetmap.org/wiki/Tag:barrier%3Dgate) with
/// no access information is on the road.
///
/// Default: `300` seconds
pub fn gate_penalty(mut self, gate_penalty: f32) -> Self {
self.auto.gate_penalty = Some(gate_penalty);
self
}
/// A penalty applied when a [gate](https://wiki.openstreetmap.org/wiki/Tag:barrier%3Dgate) or
/// [bollard](https://wiki.openstreetmap.org/wiki/Tag:barrier%3Dbollard) with `access=private`
/// is encountered.
///
/// Default: `450` seconds
pub fn private_access_penalty(mut self, private_access_penalty: f32) -> Self {
self.auto.private_access_penalty = Some(private_access_penalty);
self
}
/// A penalty applied when entering a road which is only allowed to enter if necessary to reach
/// the [destination](https://wiki.openstreetmap.org/wiki/Tag:vehicle%3Ddestination).
pub fn destination_only_penalty(mut self, destination_only_penalty: f32) -> Self {
self.auto.destination_only_penalty = Some(destination_only_penalty);
self
}
/// A cost applied when a [toll booth](http://wiki.openstreetmap.org/wiki/Tag:barrier%3Dtoll_booth)
/// is encountered.
///
/// This cost is added to the estimated and elapsed times.
///
/// Default: `15` seconds
pub fn toll_booth_cost(mut self, toll_booth_cost: f32) -> Self {
self.auto.toll_booth_cost = Some(toll_booth_cost);
self
}
/// A penalty applied to the cost when a
/// [toll booth](http://wiki.openstreetmap.org/wiki/Tag:barrier%3Dtoll_booth) is encountered.
///
/// This penalty can be used to create paths that avoid toll roads.
///
/// Default: `0`
pub fn toll_booth_penalty(mut self, toll_booth_penalty: f32) -> Self {
self.auto.toll_booth_penalty = Some(toll_booth_penalty);
self
}
/// A cost applied when entering a ferry.
///
/// This cost is added to the estimated and elapsed times.
///
/// Default: `300` seconds (5 minutes)
pub fn ferry_cost(mut self, ferry_cost: f32) -> Self {
self.auto.ferry_cost = Some(ferry_cost);
self
}
/// This value indicates the willingness to take ferries.
///
/// This is a range of values between `0` and `1`:
/// - Values near `0` attempt to avoid ferries and
/// - values near `1` will favor ferries.
///
/// **Note:** sometimes ferries are required to complete a route so values of `0` are not guaranteed to avoid ferries entirely.
///
/// Default: `0.5`
pub fn use_ferry(mut self, use_ferry: f32) -> Self {
debug_assert!(use_ferry >= 0.0);
debug_assert!(use_ferry <= 1.0);
self.auto.use_ferry = Some(use_ferry);
self
}
/// This value indicates the willingness to take highways.
///
/// This is a range of values between `0` and 1:
/// - Values near `0` attempt to avoid highways and
/// - values near `1` will favor highways.
///
/// **Note:** sometimes highways are required to complete a route so values of `0` are not guaranteed to avoid highways entirely.
///
/// Default: `1.0`
pub fn use_highways(mut self, use_highways: f32) -> Self {
debug_assert!(use_highways >= 0.0);
debug_assert!(use_highways <= 1.0);
self.auto.use_highways = Some(use_highways);
self
}
/// This value indicates the willingness to take roads with tolls.
///
/// This is a range of values between `0` and 1:
/// - Values near `0` attempt to avoid tolls and
/// - values near `1` will not attempt to avoid them.
///
/// **Note:** sometimes roads with tolls are required to complete a route so values of `0` are not guaranteed to avoid them entirely.
///
/// Default: `0.5`
pub fn use_tolls(mut self, use_tolls: f32) -> Self {
debug_assert!(use_tolls >= 0.0);
debug_assert!(use_tolls <= 1.0);
self.auto.use_tolls = Some(use_tolls);
self
}
/// This value indicates the willingness to take living streets.
///
/// This is a range of values between `0` and 1:
/// - Values near `0` attempt to avoid living streets and
/// - values near `1` will favor living streets.
///
/// **Note:** sometimes living streets are required to complete a route so values of `0` are not guaranteed to avoid living streets entirely.
///
/// Default:
/// - `truck`: `0`
/// - `cars`/`buses`/`motor scooters`/`motorcycles`: `0.1`
pub fn use_living_streets(mut self, use_living_streets: f32) -> Self {
debug_assert!(use_living_streets >= 0.0);
debug_assert!(use_living_streets <= 1.0);
self.auto.use_living_streets = Some(use_living_streets);
self
}
/// This value indicates the willingness to take track roads.
///
/// This is a range of values between `0` and 1:
/// - Values near `0` attempt to avoid tracks and
/// - values near `1` will favor tracks a little bit.
///
/// **Note:** sometimes tracks are required to complete a route so values of `0` are not guaranteed to avoid tracks entirely.
///
/// Default:
/// - `0` for autos,
/// - `0.5` for motor scooters and motorcycles.
pub fn use_tracks(mut self, use_tracks: f32) -> Self {
debug_assert!(use_tracks >= 0.0);
debug_assert!(use_tracks <= 1.0);
self.auto.use_tracks = Some(use_tracks);
self
}
/// A penalty applied for transition to generic service road.
///
/// Default:
/// - `0` trucks and
/// - `15` for cars, buses, motor scooters and motorcycles.
pub fn service_penalty(mut self, service_penalty: f32) -> Self {
self.auto.service_penalty = Some(service_penalty);
self
}
/// A factor that modifies (multiplies) the cost when generic service roads are encountered.
///
/// Default: `1`
pub fn service_factor(mut self, service_factor: f32) -> Self {
self.auto.service_factor = Some(service_factor);
self
}
/// A cost applied when encountering an international border.
///
/// This cost is added to the estimated and elapsed times.
///
/// Default: `600` seconds
pub fn country_crossing_cost(mut self, country_crossing_cost: f32) -> Self {
self.auto.country_crossing_cost = Some(country_crossing_cost);
self
}
/// A penalty applied for a country crossing.
///
/// This penalty can be used to create paths that avoid spanning country boundaries.
///
/// Default: `0`
pub fn country_crossing_penalty(mut self, country_crossing_penalty: f32) -> Self {
self.auto.country_crossing_penalty = Some(country_crossing_penalty);
self
}
/// Changes the metric to quasi-shortest, i.e. **purely distance-based costing**.
///
/// Disables ALL other costings & penalties.
/// Also note, shortest will not disable hierarchy pruning, leading to potentially sub-optimal
/// routes for some costing models.
///
/// Default: `false`
pub fn only_consider_quasi_shortest(mut self) -> Self {
self.auto.shortest = Some(true);
self
}
/// A factor that allows controlling the contribution of distance and time to the route costs.
///
/// The value is in range between `0` and 1, where
/// - `0` only takes time into account (default),
/// - `0.5` will weight them roughly equally
/// - `1` only distance.
///
/// **Note:** this costing is currently only available for [`super::Costing::Auto`].
pub fn use_distance(mut self, use_distance: f32) -> Self {
debug_assert!(use_distance >= 0.0);
debug_assert!(use_distance <= 1.0);
self.auto.use_distance = Some(use_distance);
self
}
/// Disable hierarchies to calculate the actual optimal route.
///
/// **Note:** This could be quite a performance drainer so there is an upper limit of distance.
/// If the upper limit is exceeded, this option will always be `false`.
///
/// Default: `false`
pub fn disable_hierarchy_pruning(mut self) -> Self {
self.auto.disable_hierarchy_pruning = Some(true);
self
}
/// Top speed the vehicle can go.
///
/// Also used to avoid roads with higher speeds than this value.
/// Must be between `10` and `252 KPH`.
///
/// Default:
/// - `truck`: `120 KPH`
/// - `auto`/`bus`: `140 KPH`
pub fn top_speed(mut self, top_speed: f32) -> Self {
debug_assert!(top_speed >= 10.0);
debug_assert!(top_speed <= 252.0);
self.auto.top_speed = Some(top_speed);
self
}
/// Fixed speed the vehicle can go. Used to override the calculated speed.
///
/// Can be useful if speed of vehicle is known.
/// Must be between `1` and `252 KPH`.
///
/// Default: `0KPH` which disables fixed speed and falls back to the standard calculated speed
/// based on the road attribution.
pub fn fixed_speed(mut self, fixed_speed: u32) -> Self {
debug_assert!(fixed_speed >= 1);
debug_assert!(fixed_speed <= 252);
self.auto.fixed_speed = Some(fixed_speed);
self
}
/// A factor that penalizes the cost when traversing a closed edge
///
/// Example:
/// If `search_filter.exclude_closures` is `false` for origin and/or destination
/// location and the route starts/ends on closed edges.
///
/// Its value can range from
/// - `1.0` don't penalize closed edges,
/// - to `10.0` apply high cost penalty to closed edges.
///
/// **Note:** This factor is applicable only for motorized modes of transport, i.e `auto`, `motorcycle`, `motor_scooter`, `bus`, `truck` & `taxi`.
///
/// Default: `9.0`
pub fn closure_factor(mut self, closure_factor: f32) -> Self {
self.auto.closure_factor = Some(closure_factor);
self
}
/// If set ignores all closures, marked due to live traffic closures, during routing.
///
/// **Note:** This option cannot be set if `location.search_filter.exclude_closures` is also
/// specified in the request and will return an error if it is
pub fn ignore_closures(mut self) -> Self {
self.auto.ignore_closures = Some(true);
self
}
/// If set, ignores any restrictions (e.g. turn/dimensional/conditional restrictions).
///
/// Especially useful for matching GPS traces to the road network regardless of restrictions.
///
/// Default: `false`
pub fn ignore_restrictions(mut self) -> Self {
self.auto.ignore_restrictions = Some(true);
self
}
/// If set, ignores one-way restrictions.
///
/// Especially useful for matching GPS traces to the road network ignoring uni-directional traffic rules.
/// Not included in [`Self::ignore_restrictions`] option.
///
/// Default: `false`
pub fn ignore_oneways(mut self) -> Self {
self.auto.ignore_oneways = Some(true);
self
}
/// Similar to [`Self::ignore_restrictions`], but will respect restrictions that impact vehicle safety,
/// such as weight and size restrictions.
///
/// Default: `false`
pub fn ignore_non_vehicular_restrictions(mut self) -> Self {
self.auto.ignore_non_vehicular_restrictions = Some(true);
self
}
/// Ignore mode-specific access tags.
///
/// Especially useful for matching GPS traces to the road network regardless of restrictions.
///
/// Default `false`
pub fn ignore_access(mut self) -> Self {
self.auto.ignore_access = Some(true);
self
}
/// Will determine which speed sources are used, if available.
///
/// A list of strings with the following possible values:
/// - [`UsedSpeedSources::All`]
/// - [`UsedSpeedSources::Freeflow`]
/// - [`UsedSpeedSources::Constrained`]
/// - [`UsedSpeedSources::Predicted`]
/// - [`UsedSpeedSources::Current`]
///
/// Default: [`UsedSpeedSources::All`] sources (again, only if available)
pub fn speed_types(mut self, speed_types: UsedSpeedSources) -> Self {
if speed_types == UsedSpeedSources::All {
self.auto.speed_types = None
} else {
self.auto.speed_types = Some(speed_types);
}
self
}
/// The height of the vehicle (in meters).
///
/// Default:
/// - `car`/`bus`/`taxi`: `1.9` and
/// - `truck`: `4.11`
pub fn height(mut self, height: f32) -> Self {
self.auto.height = Some(height);
self
}
/// The width of the vehicle (in meters).
///
/// Default:
/// - `car`/`bus`/`taxi`: `1.6` and
/// - `truck`: `2.6`
pub fn width(mut self, width: f32) -> Self {
self.auto.width = Some(width);
self
}
/// Exclude unpaved roads.
///
/// If exclude_unpaved is set it is allowed to start and end with unpaved roads,
/// but is not allowed to have them in the middle of the route path,
/// otherwise they are allowed.
///
/// Default: `false`.
pub fn exclude_unpaved(mut self) -> Self {
self.auto.exclude_unpaved = Some(true);
self
}
/// Desire to avoid routes with cash-only tolls.
///
/// Default: `false`.
pub fn exclude_cash_only_tolls(mut self, exclude_cash_only_tolls: bool) -> Self {
self.auto.exclude_cash_only_tolls = Some(exclude_cash_only_tolls);
self
}
/// Include HOV roads with a 2-occupant requirement in the route when advantageous.
///
/// Default: `false`.
pub fn include_hov2(mut self, include_hov2: bool) -> Self {
self.auto.include_hov2 = Some(include_hov2);
self
}
/// Include HOV roads with a 3-occupant requirement in the route when advantageous.
///
/// Default: `false`.
pub fn include_hov3(mut self, include_hov3: bool) -> Self {
self.auto.include_hov3 = Some(include_hov3);
self
}
/// Include tolled HOV roads which require the driver to pay a toll if the occupant requirement isn't met.
///
/// Default: `false`.
pub fn include_hot(mut self, include_hot: bool) -> Self {
self.auto.include_hot = Some(include_hot);
self
}
}
#[derive(Serialize, Debug, Clone, Copy, Eq, PartialEq)]
/// Used Speed Sources
pub enum UsedSpeedSources {
#[serde(rename = "all")]
/// All speed sources
All,
#[serde(rename = "freeflow")]
/// Freeflow speed
Freeflow,
#[serde(rename = "constrained")]
/// Constrained speed
Constrained,
#[serde(rename = "predicted")]
/// Predicted speed
Predicted,
#[serde(rename = "current")]
/// Current speed
Current,
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn serialisation() {
assert_eq!(
serde_json::to_value(AutoCostingOptions::default()).unwrap(),
serde_json::json!({"auto":{}})
);
}
#[test]
fn builder_returns_default() {
assert_eq!(AutoCostingOptions::builder(), AutoCostingOptions::default());
}
#[test]
fn gate_cost_sets_value() {
let opts = AutoCostingOptions::builder().gate_cost(45.0);
assert_eq!(opts.auto.gate_cost, Some(45.0));
}
#[test]
fn gate_penalty_sets_value() {
let opts = AutoCostingOptions::builder().gate_penalty(500.0);
assert_eq!(opts.auto.gate_penalty, Some(500.0));
}
#[test]
fn private_access_penalty_sets_value() {
let opts = AutoCostingOptions::builder().private_access_penalty(600.0);
assert_eq!(opts.auto.private_access_penalty, Some(600.0));
}
#[test]
fn destination_only_penalty_sets_value() {
let opts = AutoCostingOptions::builder().destination_only_penalty(100.0);
assert_eq!(opts.auto.destination_only_penalty, Some(100.0));
}
#[test]
fn toll_booth_cost_sets_value() {
let opts = AutoCostingOptions::builder().toll_booth_cost(20.0);
assert_eq!(opts.auto.toll_booth_cost, Some(20.0));
}
#[test]
fn toll_booth_penalty_sets_value() {
let opts = AutoCostingOptions::builder().toll_booth_penalty(250.0);
assert_eq!(opts.auto.toll_booth_penalty, Some(250.0));
}
#[test]
fn ferry_cost_sets_value() {
let opts = AutoCostingOptions::builder().ferry_cost(400.0);
assert_eq!(opts.auto.ferry_cost, Some(400.0));
}
#[test]
fn use_ferry_sets_value() {
let opts = AutoCostingOptions::builder().use_ferry(0.5);
assert_eq!(opts.auto.use_ferry, Some(0.5));
}
#[test]
fn use_highways_sets_value() {
let opts = AutoCostingOptions::builder().use_highways(0.8);
assert_eq!(opts.auto.use_highways, Some(0.8));
}
#[test]
fn use_tolls_sets_value() {
let opts = AutoCostingOptions::builder().use_tolls(0.3);
assert_eq!(opts.auto.use_tolls, Some(0.3));
}
#[test]
fn use_living_streets_sets_value() {
let opts = AutoCostingOptions::builder().use_living_streets(0.6);
assert_eq!(opts.auto.use_living_streets, Some(0.6));
}
#[test]
fn use_tracks_sets_value() {
let opts = AutoCostingOptions::builder().use_tracks(0.2);
assert_eq!(opts.auto.use_tracks, Some(0.2));
}
#[test]
fn service_penalty_sets_value() {
let opts = AutoCostingOptions::builder().service_penalty(10.0);
assert_eq!(opts.auto.service_penalty, Some(10.0));
}
#[test]
fn service_factor_sets_value() {
let opts = AutoCostingOptions::builder().service_factor(1.5);
assert_eq!(opts.auto.service_factor, Some(1.5));
}
#[test]
fn country_crossing_cost_sets_value() {
let opts = AutoCostingOptions::builder().country_crossing_cost(600.0);
assert_eq!(opts.auto.country_crossing_cost, Some(600.0));
}
#[test]
fn country_crossing_penalty_sets_value() {
let opts = AutoCostingOptions::builder().country_crossing_penalty(0.0);
assert_eq!(opts.auto.country_crossing_penalty, Some(0.0));
}
#[test]
fn use_distance_sets_value() {
let opts = AutoCostingOptions::builder().use_distance(0.9);
assert_eq!(opts.auto.use_distance, Some(0.9));
}
#[test]
fn disable_hierarchy_pruning_sets_value() {
let opts = AutoCostingOptions::builder().disable_hierarchy_pruning();
assert_eq!(opts.auto.disable_hierarchy_pruning, Some(true));
}
#[test]
fn only_consider_quasi_shortest_sets_value() {
let opts = AutoCostingOptions::builder().only_consider_quasi_shortest();
assert_eq!(opts.auto.shortest, Some(true));
}
#[test]
fn top_speed_sets_value() {
let opts = AutoCostingOptions::builder().top_speed(120.0);
assert_eq!(opts.auto.top_speed, Some(120.0));
}
#[test]
fn fixed_speed_sets_value() {
let opts = AutoCostingOptions::builder().fixed_speed(80);
assert_eq!(opts.auto.fixed_speed, Some(80));
}
#[test]
fn closure_factor_sets_value() {
let opts = AutoCostingOptions::builder().closure_factor(5.0);
assert_eq!(opts.auto.closure_factor, Some(5.0));
}
#[test]
fn ignore_closures_sets_value() {
let opts = AutoCostingOptions::builder().ignore_closures();
assert_eq!(opts.auto.ignore_closures, Some(true));
}
#[test]
fn ignore_restrictions_sets_value() {
let opts = AutoCostingOptions::builder().ignore_restrictions();
assert_eq!(opts.auto.ignore_restrictions, Some(true));
}
#[test]
fn ignore_oneways_sets_value() {
let opts = AutoCostingOptions::builder().ignore_oneways();
assert_eq!(opts.auto.ignore_oneways, Some(true));
}
#[test]
fn ignore_non_vehicular_restrictions_sets_value() {
let opts = AutoCostingOptions::builder().ignore_non_vehicular_restrictions();
assert_eq!(opts.auto.ignore_non_vehicular_restrictions, Some(true));
}
#[test]
fn ignore_access_sets_value() {
let opts = AutoCostingOptions::builder().ignore_access();
assert_eq!(opts.auto.ignore_access, Some(true));
}
#[test]
fn speed_types_sets_value() {
let opts = AutoCostingOptions::builder().speed_types(UsedSpeedSources::Freeflow);
assert_eq!(opts.auto.speed_types, Some(UsedSpeedSources::Freeflow));
}
#[test]
fn height_sets_value() {
let opts = AutoCostingOptions::builder().height(3.5);
assert_eq!(opts.auto.height, Some(3.5));
}
#[test]
fn width_sets_value() {
let opts = AutoCostingOptions::builder().width(2.5);
assert_eq!(opts.auto.width, Some(2.5));
}
#[test]
fn exclude_unpaved_sets_value() {
let opts = AutoCostingOptions::builder().exclude_unpaved();
assert_eq!(opts.auto.exclude_unpaved, Some(true));
}
#[test]
fn exclude_cash_only_tolls_sets_value() {
let opts = AutoCostingOptions::builder().exclude_cash_only_tolls(true);
assert_eq!(opts.auto.exclude_cash_only_tolls, Some(true));
}
#[test]
fn include_hov2_sets_value() {
let opts = AutoCostingOptions::builder().include_hov2(true);
assert_eq!(opts.auto.include_hov2, Some(true));
}
#[test]
fn include_hov3_sets_value() {
let opts = AutoCostingOptions::builder().include_hov3(true);
assert_eq!(opts.auto.include_hov3, Some(true));
}
#[test]
fn include_hot_sets_value() {
let opts = AutoCostingOptions::builder().include_hot(true);
assert_eq!(opts.auto.include_hot, Some(true));
}
#[test]
fn chaining_works() {
let opts = AutoCostingOptions::builder()
.gate_cost(45.0)
.use_highways(0.8)
.top_speed(120.0);
assert_eq!(opts.auto.gate_cost, Some(45.0));
assert_eq!(opts.auto.use_highways, Some(0.8));
assert_eq!(opts.auto.top_speed, Some(120.0));
}
}