diff --git a/src/cjunction.rs b/src/cjunction.rs index 116db14..bae9c50 100644 --- a/src/cjunction.rs +++ b/src/cjunction.rs @@ -346,6 +346,8 @@ pub fn bake(roots: &crate::install::Roots, layout: &Layout, assets: &mut Assets, std::fs::create_dir_all(dir.join("texture"))?; // the plate between the arms: the roadway, kerbs and footways, with its lanes let mut plate_paths = String::new(); + let mut plate_bus_paths = Vec::new(); + let mut plate_path_count = 0; let asphalt = crate::junction::asphalt_texture(&roots.omsi); for arms in &resolved.plates { for a in arms { @@ -353,6 +355,8 @@ pub fn bake(roots: &crate::install::Roots, layout: &Layout, assets: &mut Assets, } let plate = crate::junction::layout_plate(assets, arms, asphalt.as_deref()).ok_or_else(|| anyhow::anyhow!("{}", tr("the plate could not be made from these arms", "плиту не удалось построить из этих въездов")))?; joined.append(&plate.model_mesh(&mut src.model.materials, &mut textures), 0); + plate_bus_paths.extend(plate.bus_paths.iter().map(|i| i + plate_path_count)); + plate_path_count += plate.lanes.len(); plate_paths.push_str(&plate.paths); } for piece in resolved.pieces.iter().filter(|p| !p.hidden) { @@ -377,6 +381,9 @@ pub fn bake(roots: &crate::install::Roots, layout: &Layout, assets: &mut Assets, let mut cut = layout.clone(); cut.pieces = resolved.pieces.clone(); src.extra = extra_lines(&cut, &|f| models.get(&f.to_lowercase()).cloned()); + let preceding_paths = src.extra.lines().filter(|line| line.trim() == "[path]").count(); + let indices: Vec<_> = plate_bus_paths.into_iter().map(|i| i + preceding_paths).collect(); + src.extra.push_str(&crate::junction::bus_path_metadata(&indices)); src.extra.push_str(&plate_paths); for (name, path) in &textures { let _ = name; diff --git a/src/ed_cjunction.rs b/src/ed_cjunction.rs index 9910213..724856a 100644 --- a/src/ed_cjunction.rs +++ b/src/ed_cjunction.rs @@ -56,14 +56,15 @@ impl Editor { let folder = crate::junction::folder_name(doc); let asphalt = crate::junction::junction_asphalt(Some(&doc.dir), asphalt.as_deref()); for arms in &resolved.plates { - let plate = crate::junction::layout_plate(assets, arms, asphalt.as_deref()); - let Some(rel) = plate.and_then(|p| p.write_object(&content, &folder).ok()) else { continue }; + let Some(plate) = crate::junction::layout_plate(assets, arms, asphalt.as_deref()) else { continue }; + let rules = crate::junction::bus_path_rules(&plate.bus_paths); + let Ok(rel) = plate.write_object(&content, &folder) else { continue }; let k = tile_of(origin); if doc.tiles.contains_key(&k) { let id = doc.new_id(); let org = tile_origin(k); let Some(t) = doc.tiles.get_mut(&k) else { return }; - t.tile.objects.push(MapObject { file: rel, id, pos: [origin.x - org.x, origin.y - org.y, z], rot: [rot, 0.0, 0.0], ..Default::default() }); + t.tile.objects.push(MapObject { file: rel, id, pos: [origin.x - org.x, origin.y - org.y, z], rot: [rot, 0.0, 0.0], rules, ..Default::default() }); t.touch_content(); things.push((k, id)); } @@ -119,6 +120,7 @@ pub(crate) fn apply_custom(doc: &mut Document, assets: &mut Assets, layouts: &[L let listed: Vec<(f64, String)> = roads_at.iter().map(|r| (r.1, r.2.clone())).collect(); let (layout, rot, by_arm) = candidates.iter().filter_map(|l| cjunction::fit(l, &listed, &same).map(|(rot, by, err)| (err, *l, rot, by))).min_by(|a, b| a.0.total_cmp(&b.0)).map(|(_, l, rot, by)| (l, rot, by))?; let baked = layout.baked.clone()?; + let rules = crate::junction::read_bus_path_rules(&assets.resolve(&baked)); let z = centre.z; // everything is checked before anything is cut: the roads must be long enough and their // tiles there @@ -157,7 +159,7 @@ pub(crate) fn apply_custom(doc: &mut Document, assets: &mut Assets, layouts: &[L let org = tile_origin(k); let id = doc.new_id(); let t = doc.tiles.get_mut(&k)?; - t.tile.objects.push(MapObject { file: baked, id, pos: [centre.x - org.x, centre.y - org.y, z], rot: [rot, 0.0, 0.0], ..Default::default() }); + t.tile.objects.push(MapObject { file: baked, id, pos: [centre.x - org.x, centre.y - org.y, z], rot: [rot, 0.0, 0.0], rules, ..Default::default() }); t.touch_content(); cjunction::place_objects(doc, layout, centre.truncate(), z, rot); if follow { diff --git a/src/editor.rs b/src/editor.rs index 143d7c9..cbb7d8a 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -16088,6 +16088,9 @@ mod tests { let _ = std::fs::remove_dir_all(&content); } + include!("junction_snapshot_tests.rs"); + include!("junction_placement_tests.rs"); + /// Two road types made here, the second with a pocket lane, in a scratch content folder. fn pocket_fixture(tag: &str) -> (Assets, std::path::PathBuf, String, String) { let dir = std::env::temp_dir().join(format!("om-pocket-{tag}-{}", std::process::id())); diff --git a/src/junction.rs b/src/junction.rs index 40dea8b..d5a0ba3 100644 --- a/src/junction.rs +++ b/src/junction.rs @@ -44,6 +44,8 @@ struct LaneEnd { incoming: bool, /// This end belongs to a lane added by the bus pocket tool for this taper. pocket: bool, + bus: bool, + kerb_outer: bool, } /// Room a junction needs round its centre for these roads (m): the widest of them plus @@ -76,14 +78,29 @@ fn arm_ends(doc: &Document, assets: &mut Assets, arms: &[Arm], pocket_paths: Opt let p = c.point_at(at); ends.push((p, roads::norm_deg(into), model.half_width as f64, s.file.clone())); let paths = pocket_paths.filter(|_| ai == 1); - lanes.extend(lanes_at(&model, s.mirror, ai, a.at_end, |x, z| c.offset_point(at, x, z), c.heading_at(at), paths)); + let (bus, bay) = crate::road_maker::bus_rules::paths_for_parts(doc, &s.file, doc.content_root.as_deref()); + let flags = bus_flags(&model, ai, &s.file, &bus, &bay, &s.rules); + lanes.extend(lanes_at_classified(&model, s.mirror, ai, a.at_end, |x, z| c.offset_point(at, x, z), c.heading_at(at), paths, &flags)); } Some((ends, lanes)) } +fn bus_flags(model: &SplineModel, arm: usize, file: &str, bus: &[usize], bay: &[usize], rules: &[omsi_map::MapRule]) -> Vec { + model.def.paths.iter().enumerate().map(|(index, path)| { + let from_rules = ["bus", "no_cars"].iter().all(|kind| rules.iter().any(|r| r.path_index == index as i32 && r.kind == *kind && !r.kill)); + let result = path.kind == 0 && !bay.contains(&index) && (bus.contains(&index) || from_rules); + log::info!("junction bus classification: arm={arm} file={file:?} path_index={index} bus={result} bus_paths={} rules={from_rules} bay_paths_excluded={}", bus.contains(&index), bay.contains(&index)); + result + }).collect() +} + /// The lanes of a road type where it meets a junction: `place(x, z)` is where a lane at /// lateral place `x` (and height `z`) ends, `along` the heading of the road's own way there. fn lanes_at(model: &SplineModel, mirrored: bool, ai: usize, at_end: bool, place: impl Fn(f64, f64) -> DVec3, along: f64, pocket_paths: Option<&std::ops::Range>) -> Vec { + lanes_at_classified(model, mirrored, ai, at_end, place, along, pocket_paths, &[]) +} + +fn lanes_at_classified(model: &SplineModel, mirrored: bool, ai: usize, at_end: bool, place: impl Fn(f64, f64) -> DVec3, along: f64, pocket_paths: Option<&std::ops::Range>, bus: &[bool]) -> Vec { let mut lanes = Vec::new(); let lateral_sign = if mirrored { -1.0 } else { 1.0 }; for (index, path) in model.def.paths.iter().enumerate() { @@ -106,7 +123,7 @@ fn lanes_at(model: &SplineModel, mirrored: bool, ai: usize, at_end: bool, place: let side = if at_end { x } else { -x }; let pocket = path.kind == 0 && pocket_paths.is_some_and(|paths| paths.contains(&index)); for (incoming, flow) in ways { - lanes.push(LaneEnd { arm: ai, pos, flow: roads::norm_deg(flow), kind: path.kind, width: path.width as f64, side, incoming, pocket }); + lanes.push(LaneEnd { arm: ai, pos, flow: roads::norm_deg(flow), kind: path.kind, width: path.width as f64, side, incoming, pocket, bus: bus.get(index).copied().unwrap_or(false), kerb_outer: true }); } } lanes @@ -125,6 +142,36 @@ struct PathRec { light: Option, /// This path is part of a connection into or out of a bus pocket lane. pocket: bool, + bus: bool, +} + +fn junction_rules(recs: &[PathRec]) -> Vec { + recs.iter().enumerate().filter(|(_, p)| p.pocket || p.bus).flat_map(|(index, _)| { + ["bus", "no_cars"].map(|kind| omsi_map::MapRule { + path_index: index as i32, kind: kind.into(), ..Default::default() + }) + }).collect() +} + +const BUS_PATHS_TAG: &str = "openMapper bus paths:"; + +pub(crate) fn bus_path_metadata(indices: &[usize]) -> String { + if indices.is_empty() { return String::new(); } + format!("{BUS_PATHS_TAG} {}\n\n", indices.iter().map(usize::to_string).collect::>().join(",")) +} + +pub(crate) fn bus_path_rules(indices: &[usize]) -> Vec { + indices.iter().flat_map(|&index| ["bus", "no_cars"].map(|kind| omsi_map::MapRule { + path_index: index as i32, kind: kind.into(), ..Default::default() + })).collect() +} + +pub(crate) fn read_bus_path_rules(path: &Path) -> Vec { + let Ok(text) = omsi_cfg::vfs::read_text(path) else { return Vec::new() }; + let indices: Vec = text.lines().find_map(|line| line.trim().strip_prefix(BUS_PATHS_TAG)) + .map(|s| s.trim().split(',').filter_map(|s| s.trim().parse().ok()).collect()) + .unwrap_or_default(); + bus_path_rules(&indices) } /// What a junction has besides its roads: traffic lights (a plan of two phases, the main @@ -420,8 +467,21 @@ fn paths( corner_walks: bool, kerb_lead: &[(usize, usize, f64, f64)], zebra_arms: &[bool], kerb_corners: &[KerbCorner], left_hand_traffic: bool, ) -> Vec { - paths_with_lane_repair(lanes, centre, light_of, walk_joins, corner_walks, kerb_lead, - zebra_arms, kerb_corners, left_hand_traffic, true) + let normal: Vec<_> = lanes.iter().copied().filter(|l| !l.bus).collect(); + let mut out = paths_with_lane_repair(&normal, centre, light_of, walk_joins, corner_walks, kerb_lead, + zebra_arms, kerb_corners, left_hand_traffic, true); + let mut buses: Vec<_> = lanes.iter().copied().filter(|l| l.bus).collect(); + if !buses.is_empty() { + for lane in &mut buses { + lane.kerb_outer = !lanes.iter().any(|other| other.kind == 0 && other.arm == lane.arm && other.incoming == lane.incoming && + if lane.incoming != left_hand_traffic { other.side > lane.side + 1e-6 } else { other.side < lane.side - 1e-6 }); + } + let mut extra = paths_with_lane_repair(&buses, centre, light_of, walk_joins, corner_walks, kerb_lead, + zebra_arms, kerb_corners, left_hand_traffic, true); + for rec in &mut extra { rec.bus = true; } + out.extend(extra); + } + out } fn paths_with_lane_repair( @@ -470,13 +530,15 @@ fn paths_with_lane_repair( c.i == j && c.j == i }) }; - let (kerb_a, kerb_b) = if outer { + let (mut kerb_a, mut kerb_b) = if outer { kerb_lead.iter().find_map(|&(ki, kj, li, lj)| { if blinker == 3 && ki == i && kj == j { Some((li, lj)) } else if blinker == 2 && ki == j && kj == i { Some((lj, li)) } else { None } }).unwrap_or((0.0, 0.0)) } else { (0.0, 0.0) }; + if !a.kerb_outer { kerb_a = 0.0; } + if !b.kerb_outer { kerb_b = 0.0; } let zebra_a = if turning && zebra_arms.get(i).copied().unwrap_or(false) { 4.0 } else { 0.0 }; let zebra_b = if turning && zebra_arms.get(j).copied().unwrap_or(false) { 4.0 } else { 0.0 }; let segs = led_biarc(pa, a.flow, pb, b.flow, kerb_a.max(zebra_a), kerb_b.max(zebra_b)); @@ -499,7 +561,7 @@ fn paths_with_lane_repair( let z1 = a.pos.z + (b.pos.z - a.pos.z) * acc / total - centre.z; // (traffic waits where it comes in: the light is on the way's first piece) let light = if n == 0 { light_of.get(i).copied().flatten() } else { None }; - out.push(PathRec { seg: s, z0, z1, kind: 0, width: a.width.max(2.5), direction: 0, blinker, light, pocket }); + out.push(PathRec { seg: s, z0, z1, kind: 0, width: a.width.max(2.5), direction: 0, blinker, light, pocket, bus: false }); } true }; @@ -579,7 +641,7 @@ fn paths_with_lane_repair( let pa = a_pos.truncate() - c2; let pb = b_pos.truncate() - c2; if let Some(s) = roads::straight(pa, pb) { - out.push(PathRec { seg: s, z0: a_pos.z - centre.z, z1: b_pos.z - centre.z, kind: 1, width: a.width.max(1.5), direction: 2, blinker: 0, light: None, pocket: false }); + out.push(PathRec { seg: s, z0: a_pos.z - centre.z, z1: b_pos.z - centre.z, kind: 1, width: a.width.max(1.5), direction: 2, blinker: 0, light: None, pocket: false, bus: false }); } } } @@ -1327,8 +1389,11 @@ pub(crate) fn make_with(doc: &mut Document, assets: &mut Assets, content: &Path, let (mut mesh, kerb_corners) = junction_mesh(&plate.arms, DVec3::ZERO, core_tex, ASPHALT_PERIOD, along); let kerb_lead = corner_leads(&kerb_corners); let zebra_arms: Vec = plate.arms.iter().map(|g| opts.crossing_at(g.out)).collect(); + let bypass_bus = edit.pocket_paths.is_some() || files.iter().any(|f| f.to_lowercase().contains("_bay_")); + let mut route_lanes = plate.lanes.clone(); + if bypass_bus { for lane in &mut route_lanes { lane.bus = false; } } let mut recs = paths( - &plate.lanes, DVec3::ZERO, &plate_lights, &walk_joins, opts.corner_walks, + &route_lanes, DVec3::ZERO, &plate_lights, &walk_joins, opts.corner_walks, &kerb_lead, &zebra_arms, &kerb_corners, doc.global.left_hand_traffic, ); anyhow::ensure!(edit.pocket_paths.is_none() || recs.iter().any(|p| p.pocket), "no path connects to the bus bay lanes"); @@ -1340,13 +1405,13 @@ pub(crate) fn make_with(doc: &mut Document, assets: &mut Assets, content: &Path, let (a, b) = (mid - r * (g.left_w + 0.5), mid + r * (g.right_w + 0.5)); let z = g.end.z + g.road_z; if let Some(seg) = roads::straight(a, b) { - recs.push(PathRec { seg, z0: z, z1: z, kind: 1, width: 3.0, direction: 2, blinker: 0, light: None, pocket: false }); + recs.push(PathRec { seg, z0: z, z1: z, kind: 1, width: 3.0, direction: 2, blinker: 0, light: None, pocket: false, bus: false }); for (left, edge) in [(true, a), (false, b)] { if let Some(join) = walk_joins.iter().find(|w| w.arm == i && w.left == left) { if let Some(seg) = roads::straight(edge, join.at_crossing.truncate()) { recs.push(PathRec { seg, z0: z, z1: join.at_crossing.z, kind: 1, - width: join.width, direction: 2, blinker: 0, light: None, pocket: false, + width: join.width, direction: 2, blinker: 0, light: None, pocket: false, bus: false, }); } // The corner path starts at at_crossing; this additional @@ -1356,7 +1421,7 @@ pub(crate) fn make_with(doc: &mut Document, assets: &mut Assets, content: &Path, recs.push(PathRec { seg, z0: join.at_arm.z, z1: join.at_crossing.z, kind: 1, width: join.width, direction: 2, - blinker: 0, light: None, pocket: false, + blinker: 0, light: None, pocket: false, bus: false, }); } } @@ -1431,11 +1496,7 @@ pub(crate) fn make_with(doc: &mut Document, assets: &mut Assets, content: &Path, } let rel = format!("Sceneryobjects\\openMapper\\{folder}\\{name}.sco"); let t = doc.tiles.get_mut(&k).ok_or_else(|| anyhow::anyhow!("no tile"))?; - let rules = recs.iter().enumerate().filter(|(_, p)| p.pocket).flat_map(|(index, _)| { - ["bus", "no_cars"].map(|kind| omsi_map::MapRule { - path_index: index as i32, kind: kind.into(), ..Default::default() - }) - }).collect(); + let rules = junction_rules(&recs); t.tile.objects.push(MapObject { file: rel, id, pos: [centre.x - org.x, centre.y - org.y, centre.z], rot: [roads::norm_deg(plate.turn), 0.0, 0.0], rules, ..Default::default() }); t.touch_content(); // Establish the final terrain before storing the heights of ground-relative objects. @@ -1584,6 +1645,7 @@ pub struct Plate { mesh: Mesh, /// Its `[path]` records (drawing's frame). pub paths: String, + pub bus_paths: Vec, /// The same lanes as lines (drawing's frame): the way along it, the path's kind and its /// direction (0 along the line, 1 against, 2 both). pub lanes: Vec<(Seg, i32, i32)>, @@ -1603,7 +1665,9 @@ pub fn layout_plate(assets: &mut Assets, arms: &[PlateArm], asphalt: Option<&Pat let along = if a.at_end { roads::norm_deg(a.out + 180.0) } else { a.out }; let r = roads::right(along); geo.push(arm_geo_of(&model, false, a.at_end, end, a.out, 0.0)); - lanes.extend(lanes_at(&model, false, i, a.at_end, |x, z| end + DVec3::new(r.x * x, r.y * x, z), along, None)); + let (bus, bay) = crate::road_maker::bus_rules::parts_at(&assets.resolve(&a.file), false); + let flags = bus_flags(&model, i, &a.file, &bus, &bay, &[]); + lanes.extend(lanes_at_classified(&model, false, i, a.at_end, |x, z| end + DVec3::new(r.x * x, r.y * x, z), along, None, &flags)); } // (made round the junction's own middle, then moved to the drawing's frame) let mid = arms.iter().map(|a| a.pos).sum::() / arms.len() as f64; @@ -1614,6 +1678,7 @@ pub fn layout_plate(assets: &mut Assets, arms: &[PlateArm], asphalt: Option<&Pat let along = asphalt_heading(&geo); let (mut mesh, kerb_corners) = junction_mesh(&geo, centre, core_tex, ASPHALT_PERIOD, along); let kerb_lead = corner_leads(&kerb_corners); + if arms.iter().any(|a| a.file.to_lowercase().contains("_bay_")) { for lane in &mut lanes { lane.bus = false; } } let recs = paths(&lanes, centre, &vec![None; arms.len()], &[], true, &kerb_lead, &vec![false; arms.len()], &kerb_corners, false); for v in &mut mesh.verts { @@ -1628,7 +1693,8 @@ pub fn layout_plate(assets: &mut Assets, arms: &[PlateArm], asphalt: Option<&Pat let _ = write!(paths, "[path]\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n\n", num(start.x), num(start.y), num(p.z0), num(s.heading), num(s.radius), num(s.length), num(grad), num(grad), p.kind, num(p.width), p.direction, p.blinker); } let lanes = recs.iter().map(|p| (Seg { start: p.seg.start + mid, ..p.seg }, p.kind, p.direction)).collect(); - Some(Plate { mesh, paths, lanes }) + let bus_paths = recs.iter().enumerate().filter_map(|(i, p)| p.bus.then_some(i)).collect(); + Some(Plate { mesh, paths, lanes, bus_paths }) } impl Plate { @@ -2059,6 +2125,138 @@ mod tests { links } + #[test] + fn bus_lane_passes_keep_routes_separate_and_do_not_leave_stubs() { + let profile = [(-5.0, 3.0, 1), (-2.0, 3.0, 1), (2.0, 3.0, 0), (5.0, 3.0, 0)]; + let mut lanes = Vec::new(); + for out in [0.0, 90.0, 180.0, 270.0] { + let (_, mut arm) = lane_connectivity_arm(lanes.len() / 4, out, true, &profile); + for lane in &mut arm { lane.bus = lane.side.abs() < 3.0; } + lanes.extend(arm); + } + let recs = paths(&lanes, DVec3::ZERO, &[None; 4], &[], false, &[], &[], &[], false); + let links = lane_connectivity_report("separate bus routes", &lanes, &recs); + for (i, peers) in links.iter().enumerate() { + assert!(!peers.is_empty()); + assert!(peers.iter().all(|&j| lanes[i].bus == lanes[j].bus)); + if lanes[i].bus && lanes[i].incoming { + assert_eq!(peers.iter().map(|&j| lanes[j].arm).collect::>().len(), 3); + } + } + assert!(recs.iter().any(|p| p.bus)); + for lane in &mut lanes { lane.bus = lane.arm == 0 && lane.side.abs() < 3.0; } + let actual = paths(&lanes, DVec3::ZERO, &[None; 4], &[], false, &[], &[], &[], false); + assert!(actual.iter().all(|p| !p.bus)); + let normal: Vec<_> = lanes.iter().copied().filter(|l| !l.bus).collect(); + let expected = paths_with_lane_repair(&normal, DVec3::ZERO, &[None; 4], &[], false, &[], &[], &[], false, true); + assert_eq!(record_paths(&actual), record_paths(&expected)); + } + + #[test] + fn outer_bus_lane_straight_and_right_turn_use_the_correct_lanes_and_lead() { + let profile = [(-5.0, 3.0, 1), (-2.0, 3.0, 1), (2.0, 3.0, 0), (5.0, 3.0, 0)]; + let mut lanes = Vec::new(); + for out in [0.0, 90.0, 180.0, 270.0] { + let (_, mut arm) = lane_connectivity_arm(lanes.len() / 4, out, true, &profile); + for lane in &mut arm { lane.bus = lane.side.abs() > 4.0; } + lanes.extend(arm); + } + let leads: Vec<_> = (0..4).flat_map(|i| (0..4).filter(move |j| *j != i).map(move |j| (i, j, 3.0, 3.0))).collect(); + let recs = paths(&lanes, DVec3::ZERO, &[None; 4], &[], false, &leads, &[], &[], false); + let links = lane_connectivity_report("outer bus", &lanes, &recs); + let bus_in = lanes.iter().position(|l| l.arm == 0 && l.incoming && l.bus).unwrap(); + let normal_in = lanes.iter().position(|l| l.arm == 0 && l.incoming && !l.bus).unwrap(); + let right_out = |source: usize| links[source].iter().copied().find(|&j| turn_blinker(signed_turn(lanes[source].flow, lanes[j].flow)) == 3).unwrap(); + let normal_target = right_out(normal_in); + assert!(!lanes[normal_target].bus); + let normal_route = trace_turn(&recs, lanes[normal_in].pos.truncate(), lanes[normal_target].pos.truncate(), 3); + assert!(!normal_route[0].bus); + let straight_target = links[bus_in].iter().copied().find(|&j| lanes[j].arm == 2).unwrap(); + assert!(lanes[straight_target].bus); + assert_eq!(turn_blinker(signed_turn(lanes[bus_in].flow, lanes[straight_target].flow)), 0); + let right_target = right_out(bus_in); + let bus_route = trace_turn(&recs, lanes[bus_in].pos.truncate(), lanes[right_target].pos.truncate(), 3); + assert!(bus_route.iter().all(|p| p.bus)); + assert_eq!(bus_route[0].seg.radius, 0.0); + assert!((bus_route[0].seg.length - 3.0).abs() < 1e-6, "outer bus uses its kerb lead"); + } + + #[test] + fn centre_bus_turns_do_not_use_kerb_leads() { + let profile = [(-5.0, 3.0, 1), (-2.0, 3.0, 1), (2.0, 3.0, 0), (5.0, 3.0, 0)]; + let mut lanes = Vec::new(); + for out in [0.0, 90.0, 180.0, 270.0] { + let (_, mut arm) = lane_connectivity_arm(lanes.len() / 4, out, true, &profile); + for lane in &mut arm { lane.bus = lane.side.abs() < 3.0; } + lanes.extend(arm); + } + let leads: Vec<_> = (0..4).flat_map(|i| (0..4).filter(move |j| *j != i).map(move |j| (i, j, 5.0, 5.0))).collect(); + let with = paths(&lanes, DVec3::ZERO, &[None; 4], &[], false, &leads, &[], &[], false); + let without = paths(&lanes, DVec3::ZERO, &[None; 4], &[], false, &[], &[], &[], false); + let bus_only = |records: &[PathRec]| { + let mut text = String::new(); + for p in records.iter().filter(|p| p.bus) { write_junction_paths(&mut text, std::slice::from_ref(p)); } + text + }; + assert_eq!(bus_only(&with), bus_only(&without)); + assert_ne!(record_paths(&with), record_paths(&without)); + } + + #[test] + fn bus_route_rules_cover_each_segment_only_once() { + let profile = [(-5.0, 3.0, 1), (-2.0, 3.0, 1), (2.0, 3.0, 0), (5.0, 3.0, 0)]; + let mut lanes = Vec::new(); + for out in [0.0, 90.0, 180.0, 270.0] { + let (_, mut arm) = lane_connectivity_arm(lanes.len() / 4, out, true, &profile); + for lane in &mut arm { lane.bus = lane.side.abs() < 3.0; } + lanes.extend(arm); + } + let recs = paths(&lanes, DVec3::ZERO, &[None; 4], &[], false, &[], &[], &[], false); + let rules = junction_rules(&recs); + assert!(recs.iter().any(|p| p.bus)); + assert!(recs.iter().any(|p| !p.bus)); + for (i, rec) in recs.iter().enumerate() { + let kinds: Vec<_> = rules.iter().filter(|r| r.path_index == i as i32).map(|r| r.kind.as_str()).collect(); + assert_eq!(kinds, if rec.bus { vec!["bus", "no_cars"] } else { vec![] }); + } + } + + #[test] + fn baked_bus_path_metadata_restores_object_rules() { + let dir = std::env::temp_dir().join(format!("openmapper-bus-metadata-{}", std::process::id())); + std::fs::create_dir_all(&dir).unwrap(); + let file = dir.join("junction.sco"); + let text = format!("[path]\n...\n\n{}[path]\n...\n", bus_path_metadata(&[3, 7])); + std::fs::write(&file, text).unwrap(); + let rules = read_bus_path_rules(&file); + assert_eq!(rules.iter().map(|r| (r.path_index, r.kind.as_str())).collect::>(), + vec![(3, "bus"), (3, "no_cars"), (7, "bus"), (7, "no_cars")]); + std::fs::remove_dir_all(dir).unwrap(); + } + + #[test] + fn bus_classification_honours_live_pairs_and_excludes_bays() { + let mut model = test_road(); + model.def.paths = (0..4).map(|_| omsi_scenery::PathDef { kind: 0, ..Default::default() }).collect(); + let rule = |path_index, kind: &str, kill| omsi_map::MapRule { path_index, kind: kind.into(), kill, ..Default::default() }; + let rules = vec![rule(1, "bus", false), rule(1, "no_cars", false), rule(2, "bus", false), rule(2, "no_cars", true), rule(3, "bus", false), rule(3, "no_cars", false)]; + assert_eq!(bus_flags(&model, 0, "test.sli", &[0], &[3], &rules), vec![true, true, false, false]); + } + + #[test] + fn no_bus_paths_are_byte_identical_to_original_pass() { + for (t, zebra) in [(true, false), (false, false), (false, true)] { + let (geo, lanes) = lane_connectivity_fixture(t, false); + let (_, corners) = junction_mesh(&geo, DVec3::ZERO, None, 8.0, 0.0); + let leads = corner_leads(&corners); + let lights = vec![None; geo.len()]; + let zebras = vec![zebra; geo.len()]; + let old = paths_with_lane_repair(&lanes, DVec3::ZERO, &lights, &[], true, &leads, &zebras, &corners, false, true); + let new = paths(&lanes, DVec3::ZERO, &lights, &[], true, &leads, &zebras, &corners, false); + assert_eq!(lane_connectivity_blocks(&old), lane_connectivity_blocks(&new)); + } + } + #[test] fn lane_connectivity_fills_t_junction_exits() { let (geo, lanes) = lane_connectivity_fixture(true, true); @@ -2123,7 +2321,7 @@ mod tests { let headings = if entering { [0.0, 175.0, 20.0, 50.0, 50.0] } else { [0.0, 185.0, 340.0, 310.0, 310.0] }; let lanes: Vec<_> = headings.into_iter().enumerate().map(|(idx, flow)| LaneEnd { arm: idx.min(3), pos: DVec3::ZERO, flow, kind: 0, width: 2.5, - side: idx as f64, incoming: if idx == 0 { entering } else { !entering }, pocket: false, + side: idx as f64, incoming: if idx == 0 { entering } else { !entering }, pocket: false, bus: false, kerb_outer: true, }).collect(); let same = vec![vec![0], vec![], vec![], vec![]]; let opposite = vec![vec![], vec![1], vec![2], vec![3, 4]]; @@ -2861,7 +3059,7 @@ mod tests { let seg = roads::straight(a, b).unwrap(); before_recs.push(PathRec { seg, z0: g.end.z, z1: g.end.z, kind: 1, - width: 3.0, direction: 2, blinker: 0, light: None, pocket: false, + width: 3.0, direction: 2, blinker: 0, light: None, pocket: false, bus: false, }); zebras.push((mid, g.out, g.left_w, g.right_w)); } @@ -3303,7 +3501,7 @@ mod tests { lanes.push(LaneEnd { arm: i, pos, flow, kind: 0, width: 2.5, // Right of the *incoming* heading = minus right(out). - side: -offset, incoming, pocket: false, + side: -offset, incoming, pocket: false, bus: false, kerb_outer: true, }); } } @@ -3431,7 +3629,7 @@ mod tests { let only_left = |recs: &[PathRec]| record_paths(&recs.iter().filter(|p| p.kind == 0 && p.blinker == 2) .map(|p| PathRec { seg: p.seg, z0: p.z0, z1: p.z1, kind: p.kind, - width: p.width, direction: p.direction, blinker: p.blinker, light: p.light, pocket: p.pocket, + width: p.width, direction: p.direction, blinker: p.blinker, light: p.light, pocket: p.pocket, bus: p.bus, }).collect::>()); assert_eq!(only_left(&before).as_bytes(), only_left(&after).as_bytes()); println!("===== ASYMMETRIC / NO ZEBRA LEFT TURNS BEFORE [path] =====\n{}", only_left(&before)); diff --git a/src/junction_placement_tests.rs b/src/junction_placement_tests.rs new file mode 100644 index 0000000..340d2fa --- /dev/null +++ b/src/junction_placement_tests.rs @@ -0,0 +1,94 @@ +#[test] +fn drawn_junctions_place_rules_on_the_baked_bus_routes() { + use crate::cjunction::{LSeg, Layout, Piece}; + use crate::road_maker::{Direction, RoadSpec, Strip}; + let (mut assets, dir, plain, _) = pocket_fixture("drawn-bus"); + let content = dir.join("content"); + let lane = |dir, bus_only| Strip::Lane { dir, width: 3.5, bus_only }; + let road = RoadSpec { + name: "Bus".into(), left_hand: Some(false), + roadway_tex: dir.join("asph.png"), footway_tex: dir.join("side.png"), + strips: vec![lane(Direction::Back, true), lane(Direction::Back, false), lane(Direction::Fwd, false), lane(Direction::Fwd, true)], + ..Default::default() + }; + let bus = road.write(&content).unwrap(); + assert!(assets.spline_wait(&bus, 5000).is_some()); + let line = |file: &str, x, y, heading| Piece { + file: file.into(), segs: vec![LSeg { x, y, heading, radius: 0.0, length: 80.0 }], + lift: 0.0, hidden: false, auto: false, + }; + let mut layout = Layout { name: "Drawn bus".into(), auto: true, + pieces: vec![line(&bus, 0.0, -40.0, 0.0), line(&plain, -40.0, 0.0, 90.0)], ..Default::default() }; + let kinds = crate::cjunction::road_kinds(&layout, &mut assets); + let is_road = |f: &str| kinds.get(&f.to_lowercase()).map(|k| k.0).unwrap_or(false); + let half = |f: &str| kinds.get(&f.to_lowercase()).map(|k| k.1).unwrap_or(1.5); + layout.sync_arms(&is_road, &half); + let resolved = layout.resolve(&is_road, &half); + assert_eq!(resolved.plates.len(), 1); + let plate = crate::junction::layout_plate(&mut assets, &resolved.plates[0], None).unwrap(); + assert!(!plate.bus_paths.is_empty()); + // Independently locate the road's declared bus paths at each plate arm and + // follow the emitted segments from one bus endpoint to another. + let bus_indices = crate::road_maker::bus_rules::parts_at(&assets.resolve(&bus), false).0; + let model = assets.spline_wait(&bus, 5000).unwrap(); + let mut bus_ends = Vec::new(); + for arm in resolved.plates[0].iter().filter(|a| a.file == bus) { + let along = if arm.at_end { crate::roads::norm_deg(arm.out + 180.0) } else { arm.out }; + for &index in &bus_indices { + bus_ends.push(arm.pos + crate::roads::right(along) * model.def.paths[index].start[0] as f64); + } + } + assert!(bus_ends.len() >= 2); + let at_bus_end = |p: DVec2| bus_ends.iter().any(|q| p.distance(*q) < 0.02); + let mut inside = false; + for &i in &plate.bus_paths { + let seg = &plate.lanes[i].0; + if !inside { assert!(at_bus_end(seg.start), "route must start at a declared bus lane"); } + inside = !at_bus_end(seg.end()); + } + assert!(!inside, "last bus route must reach a declared bus lane"); + let check = |object: &omsi_map::MapObject, offset: usize| { + let sco = omsi_scenery::SceneryObject::load(&omsi_cfg::resolve_path(&content, &object.file)).unwrap(); + let actual: Vec<_> = object.rules.iter().map(|r| (r.path_index as usize, r.kind.as_str())).collect(); + let expected: Vec<_> = plate.bus_paths.iter().flat_map(|i| [(i + offset, "bus"), (i + offset, "no_cars")]).collect(); + assert_eq!(actual, expected); + for (i, (seg, kind, direction)) in plate.lanes.iter().enumerate() { + let p = &sco.paths[offset + i]; + assert_eq!((p.kind, p.direction), (*kind, *direction)); + assert!((p.start[0] as f64 - seg.start.x).abs() < 0.002); + assert!((p.start[1] as f64 - seg.start.y).abs() < 0.002); + assert_eq!(object.rules.iter().any(|r| r.path_index as usize == offset + i), plate.bus_paths.contains(&i)); + } + }; + let mut doc = flat_map(1); + doc.dir = content.join("maps").join("Drawn"); + let mut ed = Editor::default(); + ed.content_dir = Some(content.clone()); + ed.open(doc); + ed.place_layout(&mut assets, &layout, DVec2::new(150.0, 150.0), 0.0); + let tile = &ed.doc.as_ref().unwrap().tiles[&(0, 0)].tile; + let object = tile.objects.iter().find(|o| o.file.contains("junction_")).expect("plate placed"); + check(object, 0); + + let roots = crate::install::Roots { omsi: dir.join("omsi"), content: content.clone() }; + let baked = crate::cjunction::bake(&roots, &layout, &mut assets, true).unwrap(); + layout.baked = Some(baked.clone()); + let mut doc = flat_map(1); + doc.dir = content.join("maps").join("Custom"); + let mut ends = Vec::new(); + for (i, arm) in layout.arms.iter().enumerate() { + let pos = DVec2::new(150.0 + arm.x, 150.0 + arm.y) + crate::roads::dir(arm.out) * 80.0; + let id = i as i64 + 1; + doc.tiles.get_mut(&(0, 0)).unwrap().tile.splines.push(MapSpline { + file: arm.road.clone(), id, pos: [pos.x, pos.y, 0.0], heading: crate::roads::norm_deg(arm.out + 180.0), length: 70.0, ..Default::default() + }); + ends.push(Some(((0, 0), id, true))); + } + crate::ed_cjunction::apply_custom(&mut doc, &mut assets, &[layout], &ends, DVec3::new(150.0, 150.0, 0.0), false).expect("custom junction placed"); + let object = doc.tiles[&(0, 0)].tile.objects.iter().find(|o| o.file == baked).unwrap(); + let baked_sco = omsi_scenery::SceneryObject::load(&omsi_cfg::resolve_path(&content, &baked)).unwrap(); + let offset = baked_sco.paths.len() - plate.lanes.len(); + assert!(offset > 0, "piece paths precede plate paths"); + check(object, offset); + std::fs::remove_dir_all(dir).unwrap(); +} diff --git a/src/junction_snapshot_tests.rs b/src/junction_snapshot_tests.rs new file mode 100644 index 0000000..24b47e9 --- /dev/null +++ b/src/junction_snapshot_tests.rs @@ -0,0 +1,68 @@ +// Golden SCOs generated by these exact fixtures at integration 309ad4d. +fn compare_junction_snapshot(name: &str, bytes: &[u8]) { + let root = std::env::var_os("OPENMAPPER_SNAPSHOT_WRITE") + .map(std::path::PathBuf::from) + .unwrap_or_else(|| std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/junction-baseline")); + let file = root.join(format!("{name}.sco")); + if std::env::var_os("OPENMAPPER_SNAPSHOT_WRITE").is_some() { + std::fs::create_dir_all(&root).unwrap(); + std::fs::write(file, bytes).unwrap(); + } else { + assert_eq!(bytes, std::fs::read(&file).unwrap(), "snapshot {}", file.display()); + } +} + +#[test] +fn junction_sco_baseline_snapshots() { + for (name, headings, zebra) in [ + ("three-arm", vec![0.0, 90.0, 270.0], false), + ("four-arm", vec![0.0, 90.0, 180.0, 270.0], false), + ("zebra", vec![0.0, 90.0, 180.0, 270.0], true), + ] { + let (mut assets, dir, plain, _) = pocket_fixture(name); + let content = dir.join("content"); + let mut doc = flat_map(1); + doc.dir = content.join("maps").join("Snapshot"); + let centre = DVec3::new(150.0, 150.0, 0.0); + let mut arms = Vec::new(); + for (i, heading) in headings.iter().enumerate() { + let p = centre.truncate() + crate::roads::dir(*heading) * 18.0; + let id = i as i64 + 1; + doc.tiles.get_mut(&(0, 0)).unwrap().tile.splines.push(MapSpline { + file: plain.clone(), id, pos: [p.x, p.y, 0.0], heading: *heading, + length: 50.0, ..Default::default() + }); + arms.push(crate::junction::Arm { key: (0, 0), id, at_end: false }); + } + let opts = crate::junction::Options { crossings: if zebra { vec![0.0, 90.0] } else { vec![] }, ..Default::default() }; + let id = crate::junction::make_with(&mut doc, &mut assets, &content, None, centre, &arms, &opts, Default::default()).unwrap(); + let obj = doc.tiles[&(0, 0)].tile.objects.iter().find(|o| o.id == id).unwrap(); + assert!(obj.rules.is_empty()); + compare_junction_snapshot(name, &std::fs::read(omsi_cfg::resolve_path(&content, &obj.file)).unwrap()); + std::fs::remove_dir_all(dir).unwrap(); + } + for both in [false, true] { + let name = if both { "pocket-both" } else { "pocket-one" }; + let (mut assets, dir, plain, _) = pocket_fixture(name); + let content = dir.join("content"); + let mut doc = flat_map(1); + doc.dir = content.join("maps").join("Snapshot"); + doc.tiles.get_mut(&(0, 0)).unwrap().tile.splines.push(MapSpline { + file: plain, id: 1, pos: [150.0, 60.0, 0.0], length: 180.0, ..Default::default() + }); + let mut ed = Editor::default(); + ed.content_dir = Some(content.clone()); + ed.open(doc); + ed.set_tool(Tool::Roads); + ed.bus_pocket = true; + ed.pocket_both_sides = both; + ed.cursor = Some(DVec3::new(150.0, 150.0, 0.0)); + ed.left_press(&mut assets, &Library::default(), false); + let tile = &ed.doc.as_ref().unwrap().tiles[&(0, 0)].tile; + let mut plates: Vec<_> = tile.objects.iter().filter(|o| is_bus_bay_junction(&o.file)).collect(); + plates.sort_by(|a, b| a.pos[1].total_cmp(&b.pos[1])); + assert_eq!(plates.len(), 2); + compare_junction_snapshot(name, &std::fs::read(omsi_cfg::resolve_path(&content, &plates[0].file)).unwrap()); + std::fs::remove_dir_all(dir).unwrap(); + } +} diff --git a/src/road_maker/bus_rules.rs b/src/road_maker/bus_rules.rs index 81bc7cc..b23a8ee 100644 --- a/src/road_maker/bus_rules.rs +++ b/src/road_maker/bus_rules.rs @@ -4,6 +4,14 @@ use crate::doc::{Document, TileKey}; use omsi_map::MapSpline; pub fn paths_for(doc: &Document, file: &str, content: Option<&std::path::Path>) -> Vec { + let (mut bus, bay) = paths_for_parts(doc, file, content); + bus.extend(bay); + bus.sort_unstable(); + bus.dedup(); + bus +} + +pub fn paths_for_parts(doc: &Document, file: &str, content: Option<&std::path::Path>) -> (Vec, Vec) { let mut roots: Vec = content .or(doc.content_root.as_deref()) .map(|p| p.to_path_buf()) @@ -26,15 +34,7 @@ pub fn paths_for(doc: &Document, file: &str, content: Option<&std::path::Path>) std::env::current_dir().unwrap_or_default().join(&json) }); if json.is_file() { - return RoadSpec::of_with_traffic(&sli, doc.global.left_hand_traffic) - .map(|s| { - let mut paths = s.bus_paths; - paths.extend(s.bay_paths); - paths.sort_unstable(); - paths.dedup(); - paths - }) - .unwrap_or_default(); + return parts_at(&sli, doc.global.left_hand_traffic); } } let normalized = file.replace('\\', "/").to_lowercase(); @@ -48,7 +48,13 @@ pub fn paths_for(doc: &Document, file: &str, content: Option<&std::path::Path>) ) ); } - Vec::new() + (Vec::new(), Vec::new()) +} + +pub fn parts_at(sli: &std::path::Path, left_hand: bool) -> (Vec, Vec) { + RoadSpec::of_with_traffic(sli, left_hand) + .map(|s| (s.bus_paths, s.bay_paths)) + .unwrap_or_default() } fn log_rule(caller: &str, phase: &str, spline: &MapSpline, path: i32, kind: &str) { diff --git a/tests/fixtures/junction-baseline/README.md b/tests/fixtures/junction-baseline/README.md new file mode 100644 index 0000000..a5fda69 --- /dev/null +++ b/tests/fixtures/junction-baseline/README.md @@ -0,0 +1,10 @@ +# Junction SCO baselines + +The five `.sco` files were generated by `junction_sco_baseline_snapshots` on the +unmodified production code at integration commit `309ad4df93baf1ecf3c3876006bd1b2e4d716d87`. +The test fixture was temporarily included in that checkout and run with +`OPENMAPPER_SNAPSHOT_WRITE` pointing at this directory. It makes the three normal +junctions through `make_with` and places both pocket variants through the editor's +bus-pocket tool. The first taper in the direction of the original road is saved. +The regression test compares the complete SCO bytes, including the generated mesh +name and all path and helper records. diff --git a/tests/fixtures/junction-baseline/four-arm.sco b/tests/fixtures/junction-baseline/four-arm.sco new file mode 100644 index 0000000..79351a3 --- /dev/null +++ b/tests/fixtures/junction-baseline/four-arm.sco @@ -0,0 +1,444 @@ +openMapper junction: lights=0 heads=0 main=30 side=20 crossings= zebra_tex=1 walks=1 helpers=omsi sig= + +[friendlyname] +Junction cdfbba + +[groups] +1 +openMapper + +[surface] + +[absheight] + +[mesh] +junction_cdfbba2d63dbc03a.x + +[splinehelper] +Splines\openMapper\Plain.sli +0 +0 +18 +180 +0.1 +0 + +[splinehelper] +Splines\openMapper\Plain.sli +-18 +0 +0 +90 +0.1 +0 + +[splinehelper] +Splines\openMapper\Plain.sli +0 +0 +-18 +0 +0.1 +0 + +[splinehelper] +Splines\openMapper\Plain.sli +18 +0 +0 +270 +0.1 +0 + +[path] +-1.75 +18 +0.1 +180 +16.25 +12.7627 +0 +0 +0 +3.15 +0 +3 + +[path] +-6.5095 +6.5095 +0.1 +225 +16.25 +12.7627 +0 +0 +0 +3.15 +0 +3 + +[path] +-1.75 +18 +0.1 +180 +0 +18 +0 +0 +0 +3.15 +0 +0 + +[path] +-1.75 +0 +0.1 +180 +0 +18 +0 +0 +0 +3.15 +0 +0 + +[path] +-1.75 +18 +0.1 +180 +-19.75 +15.5116 +0 +0 +0 +3.15 +0 +2 + +[path] +4.0346 +4.0346 +0.1 +135 +-19.75 +15.5116 +0 +0 +0 +3.15 +0 +2 + +[path] +-18 +-1.75 +0.1 +90 +-19.75 +15.5116 +0 +0 +0 +3.15 +0 +2 + +[path] +-4.0346 +4.0346 +0.1 +45 +-19.75 +15.5116 +0 +0 +0 +3.15 +0 +2 + +[path] +-18 +-1.75 +0.1 +90 +16.25 +12.7627 +0 +0 +0 +3.15 +0 +3 + +[path] +-6.5095 +-6.5095 +0.1 +135 +16.25 +12.7627 +0 +0 +0 +3.15 +0 +3 + +[path] +-18 +-1.75 +0.1 +90 +0 +18 +0 +0 +0 +3.15 +0 +0 + +[path] +0 +-1.75 +0.1 +90 +0 +18 +0 +0 +0 +3.15 +0 +0 + +[path] +1.75 +-18 +0.1 +0 +0 +18 +0 +0 +0 +3.15 +0 +0 + +[path] +1.75 +0 +0.1 +0 +0 +18 +0 +0 +0 +3.15 +0 +0 + +[path] +1.75 +-18 +0.1 +0 +-19.75 +15.5116 +0 +0 +0 +3.15 +0 +2 + +[path] +-4.0346 +-4.0346 +0.1 +315 +-19.75 +15.5116 +0 +0 +0 +3.15 +0 +2 + +[path] +1.75 +-18 +0.1 +0 +16.25 +12.7627 +0 +0 +0 +3.15 +0 +3 + +[path] +6.5095 +-6.5095 +0.1 +45 +16.25 +12.7627 +0 +0 +0 +3.15 +0 +3 + +[path] +18 +1.75 +0.1 +270 +16.25 +12.7627 +0 +0 +0 +3.15 +0 +3 + +[path] +6.5095 +6.5095 +0.1 +315 +16.25 +12.7627 +0 +0 +0 +3.15 +0 +3 + +[path] +18 +1.75 +0.1 +270 +0 +18 +0 +0 +0 +3.15 +0 +0 + +[path] +0 +1.75 +0.1 +270 +0 +18 +0 +0 +0 +3.15 +0 +0 + +[path] +18 +1.75 +0.1 +270 +-19.75 +15.5116 +0 +0 +0 +3.15 +0 +2 + +[path] +4.0346 +-4.0346 +0.1 +225 +-19.75 +15.5116 +0 +0 +0 +3.15 +0 +2 + +[path] +-18 +-5 +0.25 +135 +0 +18.3848 +0 +0 +1 +1.5 +2 +0 + +[path] +5 +-18 +0.25 +45 +0 +18.3848 +0 +0 +1 +1.5 +2 +0 + +[path] +18 +5 +0.25 +315 +0 +18.3848 +0 +0 +1 +1.5 +2 +0 + +[path] +-5 +18 +0.25 +225 +0 +18.3848 +0 +0 +1 +1.5 +2 +0 + diff --git a/tests/fixtures/junction-baseline/pocket-both.sco b/tests/fixtures/junction-baseline/pocket-both.sco new file mode 100644 index 0000000..6ffbd99 --- /dev/null +++ b/tests/fixtures/junction-baseline/pocket-both.sco @@ -0,0 +1,160 @@ +openMapper junction: lights=0 heads=0 main=30 side=20 crossings= zebra_tex=1 walks=1 helpers=omsi sig= + +[friendlyname] +Junction 1aa0b2 + +[groups] +1 +openMapper + +[surface] + +[absheight] + +[mesh] +junction_1aa0b23462779ecb_busbay.x + +[splinehelper] +Splines\openMapper\Plain.sli +0 +0 +9 +180 +0.1 +0 + +[splinehelper] +Splines\openMapper\Plain_bay_both_3_000m.sli +0 +0 +-9 +0 +0.1 +0 + +[path] +-1.75 +9 +0.1 +180 +25.7356 +9.1943 +0 +0 +0 +3.15 +0 +0 + +[path] +-3.375 +0 +0.1 +200.4696 +-25.7356 +9.1943 +0 +0 +0 +3.15 +0 +0 + +[path] +-1.75 +9 +0.1 +180 +0 +9 +0 +0 +0 +3.15 +0 +0 + +[path] +-1.75 +0 +0.1 +180 +0 +9 +0 +0 +0 +3.15 +0 +0 + +[path] +5 +-9 +0.1 +0 +-25.7356 +9.1943 +0 +0 +0 +2.7 +0 +0 + +[path] +3.375 +0 +0.1 +339.5304 +25.7356 +9.1943 +0 +0 +0 +2.7 +0 +0 + +[path] +1.75 +-9 +0.1 +0 +0 +9 +0 +0 +0 +3.15 +0 +0 + +[path] +1.75 +0 +0.1 +0 +0 +9 +0 +0 +0 +3.15 +0 +0 + +[path] +8 +-9 +0.25 +350.5377 +0 +18.2483 +0 +0 +1 +1.5 +2 +0 + diff --git a/tests/fixtures/junction-baseline/pocket-one.sco b/tests/fixtures/junction-baseline/pocket-one.sco new file mode 100644 index 0000000..a025e69 --- /dev/null +++ b/tests/fixtures/junction-baseline/pocket-one.sco @@ -0,0 +1,132 @@ +openMapper junction: lights=0 heads=0 main=30 side=20 crossings= zebra_tex=1 walks=1 helpers=omsi sig= + +[friendlyname] +Junction 34124b + +[groups] +1 +openMapper + +[surface] + +[absheight] + +[mesh] +junction_34124b8a61bdcafe_busbay.x + +[splinehelper] +Splines\openMapper\Plain.sli +0 +0 +9 +180 +0.1 +0 + +[splinehelper] +Splines\openMapper\Plain_bay_right_3_0m.sli +0 +0 +-9 +0 +0.1 +0 + +[path] +-1.75 +9 +0.1 +180 +25.7356 +9.1943 +0 +0 +0 +3.15 +0 +0 + +[path] +-3.375 +0 +0.1 +200.4696 +-25.7356 +9.1943 +0 +0 +0 +3.15 +0 +0 + +[path] +-1.75 +9 +0.1 +180 +0 +9 +0 +0 +0 +3.15 +0 +0 + +[path] +-1.75 +0 +0.1 +180 +0 +9 +0 +0 +0 +3.15 +0 +0 + +[path] +1.75 +-9 +0.1 +0 +0 +9 +0 +0 +0 +3.15 +0 +0 + +[path] +1.75 +0 +0.1 +0 +0 +9 +0 +0 +0 +3.15 +0 +0 + +[path] +5 +-9 +0.25 +0 +0 +18 +0 +0 +1 +1.5 +2 +0 + diff --git a/tests/fixtures/junction-baseline/three-arm.sco b/tests/fixtures/junction-baseline/three-arm.sco new file mode 100644 index 0000000..027ba95 --- /dev/null +++ b/tests/fixtures/junction-baseline/three-arm.sco @@ -0,0 +1,253 @@ +openMapper junction: lights=0 heads=0 main=30 side=20 crossings= zebra_tex=1 walks=1 helpers=omsi sig= + +[friendlyname] +Junction 1ab112 + +[groups] +1 +openMapper + +[surface] + +[absheight] + +[mesh] +junction_1ab11210af17380f.x + +[splinehelper] +Splines\openMapper\Plain.sli +0 +0 +18 +180 +0.1 +0 + +[splinehelper] +Splines\openMapper\Plain.sli +0 +0 +-18 +0 +0.1 +0 + +[splinehelper] +Splines\openMapper\Plain.sli +18 +0 +0 +270 +0.1 +0 + +[path] +-1.75 +18 +0.1 +180 +0 +18 +0 +0 +0 +3.15 +0 +0 + +[path] +-1.75 +0 +0.1 +180 +0 +18 +0 +0 +0 +3.15 +0 +0 + +[path] +-1.75 +18 +0.1 +180 +-19.75 +15.5116 +0 +0 +0 +3.15 +0 +2 + +[path] +4.0346 +4.0346 +0.1 +135 +-19.75 +15.5116 +0 +0 +0 +3.15 +0 +2 + +[path] +1.75 +-18 +0.1 +0 +0 +18 +0 +0 +0 +3.15 +0 +0 + +[path] +1.75 +0 +0.1 +0 +0 +18 +0 +0 +0 +3.15 +0 +0 + +[path] +1.75 +-18 +0.1 +0 +16.25 +12.7627 +0 +0 +0 +3.15 +0 +3 + +[path] +6.5095 +-6.5095 +0.1 +45 +16.25 +12.7627 +0 +0 +0 +3.15 +0 +3 + +[path] +18 +1.75 +0.1 +270 +16.25 +12.7627 +0 +0 +0 +3.15 +0 +3 + +[path] +6.5095 +6.5095 +0.1 +315 +16.25 +12.7627 +0 +0 +0 +3.15 +0 +3 + +[path] +18 +1.75 +0.1 +270 +-19.75 +15.5116 +0 +0 +0 +3.15 +0 +2 + +[path] +4.0346 +-4.0346 +0.1 +225 +-19.75 +15.5116 +0 +0 +0 +3.15 +0 +2 + +[path] +5 +-18 +0.25 +45 +0 +18.3848 +0 +0 +1 +1.5 +2 +0 + +[path] +18 +5 +0.25 +315 +0 +18.3848 +0 +0 +1 +1.5 +2 +0 + +[path] +-5 +18 +0.25 +180 +0 +36 +0 +0 +1 +1.5 +2 +0 + diff --git a/tests/fixtures/junction-baseline/zebra.sco b/tests/fixtures/junction-baseline/zebra.sco new file mode 100644 index 0000000..1b2d0b5 --- /dev/null +++ b/tests/fixtures/junction-baseline/zebra.sco @@ -0,0 +1,696 @@ +openMapper junction: lights=0 heads=0 main=30 side=20 crossings=0.0,90.0 zebra_tex=1 walks=1 helpers=omsi sig= + +[friendlyname] +Junction 10ded0 + +[groups] +1 +openMapper + +[surface] + +[absheight] + +[mesh] +junction_10ded0cce0ab84db.x + +[splinehelper] +Splines\openMapper\Plain.sli +0 +0 +18 +180 +0.1 +0 + +[splinehelper] +Splines\openMapper\Plain.sli +-18 +0 +0 +90 +0.1 +0 + +[splinehelper] +Splines\openMapper\Plain.sli +0 +0 +-18 +0 +0.1 +0 + +[splinehelper] +Splines\openMapper\Plain.sli +18 +0 +0 +270 +0.1 +0 + +[path] +-1.75 +18 +0.1 +180 +0 +4 +0 +0 +0 +3.15 +0 +3 + +[path] +-1.75 +14 +0.1 +180 +10.6882 +10.937 +0 +0 +0 +3.15 +0 +3 + +[path] +-6.8742 +4.8742 +0.1 +238.6294 +21.3723 +11.7017 +0 +0 +0 +3.15 +0 +3 + +[path] +-1.75 +18 +0.1 +180 +0 +18 +0 +0 +0 +3.15 +0 +0 + +[path] +-1.75 +0 +0.1 +180 +0 +18 +0 +0 +0 +3.15 +0 +0 + +[path] +-1.75 +18 +0.1 +180 +0 +4 +0 +0 +0 +3.15 +0 +2 + +[path] +-1.75 +14 +0.1 +180 +-15.75 +12.37 +0 +0 +0 +3.15 +0 +2 + +[path] +2.8631 +2.8631 +0.1 +135 +-15.75 +12.37 +0 +0 +0 +3.15 +0 +2 + +[path] +14 +-1.75 +0.1 +90 +0 +4 +0 +0 +0 +3.15 +0 +2 + +[path] +-18 +-1.75 +0.1 +90 +-24.2855 +14.4241 +0 +0 +0 +3.15 +0 +2 + +[path] +-4.4091 +2.4091 +0.1 +55.9698 +-13.9862 +13.6625 +0 +0 +0 +3.15 +0 +2 + +[path] +1.75 +14 +0.1 +0 +0 +4 +0 +0 +0 +3.15 +0 +2 + +[path] +-18 +-1.75 +0.1 +90 +16.25 +12.7627 +0 +0 +0 +3.15 +0 +3 + +[path] +-6.5095 +-6.5095 +0.1 +135 +16.25 +12.7627 +0 +0 +0 +3.15 +0 +3 + +[path] +-18 +-1.75 +0.1 +90 +0 +18 +0 +0 +0 +3.15 +0 +0 + +[path] +0 +-1.75 +0.1 +90 +0 +18 +0 +0 +0 +3.15 +0 +0 + +[path] +1.75 +-18 +0.1 +0 +0 +18 +0 +0 +0 +3.15 +0 +0 + +[path] +1.75 +0 +0.1 +0 +0 +18 +0 +0 +0 +3.15 +0 +0 + +[path] +1.75 +-18 +0.1 +0 +-19.75 +15.5116 +0 +0 +0 +3.15 +0 +2 + +[path] +-4.0346 +-4.0346 +0.1 +315 +-19.75 +15.5116 +0 +0 +0 +3.15 +0 +2 + +[path] +1.75 +-18 +0.1 +0 +21.3723 +11.7017 +0 +0 +0 +3.15 +0 +3 + +[path] +4.8742 +-6.8742 +0.1 +31.3706 +10.6882 +10.937 +0 +0 +0 +3.15 +0 +3 + +[path] +14 +-1.75 +0.1 +90 +0 +4 +0 +0 +0 +3.15 +0 +3 + +[path] +18 +1.75 +0.1 +270 +0 +4 +0 +0 +0 +3.15 +0 +3 + +[path] +14 +1.75 +0.1 +270 +12.25 +9.6211 +0 +0 +0 +3.15 +0 +3 + +[path] +5.3379 +5.3379 +0.1 +315 +12.25 +9.6211 +0 +0 +0 +3.15 +0 +3 + +[path] +1.75 +14 +0.1 +0 +0 +4 +0 +0 +0 +3.15 +0 +3 + +[path] +18 +1.75 +0.1 +270 +0 +18 +0 +0 +0 +3.15 +0 +0 + +[path] +0 +1.75 +0.1 +270 +0 +18 +0 +0 +0 +3.15 +0 +0 + +[path] +18 +1.75 +0.1 +270 +0 +4 +0 +0 +0 +3.15 +0 +2 + +[path] +14 +1.75 +0.1 +270 +-13.9862 +13.6625 +0 +0 +0 +3.15 +0 +2 + +[path] +2.4091 +-4.4091 +0.1 +214.0302 +-24.2855 +14.4241 +0 +0 +0 +3.15 +0 +2 + +[path] +-18 +-5 +0.25 +135 +0 +18.3848 +0 +0 +1 +1.5 +2 +0 + +[path] +5 +-18 +0.25 +40.2364 +0 +17.0294 +0 +0 +1 +1.5 +2 +0 + +[path] +16 +5 +0.25 +315 +0 +15.5563 +0 +0 +1 +1.5 +2 +0 + +[path] +-5 +16 +0.25 +229.7636 +0 +17.0294 +0 +0 +1 +1.5 +2 +0 + +[path] +-4 +16 +0.1 +90 +0 +8 +0 +0 +1 +3 +2 +0 + +[path] +-4 +16 +0.1 +270 +0 +1 +0.15 +0.15 +1 +1.2 +2 +0 + +[path] +-5 +18 +0.25 +180 +0 +2 +0 +0 +1 +1.2 +2 +0 + +[path] +4 +16 +0.1 +90 +0 +1 +0.15 +0.15 +1 +1.2 +2 +0 + +[path] +5 +18 +0.25 +180 +0 +2 +0 +0 +1 +1.2 +2 +0 + +[path] +16 +4 +0.1 +180 +0 +8 +0 +0 +1 +3 +2 +0 + +[path] +16 +4 +0.1 +0 +0 +1 +0.15 +0.15 +1 +1.2 +2 +0 + +[path] +18 +5 +0.25 +270 +0 +2 +0 +0 +1 +1.2 +2 +0 + +[path] +16 +-4 +0.1 +180 +0 +1 +0.15 +0.15 +1 +1.2 +2 +0 + +[path] +18 +-5 +0.25 +270 +0 +2 +0 +0 +1 +1.2 +2 +0 +