use serde::{Deserialize, Serialize};
use strum::{AsRefStr, Display, EnumString};
use routers_network::edge::Weight;
#[derive(
Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash, Display, EnumString, AsRefStr,
)]
#[strum(serialize_all = "snake_case")]
#[repr(u8)]
pub enum RoadClass {
Motorway,
Trunk,
Primary,
Secondary,
Tertiary,
Unclassified,
Residential,
LivingStreet,
Service,
Pedestrian,
Footway,
Steps,
Path,
Track,
Cycleway,
Bridleway,
Unknown,
}
impl RoadClass {
#[inline]
pub const fn navigable(&self) -> bool {
use RoadClass::*;
matches!(
self,
Motorway
| Trunk
| Primary
| Secondary
| Tertiary
| Unclassified
| Residential
| LivingStreet
| Service
)
}
#[inline]
pub const fn weighting(&self) -> Weight {
use RoadClass::*;
match self {
Motorway => 1,
Trunk => 3,
Primary => 5,
Secondary => 7,
Tertiary => 9,
Unclassified => 10,
Residential => 10,
LivingStreet => 50,
Service => 50,
Pedestrian | Footway | Steps | Path | Track | Cycleway | Bridleway | Unknown => 100,
}
}
}