osmgraphing 0.12.0

Playing around with graphs created via parsing OpenStreetMap data
Documentation
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
pub mod accuracy {
    /// value is good because it refers to
    /// - 1 mm for km
    /// - 1 µs for s
    /// - 60 µs for min
    /// - 3.6 ms for hour
    /// - lat/lon
    ///   - lat: 1/60 ~ 0.0167 degrees equals 1_852 m
    ///     -> 1e-6 degrees equals around 0.11 m
    ///   - lon: distance depends on latitude
    ///     -> 1e-6 degrees equals <= 0.11 m (equator)
    ///   -> 1e-5 degrees points to a person in a room, see https://xkcd.com/2170/
    pub const F64_ABS: f64 = 0.000_001; // = 10^(-F64__FMT_DIGITS)
    pub const F64_FMT_DIGITS: usize = 6;
}

pub mod distance {
    pub type TYPE = crate::units::distance::Kilometers;
}

pub mod time {
    pub type TYPE = crate::units::time::Minutes;
}

pub mod speed {
    pub type TYPE = crate::units::speed::KilometersPerHour;
    pub const MAX_KMH: u16 = 130;
    pub const MIN_KMH: u8 = 5;
}

pub mod capacity {
    // For optimal performance and memory-usage:
    // Change this value before compiling, dependent of your number of stored metrics in the graph.
    pub const SMALL_VEC_INLINE_SIZE: usize = 4;
    pub type DimVec<T> = smallvec::SmallVec<[T; SMALL_VEC_INLINE_SIZE]>;
    pub const MAX_BYTE_PER_CHUNK: usize = 200 * 1_000_000;
}

pub mod parser {
    // provided by multi-ch-constructor
    pub const NO_SHORTCUT_IDX: &str = "-1";
}

pub mod generator {
    pub use super::parser::NO_SHORTCUT_IDX;
}

pub mod routing {
    pub const ALPHA: f64 = 1.0;
}

pub mod network {
    use crate::{
        defaults,
        network::{StreetCategory, VehicleCategory},
        units::speed::KilometersPerHour,
    };
    use log::warn;
    use osmpbfreader::Way;
    use std::{cmp::max, fmt, fmt::Display, str::FromStr};

    impl StreetCategory {
        fn lane_count(&self) -> u8 {
            match self {
                StreetCategory::Motorway => 3,
                StreetCategory::MotorwayLink => 1,
                StreetCategory::Trunk => 2,
                StreetCategory::TrunkLink => 1,
                StreetCategory::Primary => 2,
                StreetCategory::PrimaryLink => 1,
                StreetCategory::Secondary => 1,
                StreetCategory::SecondaryLink => 1,
                StreetCategory::Tertiary => 1,
                StreetCategory::TertiaryLink => 1,
                StreetCategory::Unclassified => 1,
                StreetCategory::Residential => 1,
                StreetCategory::LivingStreet => 1,
                StreetCategory::Service => 1,
                StreetCategory::Track => 1,
                StreetCategory::Road => 1,
                StreetCategory::Cycleway => 1,
                StreetCategory::Pedestrian => 1,
                StreetCategory::Path => 1,
            }
        }

        fn maxspeed(&self) -> KilometersPerHour {
            KilometersPerHour(match self {
                StreetCategory::Motorway => 130,
                StreetCategory::MotorwayLink => 50,
                StreetCategory::Trunk => 100,
                StreetCategory::TrunkLink => 50,
                StreetCategory::Primary => 100,
                StreetCategory::PrimaryLink => 30,
                StreetCategory::Secondary => 70,
                StreetCategory::SecondaryLink => 30,
                StreetCategory::Tertiary => 70,
                StreetCategory::TertiaryLink => 30,
                StreetCategory::Unclassified => 50,
                StreetCategory::Residential => 50,
                StreetCategory::LivingStreet => 15,
                StreetCategory::Service => 20,
                StreetCategory::Track => 30,
                StreetCategory::Road => 50,
                StreetCategory::Cycleway => 25,
                StreetCategory::Pedestrian => 5,
                StreetCategory::Path => 15,
            } as f64)
        }

        pub fn is_for(&self, vehicle_category: &VehicleCategory, is_driver_picky: bool) -> bool {
            match vehicle_category {
                VehicleCategory::Car => self.is_for_vehicles(is_driver_picky),
                VehicleCategory::Bicycle => self.is_for_bicycles(is_driver_picky),
                VehicleCategory::Pedestrian => self.is_for_pedestrians(is_driver_picky),
            }
        }

        fn is_for_vehicles(&self, is_driver_picky: bool) -> bool {
            match self {
                StreetCategory::Motorway => true,
                StreetCategory::MotorwayLink => true,
                StreetCategory::Trunk => true,
                StreetCategory::TrunkLink => true,
                StreetCategory::Primary => true,
                StreetCategory::PrimaryLink => true,
                StreetCategory::Secondary => true,
                StreetCategory::SecondaryLink => true,
                StreetCategory::Tertiary => true,
                StreetCategory::TertiaryLink => true,
                StreetCategory::Unclassified => true,
                StreetCategory::Residential => true,
                StreetCategory::LivingStreet => true,
                StreetCategory::Service => !is_driver_picky,
                StreetCategory::Track => !is_driver_picky,
                StreetCategory::Road => !is_driver_picky,
                StreetCategory::Cycleway => false,
                StreetCategory::Pedestrian => false,
                StreetCategory::Path => false,
            }
        }

        fn is_for_bicycles(&self, is_driver_picky: bool) -> bool {
            match self {
                StreetCategory::Motorway => false,
                StreetCategory::MotorwayLink => false,
                StreetCategory::Trunk => false,
                StreetCategory::TrunkLink => false,
                StreetCategory::Primary => !is_driver_picky,
                StreetCategory::PrimaryLink => !is_driver_picky,
                StreetCategory::Secondary => !is_driver_picky,
                StreetCategory::SecondaryLink => !is_driver_picky,
                StreetCategory::Tertiary => true,
                StreetCategory::TertiaryLink => true,
                StreetCategory::Unclassified => true,
                StreetCategory::Residential => true,
                StreetCategory::LivingStreet => true,
                StreetCategory::Service => true,
                StreetCategory::Track => !is_driver_picky,
                StreetCategory::Road => !is_driver_picky,
                StreetCategory::Cycleway => true,
                StreetCategory::Pedestrian => !is_driver_picky,
                StreetCategory::Path => !is_driver_picky,
            }
        }

        fn is_for_pedestrians(&self, is_driver_picky: bool) -> bool {
            match self {
                StreetCategory::Motorway => false,
                StreetCategory::MotorwayLink => false,
                StreetCategory::Trunk => false,
                StreetCategory::TrunkLink => false,
                StreetCategory::Primary => false,
                StreetCategory::PrimaryLink => false,
                StreetCategory::Secondary => false,
                StreetCategory::SecondaryLink => false,
                StreetCategory::Tertiary => false,
                StreetCategory::TertiaryLink => false,
                StreetCategory::Unclassified => false,
                StreetCategory::Residential => true,
                StreetCategory::LivingStreet => true,
                StreetCategory::Service => true,
                StreetCategory::Track => true,
                StreetCategory::Road => !is_driver_picky,
                StreetCategory::Cycleway => false,
                StreetCategory::Pedestrian => true,
                StreetCategory::Path => true,
            }
        }

        //--------------------------------------------------------------------------------------------//
        // parsing

        pub fn from(way: &Way) -> Option<StreetCategory> {
            // read highway-tag from way
            way.tags.get("highway").and_then(|highway_tag_value| {
                // and parse the value if valid
                match format!("highway:{}", highway_tag_value).parse::<StreetCategory>() {
                    Ok(highway_tag) => Some(highway_tag),
                    Err(is_unknown) => {
                        if is_unknown {
                            warn!(
                                "Unknown highway-tag `highway:{}` of way-id `{}` -> ignored",
                                highway_tag_value, way.id.0
                            );
                        }
                        None
                    }
                }
            })
        }

        pub fn parse_lane_count(&self, _way: &Way) -> u8 {
            // TODO parse lanes
            self.lane_count()
        }

        pub fn parse_maxspeed(&self, way: &Way) -> KilometersPerHour {
            let snippet = match way.tags.get("maxspeed") {
                Some(snippet) => snippet,
                None => return self.maxspeed(),
            };

            // parse given maxspeed and return
            match snippet.parse::<u16>() {
                Ok(maxspeed) => {
                    KilometersPerHour(max(defaults::speed::MIN_KMH.into(), maxspeed) as f64)
                }
                Err(_) => match snippet.trim().to_ascii_lowercase().as_ref() {
                    // motorway
                    "de:motorway"
                    => StreetCategory::Motorway.maxspeed(),
                    // 100 kmh
                    | "100, 70" // way-id: 319046425
                    | "100; 50" // way-id: 130880229
                    | "100;70;50" // way-id: 313097404
                    | "100;70" // way-id: 130006647
                    | "100;80" // way-id: 161216768
                    | "100|70" // way-id: 118245446
                    | "50; 100" // way-id: 152374728
                    | "50;100" // way-id: 266299302
                    | "60 mph"
                    => KilometersPerHour(100.0),
                    // 80 kmh
                    | "50 mph"
                    | "60;80" // way-id: 24441573
                    | "80;60" // way-id: 25154358
                    => KilometersPerHour(80.0),
                    // 70 kmh
                    "70; 50" // way-id: 260835537
                    | "50;70" // way-id: 48581258
                    | "50; 70" // way-id: 20600128
                    | "40 mph"
                    => KilometersPerHour(70.0),
                    // 60 kmh
                    "60;50" // way-id: 48453714
                    => KilometersPerHour(60.0),
                    // 50 kmh
                    | "20; 50" // way-id: 308645778
                    | "30 mph"
                    | "30,50" // way-id: 28293340
                    | "30; 50" // way-id: 305677124
                    | "30;50" // way-id: 4954059
                    | "50; 30" // way-id: 28494183
                    | "50;30" // way-id: 25616305
                    | "50b"
                    | "" // way-id: 8367325
                    | "de:urban" // way-id: 111446158
                    | "maxspeed=50"
                    => KilometersPerHour(50.0),
                    // 30 kmh
                    | "20 mph"
                    | "30 @ (mo-fr 06:00-18:00)" // way-id: 558224330
                    | "30 kph"
                    | "30;10" // way-id: 111450904
                    | "30; 40" // way-id: 28311529
                    | "" // way-id: 4045417
                    | "conditional=30 @ (mo-fr 06:00-22:00)" // way-id: 612333030
                    | "de:zone:30" // way-id: 32657912
                    | "de:zone30"
                    | "zone:maxspeed=de:30" // way-id: 26521170
                    => KilometersPerHour(30.0),
                    // 25 kmh
                    "15 mph"
                    => KilometersPerHour(25.0),
                    // 20 kmh
                    ""
                    => KilometersPerHour(20.0),
                    // bicycle
                    "de:bicycle_road"
                    => StreetCategory::Cycleway.maxspeed(),
                    // walk (<= 15 kmh)
                    | "10 mph"
                    | "10#" // way-id: 301985410
                    | ""
                    | "3 mph"
                    | "4-6"
                    | "4-7"
                    | "5 mph"
                    | "6 km/h" // way-id: 60066367
                    | "6,5" // way-id: 27172163
                    | "7-10" // way-id: 60805930
                    | "de:living_street"
                    | "de:walk"
                    | "schrittgeschwindigkeit" // way-id: 212487477
                    | "walk"
                    => StreetCategory::LivingStreet.maxspeed(),
                    // known defaults/weirdos
                    | "*" // way-id: 4682329
                    | "20:forward" // way-id: 24215081
                    | "30+" // way-id: 87765739
                    | "at:rural" // way-id: 23622533
                    | "at:urban" // way-id: 30504860
                    | "cz:urban" // way-id: 683729581
                    | "de:274.1[30]" // way-id: 458676403
                    | "de:rural" // way-id: 15558598
                    | "de" // way-id: 180794115
                    | "fixme:höchster üblicher wert" // way-id: 8036120
                    | "hgv=30" // way-id: 33172848
                    | "nome" // way-id: 67659840
                    | "none" // way-id: 3061397
                    | "posted time dependent" // way-id: 168135218
                    | "signal" // way-id: 189189059
                    | "signals" // way-id: 3996833
                    | "variable" // way-id: 461169632
                    => self.maxspeed(),
                    // unknown
                    _ => {
                        warn!(
                            "Unknown maxspeed `{}` of way-id `{}` -> default: (`{}`,`{}`)",
                            snippet,
                            way.id.0,
                            self,
                            self.maxspeed()
                        );
                        self.maxspeed()
                    }
                },
            }
        }

        /// return (is_oneway, is_reverse)
        pub fn parse_oneway(&self, way: &Way) -> (bool, bool) {
            let is_oneway = true;
            let is_reverse = true;

            match way.tags.get("oneway") {
                Some(oneway_value) => {
                    match oneway_value.trim().to_ascii_lowercase().as_ref() {
                        // yes
                        | "1"
                        | "left;through" // way-id: 679817792
                        | "motor_vehicle" // way-id: 172676596
                        | "recommended" // way-id: 38250792
                        | "shelter" // way-id: 680612616
                        | "use_sidepath" // way-id: 3701112
                        | "yes + oneway:bicycle=no" // way-id: 25013800
                        | "yes"
                        => (is_oneway, !is_reverse),
                        // yes but reverse
                        | "´-1" // way-id: 721848168
                        | "-1"
                        | "-1;no" // way-id: 180680762
                        => (is_oneway, is_reverse),
                        // no
                        | "alternating" // way-id: 5051072
                        | "bicycle" // way-id: 25596393
                        | "cycle_barrier" // way-id: 691452957
                        | "fixme" // way-id: 199388177
                        | "no"
                        | "reversible" // way-id: 4005347
                        | "undefined" // way-id: 331847642
                        | "unknown" // way-id: 380885551
                        | "yes @ (2018 aug 0 - 2018 dec 21)" // way-id: 24379239
                        | "yes;no" // way-id: 158249443
                        => (!is_oneway, !is_reverse),
                        // unknown or unhandled
                        _ => {
                            warn!(
                                "Unknown oneway `{}` of way-id `{}` -> default: `oneway=no`",
                                oneway_value, way.id.0
                            );
                            (!is_oneway, !is_reverse)
                        }
                    }
                }
                None => (!is_oneway, !is_reverse),
            }
        }
    }

    impl FromStr for StreetCategory {
        type Err = bool;

        fn from_str(s: &str) -> Result<StreetCategory, bool> {
            let is_unknown = true;
            match s.trim().to_ascii_lowercase().as_ref() {
                // known and used
                | "highway:motorway"
                => Ok(StreetCategory::Motorway),
                | "highway:motorway_link"
                => Ok(StreetCategory::MotorwayLink),
                | "highway:trunk"
                => Ok(StreetCategory::Trunk),
                | "highway:trunk_link"
                => Ok(StreetCategory::TrunkLink),
                | "highway:primary"
                => Ok(StreetCategory::Primary),
                | "highway:primary_link"
                => Ok(StreetCategory::PrimaryLink),
                | "highway:secondary"
                => Ok(StreetCategory::Secondary),
                | "highway:secondary_link"
                => Ok(StreetCategory::SecondaryLink),
                | "highway:tertiary"
                => Ok(StreetCategory::Tertiary),
                | "highway:tertiary_link"
                | "highway:traffic_calming" // way-id: 746304770
                | "highway:unclassified_link" // way-id: 460413095
                => Ok(StreetCategory::TertiaryLink),
                | "highway:give_way" // way-id: 61580672
                | "highway:unclassified"
                | "highway:unclasified" // way-id: 71428454
                => Ok(StreetCategory::Unclassified),
                | "highway:area:residential" // way-id: 36986745
                | "highway:asphalt" // way-id: 773144688
                | "highway:junction" // way-id: 589935900
                | "highway:mini_roundabout" // way-id: 745748272
                | "highway:residential"
                => Ok(StreetCategory::Residential),
                | "highway:living_street"
                => Ok(StreetCategory::LivingStreet),
                | "highway:razed:service" // way-id: 415355747
                | "highway:service;yes" // way-id: 170702046
                | "highway:service"
                | "highway:sevice" // way-id: 557625537
                | "highway:service2" // way-id: 553698179
                | "highway:swervice" // way-id: 551728065
                => Ok(StreetCategory::Service),
                | "highway:byway" // way-id: 29881284
                | "highway:historic" // way-id: 192265844
                | "highway:path;unclassified" // way-id: 38480982
                | "highway:tra#" // way-id: 721881475
                | "highway:track"
                | "highway:track;path" // way-id: 640616710
                | "highway:trank" // way-id: 685079101
                | "highway:track; cycleway; cycleway; track; track" // way-id: 128073314
                => Ok(StreetCategory::Track),
                | "highway:4" // way-id: 23128594545
                | "highway:bridge" // way-id: 696697784
                | "highway:fixme" // way-id: 371216260
                | "highway:parking_aisle" // way-id: 552156572
                | "highway:road"
                | "highway:yes" // way-id: 684234513
                => Ok(StreetCategory::Road),
                | "highway:cycleway"
                | "highway:bridleway" // way-id: 3617168
                => Ok(StreetCategory::Cycleway),
                | "highway:access_ramp" // way-id: 24975340
                | "highway:access" // way-id: 357086739
                | "highway:alley" // way-id: 24453717
                | "highway:corridor" // way-id: 210464225
                | "highway:crossing" // way-id: 679590652
                | "highway:elevator" // way-id: 166960177
                | "highway:footpath" // way-id: 306304178
                | "highway:footway rad frei" // way-id: 45786636
                | "highway:footway;service" // way-id: 245106042
                | "highway:footway"
                | "highway:fo" // way-id: 558233034
                | "highway:f" // way-id: 562267514
                | "highway:pa" // way-id: 193668915
                | "highway:pedestrian"
                | "highway:private_footway" // way-id: 61557441
                | "highway:ramp" // way-id: 60561495
                | "highway:schoolyard" // way-id: 254357487
                | "highway:sidewalk" // way-id: 492983410
                | "highway:stairs" // way-id: 698856376
                | "highway:steps"
                | "highway:trail" // way-id: 606170671
                | "highway:virtual" // way-id: 612194863
                | "highway:vitrual" // way-id: 699685919
                | "highway:yes;footway" // way-id: 634213443
                => Ok(StreetCategory::Pedestrian),
                | "highway:informal_path" // way-id: 27849992
                | "highway:ladder" // way-id: 415352091
                | "highway:path---" // way-id: 753671939
                | "highway:path;steps" // way-id: 768826568
                | "highway:path"
                | "highway:path/cycleway" // way-id: 152848247
                | "highway:pathless" // way-id: 529231499
                => Ok(StreetCategory::Path),
                // ignored
                | "highway:85" // way-id: 28682800
                | "highway:abondoned" // way-id: 550607106
                | "highway:abandoned:highway" // way-id: 243670918
                | "highway:abandoned:path" // way-id: 659187494
                | "highway:abandoned:service" // way-id: 668073809
                | "highway:abandoned" // way-id: 551167806
                | "highway:bus_guideway" // way-id: 659097872
                | "highway:bus_stop" // way-id: 551048594
                | "highway:bus" // way-id: 653176966
                | "highway:busway" // way-id: 26178605
                | "highway:centre_line" // way-id: 131730185
                | "highway:climbing_access" // way-id: 674680967
                | "highway:common" // way-id: 680432920
                | "highway:under construction" // way-id: 557005264
                | "highway:construction" // way-id: 23692144
                | "highway:constuction" // way-id: 40101546
                | "highway:demolished" // way-id: 146859260
                | "highway:dismantled" // way-id: 138717422
                | "highway:disused:track" // way-id: 660999751
                | "highway:disused" // way-id: 4058936
                | "highway:duckboards" // way-id: 121884826
                | "highway:emergency_access_point" // way-id: 124039649
                | "highway:emergency_bay" // way-id: 510872933
                | "highway:escalator" // way-id: 49542657
                | "highway:escape" // way-id: 166519327
                | "highway:foot" // way-id: 675407702
                | "highway:fuel" // way-id: 385074661
                | "highway:in planung" // way-id: 713888400
                | "highway:island" // way-id: 670953148
                | "highway:layby" // way-id: 171879602
                | "highway:loading_place" // way-id: 473983427
                | "highway:lohwiese" // way-id: 699398300
                | "highway:never_built" // way-id: 310787147
                | "highway:nicht mehr in benutzung" // way-id: 477193801
                | "highway:no" // way-id: 23605191
                | "highway:none" // way-id: 144657573
                | "highway:p" // way-id: 279099565
                | "highway:passing_place" // way-id: 678674065
                | "highway:piste" // way-id: 299032574
                | "highway:place" // way-id: 228745170
                | "highway:planned" // way-id: 509400222
                | "highway:platform" // way-id: 552088750
                | "highway:private" // way-id: 707015329
                | "highway:project" // way-id: 698166909
                | "highway:projected" // way-id: 698166910
                | "highway:proposed" // way-id: 23551790
                | "highway:raceway" // way-id: 550503761
                | "highway:razed" // way-id: 23653804
                | "highway:removed" // way-id: 667029512
                | "highway:rest_area" // way-id: 23584797
                | "highway:ser" // way-id: 27215798
                | "highway:sere" // way-id: 167276926
                | "highway:services" // way-id: 111251693
                | "highway:stop_line" // way-id: 569603293
                | "highway:stop" // way-id: 669234427
                | "highway:street_lamp" // way-id: 614573217
                | "highway:tidal_path" // way-id: 27676473
                | "highway:traffic_island" // way-id: 263644518
                | "highway:traffic_signals" // way-id: 300419851
                | "highway:turning_circle" // way-id: 669184618
                | "highway:turning_loop" // way-id: 31516941
                | "highway:unused" // way-id: 37888214
                | "highway:via_ferrata" // way-id: 23939968
                | "highway:virtual_rail" // way-id: 772152425
                => Err(!is_unknown),
                // unknown
                _ => Err(is_unknown),
            }
        }
    }

    impl Display for StreetCategory {
        fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
            write!(
                f,
                "{}",
                match &self {
                    StreetCategory::Motorway => "motorway",
                    StreetCategory::MotorwayLink => "motorway_link",
                    StreetCategory::Trunk => "trunk",
                    StreetCategory::TrunkLink => "trunk_link",
                    StreetCategory::Primary => "primary",
                    StreetCategory::PrimaryLink => "primary_link",
                    StreetCategory::Secondary => "secondary",
                    StreetCategory::SecondaryLink => "secondary_link",
                    StreetCategory::Tertiary => "tertiary",
                    StreetCategory::TertiaryLink => "tertiary_link",
                    StreetCategory::Unclassified => "unclassified",
                    StreetCategory::Residential => "residential",
                    StreetCategory::LivingStreet => "living_street",
                    StreetCategory::Service => "service",
                    StreetCategory::Track => "track",
                    StreetCategory::Road => "road",
                    StreetCategory::Cycleway => "cycleway",
                    StreetCategory::Pedestrian => "pedestrian",
                    StreetCategory::Path => "path",
                }
            )
        }
    }
}