Refactor dummy MapConfig constructor

This commit is contained in:
Dustin Carlino 2022-07-06 17:58:43 +01:00
parent bafbb58eb9
commit f09c88a244
6 changed files with 20 additions and 28 deletions

View File

@ -46,15 +46,7 @@ pub struct Options {
impl Options {
pub fn default_for_side(driving_side: raw_map::DrivingSide) -> Self {
Self {
map_config: MapConfig {
driving_side,
bikes_can_use_bus_lanes: true,
inferred_sidewalks: true,
street_parking_spot_length: Distance::meters(8.0),
turn_on_red: true,
find_dog_legs_experiment: false,
merge_osm_ways: Vec::new(),
},
map_config: MapConfig::default_for_side(driving_side),
onstreet_parking: OnstreetParking::JustOSM,
public_offstreet_parking: PublicOffstreetParking::None,
private_offstreet_parking: PrivateOffstreetParking::FixedPerBldg(1),

View File

@ -20,7 +20,7 @@ pub fn config_for_map(name: &MapName) -> convert_osm::Options {
};
convert_osm::Options {
map_config: map_model::MapConfig {
map_config: street_network::MapConfig {
driving_side: match name.city.country.as_ref() {
"au" | "gb" | "in" | "jp" | "nz" | "sg" => DrivingSide::Left,
_ => DrivingSide::Right,

View File

@ -146,15 +146,7 @@ impl Map {
traffic_signals: BTreeMap::new(),
gps_bounds: GPSBounds::new(),
bounds: Bounds::new(),
config: MapConfig {
driving_side: DrivingSide::Right,
bikes_can_use_bus_lanes: true,
inferred_sidewalks: true,
street_parking_spot_length: Distance::meters(8.0),
turn_on_red: true,
find_dog_legs_experiment: false,
merge_osm_ways: Vec::new(),
},
config: MapConfig::default_for_side(DrivingSide::Right),
pathfinder: Pathfinder::empty(),
pathfinder_dirty: false,
routing_params: RoutingParams::default(),

View File

@ -556,6 +556,8 @@ mod tests {
inferred_sidewalks: true,
street_parking_spot_length: geom::Distance::meters(8.0),
turn_on_red: true,
find_dog_legs_experiment: false,
merge_osm_ways: Vec::new(),
};
let actual = get_lane_specs_ltr(&tags(input.clone()), &cfg);
let actual_lt: String = actual.iter().map(|s| s.lt.to_char()).collect();

View File

@ -124,15 +124,7 @@ impl StreetNetwork {
// Some nonsense thing
boundary_polygon: Polygon::rectangle(1.0, 1.0),
gps_bounds: GPSBounds::new(),
config: MapConfig {
driving_side: DrivingSide::Right,
bikes_can_use_bus_lanes: true,
inferred_sidewalks: true,
street_parking_spot_length: Distance::meters(8.0),
turn_on_red: true,
find_dog_legs_experiment: false,
merge_osm_ways: Vec::new(),
},
config: MapConfig::default_for_side(DrivingSide::Right),
}
}

View File

@ -104,6 +104,20 @@ pub struct MapConfig {
pub merge_osm_ways: Vec<OriginalRoad>,
}
impl MapConfig {
pub fn default_for_side(driving_side: DrivingSide) -> Self {
Self {
driving_side,
bikes_can_use_bus_lanes: true,
inferred_sidewalks: true,
street_parking_spot_length: Distance::meters(8.0),
turn_on_red: true,
find_dog_legs_experiment: false,
merge_osm_ways: Vec::new(),
}
}
}
#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
pub enum DrivingSide {
Right,