clean up old experiments from the intersection geometry code.

imperceptible changes to some (already broken) intersections.

also grab fresh osm and a new traffic signal
This commit is contained in:
Dustin Carlino 2020-07-14 17:41:56 -07:00
parent 614354271a
commit eeb70030c2
4 changed files with 61 additions and 131 deletions

2
Cargo.lock generated
View File

@ -2814,7 +2814,7 @@ dependencies = [
[[package]]
name = "seattle_traffic_signals"
version = "0.1.0"
source = "git+https://github.com/dabreegster/seattle_traffic_signals#22d7d7b378a8467ef5196236d4fd5de68a24e88c"
source = "git+https://github.com/dabreegster/seattle_traffic_signals#c110e0dfb330a3fd9dcfbb8df45403adf0d10c8e"
dependencies = [
"include_dir 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.110 (registry+https://github.com/rust-lang/crates.io-index)",

View File

@ -1,55 +1,55 @@
data/input/krakow/osm/huge_krakow.osm,0b098456c8ae844ff240ca9fe3b617d1,https://www.dropbox.com/s/fe2e8qzd4g5tkoy/huge_krakow.osm.zip?dl=0
data/input/krakow/osm/malopolskie-latest.osm.pbf,d848a278092001aaab3ced09de4d98ff,https://www.dropbox.com/s/ia2uwy3z52r6hpe/malopolskie-latest.osm.pbf.zip?dl=0
data/input/raw_maps/ballard.bin,f15f2fd87b0cac16fa0683a978971adf,https://www.dropbox.com/s/7g761ophke8h5o6/ballard.bin.zip?dl=0
data/input/raw_maps/downtown.bin,68c6d2c200916e1b7c41a52e1db83d77,https://www.dropbox.com/s/jr9lu60f14ow2tn/downtown.bin.zip?dl=0
data/input/raw_maps/huge_krakow.bin,f3a5700b1c8c9fab48e8ed952dcc6ee3,https://www.dropbox.com/s/6208nglhzvjkj0l/huge_krakow.bin.zip?dl=0
data/input/raw_maps/huge_seattle.bin,182ee725ca939a6df1743302b7f32650,https://www.dropbox.com/s/kocsgguvu5t2gul/huge_seattle.bin.zip?dl=0
data/input/krakow/osm/huge_krakow.osm,03bae13bcf9461236b81dd1f0a74696d,https://www.dropbox.com/s/ooqaw4z5yfwucql/huge_krakow.osm.zip?dl=0
data/input/krakow/osm/malopolskie-latest.osm.pbf,36071de68f68c516fe81300c2d1940a9,https://www.dropbox.com/s/4718vobelcz32id/malopolskie-latest.osm.pbf.zip?dl=0
data/input/raw_maps/ballard.bin,34ee5e25dc7fae4d1afffced0e11133e,https://www.dropbox.com/s/dczk7174xmdij2k/ballard.bin.zip?dl=0
data/input/raw_maps/downtown.bin,dbafee6ab45aaa55e95360ce1b3cfe2c,https://www.dropbox.com/s/5bhmnwhjfbdr73y/downtown.bin.zip?dl=0
data/input/raw_maps/huge_krakow.bin,dee71f3a27fb5d412b0b8d5f820dbc8f,https://www.dropbox.com/s/8r9sc6sdhh3sr2a/huge_krakow.bin.zip?dl=0
data/input/raw_maps/huge_seattle.bin,8ed56005a5b5fc50e08dfdfb54a5b93d,https://www.dropbox.com/s/ldsv4rgpm4s47jv/huge_seattle.bin.zip?dl=0
data/input/raw_maps/lakeslice.bin,b145e5dee9c953e0e0700843d6c96ac7,https://www.dropbox.com/s/wrmxud893nt427w/lakeslice.bin.zip?dl=0
data/input/raw_maps/montlake.bin,712532a30baa5225aca621fd1f1f7f0a,https://www.dropbox.com/s/evwmldb5872nf0u/montlake.bin.zip?dl=0
data/input/raw_maps/south_seattle.bin,9c7e5d352405efbd0234c4ddb92ed1d4,https://www.dropbox.com/s/lh2t2otcl15oo86/south_seattle.bin.zip?dl=0
data/input/raw_maps/udistrict.bin,a45f45140c03da4abf8d698cda580133,https://www.dropbox.com/s/plspsqay9c77fwz/udistrict.bin.zip?dl=0
data/input/raw_maps/west_seattle.bin,09143db3acb0354d2bc202ca1b93fa39,https://www.dropbox.com/s/nxl6qh4mr2mz1ng/west_seattle.bin.zip?dl=0
data/input/screenshots/downtown.zip,4df6e66d60791eddb29cb2df7a42d2b9,https://www.dropbox.com/s/qawd35wz62m2acl/downtown.zip.zip?dl=0
data/input/screenshots/huge_krakow.zip,ec769392353bc2faedbb0900426d1341,https://www.dropbox.com/s/dbzon7k5ukndtza/huge_krakow.zip.zip?dl=0
data/input/screenshots/lakeslice.zip,1be026bf7ae86fa6aa83a9ef3df7867c,https://www.dropbox.com/s/z0z96lsn7bunqfy/lakeslice.zip.zip?dl=0
data/input/screenshots/montlake.zip,f7f972a167dd11be4de82e5c9da9eff1,https://www.dropbox.com/s/r9vkgwesqklfuq2/montlake.zip.zip?dl=0
data/input/screenshots/udistrict.zip,362c1a09ec6ab4277157513d315c9788,https://www.dropbox.com/s/ecnt1tyza48y9o2/udistrict.zip.zip?dl=0
data/input/raw_maps/montlake.bin,02aeaafd38499339d8574a91d49eb78a,https://www.dropbox.com/s/8gu9v36ngqs5ylf/montlake.bin.zip?dl=0
data/input/raw_maps/south_seattle.bin,81abad5c266a0a074679697249e53486,https://www.dropbox.com/s/rojped5f21sj0gs/south_seattle.bin.zip?dl=0
data/input/raw_maps/udistrict.bin,ee9a8e476096c378f41ce6600ca2dea4,https://www.dropbox.com/s/58a90wvzmlptnxo/udistrict.bin.zip?dl=0
data/input/raw_maps/west_seattle.bin,68e1469e777df5cd0cd0d71923429805,https://www.dropbox.com/s/90ydkk1peuevt51/west_seattle.bin.zip?dl=0
data/input/screenshots/downtown.zip,44988ee69685062557bee477ff8a1853,https://www.dropbox.com/s/qawd35wz62m2acl/downtown.zip.zip?dl=0
data/input/screenshots/huge_krakow.zip,e1caa42e6627358c8c25276be8abc3ff,https://www.dropbox.com/s/dbzon7k5ukndtza/huge_krakow.zip.zip?dl=0
data/input/screenshots/lakeslice.zip,5fc8a5cb061d2df40fefd1599470e9f7,https://www.dropbox.com/s/z0z96lsn7bunqfy/lakeslice.zip.zip?dl=0
data/input/screenshots/montlake.zip,98678d91a22b5839a968432bfc9410af,https://www.dropbox.com/s/r9vkgwesqklfuq2/montlake.zip.zip?dl=0
data/input/screenshots/udistrict.zip,95302b49c910a972307204bb7dbda971,https://www.dropbox.com/s/ecnt1tyza48y9o2/udistrict.zip.zip?dl=0
data/input/seattle/N47W122.hgt,0db4e23e51f7680538b0bbbc72208e07,https://www.dropbox.com/s/mmb4mgutwotijdw/N47W122.hgt.zip?dl=0
data/input/seattle/blockface.bin,add872bab9040ae911366328a230f8b5,https://www.dropbox.com/s/rxd2care60tbe75/blockface.bin.zip?dl=0
data/input/seattle/blockface.kml,350bd9e59bf2af4e885a7c0741e6ee6b,https://www.dropbox.com/s/ukknmpjdvilncq9/blockface.kml.zip?dl=0
data/input/seattle/offstreet_parking.bin,a33c05e8962dfe10a7a14b9eb6413803,https://www.dropbox.com/s/7j2gwb18685kd5u/offstreet_parking.bin.zip?dl=0
data/input/seattle/offstreet_parking.kml,e24d1c308ca739df73621846c7b7847c,https://www.dropbox.com/s/dkkkpywob7cdo57/offstreet_parking.kml.zip?dl=0
data/input/seattle/osm/ballard.osm,b0d304caf28dab951f544567cff2bf32,https://www.dropbox.com/s/25i2e5ztndggijn/ballard.osm.zip?dl=0
data/input/seattle/osm/downtown.osm,93ff3e6c06152e0bf9c99498445282da,https://www.dropbox.com/s/d64ha2060cq9oeh/downtown.osm.zip?dl=0
data/input/seattle/osm/huge_seattle.osm,c25311813f02bd2043d11024fe35267b,https://www.dropbox.com/s/5be3ufmoy42gw58/huge_seattle.osm.zip?dl=0
data/input/seattle/osm/lakeslice.osm,431da0077988f3e85fc43321bb8c793e,https://www.dropbox.com/s/ynesf6p1jreevv9/lakeslice.osm.zip?dl=0
data/input/seattle/osm/montlake.osm,d6403149e1f13a837a93c63659d6beb3,https://www.dropbox.com/s/z6deuqxf2sz596u/montlake.osm.zip?dl=0
data/input/seattle/osm/south_seattle.osm,856ba9af0751432d40f51c0bec8a1664,https://www.dropbox.com/s/5rc06uj8m5z2hlt/south_seattle.osm.zip?dl=0
data/input/seattle/osm/udistrict.osm,184c269bd39ac6d475c1d31b01af824f,https://www.dropbox.com/s/35pu17pckr55p74/udistrict.osm.zip?dl=0
data/input/seattle/osm/washington-latest.osm.pbf,0db475bae90a383273865215f5b61f15,https://www.dropbox.com/s/lowvuydkyypnjwi/washington-latest.osm.pbf.zip?dl=0
data/input/seattle/osm/west_seattle.osm,924178166c37e2cc6c284783d27be459,https://www.dropbox.com/s/nkq6xr8jhqk5k9z/west_seattle.osm.zip?dl=0
data/input/seattle/parcels.bin,58c55a6e18ff3c5e08fa719006b6edf6,https://www.dropbox.com/s/hxc1dbtfpsu6203/parcels.bin.zip?dl=0
data/input/seattle/osm/ballard.osm,06b4ed9280a004e816b66c6fd1f76066,https://www.dropbox.com/s/dadzwhwfgfhpe3z/ballard.osm.zip?dl=0
data/input/seattle/osm/downtown.osm,7a837ff497495f896614303d71923f14,https://www.dropbox.com/s/44oakescjjebyfg/downtown.osm.zip?dl=0
data/input/seattle/osm/huge_seattle.osm,f0556627caf76db901ac5fe244285fab,https://www.dropbox.com/s/sg472oq40zz7p0d/huge_seattle.osm.zip?dl=0
data/input/seattle/osm/lakeslice.osm,a592d77833d99ef7969bedd2129075b9,https://www.dropbox.com/s/9zqrgvgm529kwns/lakeslice.osm.zip?dl=0
data/input/seattle/osm/montlake.osm,d151c1d711452c6c279145eef8fd45c4,https://www.dropbox.com/s/hvjnwcyhcdl3f7z/montlake.osm.zip?dl=0
data/input/seattle/osm/south_seattle.osm,bfffbfee550f627f9d61f127fab31855,https://www.dropbox.com/s/23ur33gldoo9hth/south_seattle.osm.zip?dl=0
data/input/seattle/osm/udistrict.osm,9b6ba4a130ce6e791564e739c6c34903,https://www.dropbox.com/s/nl1f0lpzej2rant/udistrict.osm.zip?dl=0
data/input/seattle/osm/washington-latest.osm.pbf,250d9706d97466356e47e613cade7989,https://www.dropbox.com/s/nuastb68n0vi2lv/washington-latest.osm.pbf.zip?dl=0
data/input/seattle/osm/west_seattle.osm,1dda33df0fe65226060164c37d59295c,https://www.dropbox.com/s/j949ws29depbop4/west_seattle.osm.zip?dl=0
data/input/seattle/parcels.bin,37da94a682b27ff5ff863bee1a2cdf70,https://www.dropbox.com/s/fy0aj4bmwz38w5z/parcels.bin.zip?dl=0
data/input/seattle/parcels_urbansim.txt,db63d7d606e8702d12f9399e87e6a00f,https://www.dropbox.com/s/6g8rbsf200dssj3/parcels_urbansim.txt.zip?dl=0
data/input/seattle/popdat.bin,ad38e1f20ce71f488112fe81e32798d2,https://www.dropbox.com/s/ajqii1qpfke8063/popdat.bin.zip?dl=0
data/input/seattle/popdat.bin,1aa2569c7e5a5a4773d7ca706d60432d,https://www.dropbox.com/s/p0g5cohy3p40p71/popdat.bin.zip?dl=0
data/input/seattle/trips_2014.csv,d4a8e733045b28c0385fb81359d6df03,https://www.dropbox.com/s/5ppravwmk6bf20d/trips_2014.csv.zip?dl=0
data/system/cities/seattle.bin,9ed9ff25b3f3941fecf530b3815a1b05,https://www.dropbox.com/s/nwb29tt4koqk6um/seattle.bin.zip?dl=0
data/system/maps/ballard.bin,4e7bcd6fa971da03ba0d7fc87bfb240f,https://www.dropbox.com/s/ec7yg6d2aclcgop/ballard.bin.zip?dl=0
data/system/maps/downtown.bin,789690697d79505522e784b475dcc046,https://www.dropbox.com/s/vpylkr71x6wue0m/downtown.bin.zip?dl=0
data/system/maps/huge_krakow.bin,bb0c97e39ea7142a9856c01f8673b58d,https://www.dropbox.com/s/dnzxcg9lmo0yu1t/huge_krakow.bin.zip?dl=0
data/system/maps/huge_seattle.bin,b8912032d14023f7d2c036e3c119c6cb,https://www.dropbox.com/s/joezpphe2y4xtz0/huge_seattle.bin.zip?dl=0
data/system/maps/lakeslice.bin,968eacb5331034944b3ae90ef14100bb,https://www.dropbox.com/s/g771j6pdkap0vjw/lakeslice.bin.zip?dl=0
data/system/maps/montlake.bin,04faf98ee6e6e40998b46d6dffd71288,https://www.dropbox.com/s/zrkn57g3bfp3ky2/montlake.bin.zip?dl=0
data/system/maps/south_seattle.bin,e3f585a7365048b5a6ad48dd47758017,https://www.dropbox.com/s/022ehrh4r08fsrd/south_seattle.bin.zip?dl=0
data/system/maps/udistrict.bin,864459a858f573f95937a82080278804,https://www.dropbox.com/s/m8quryc6n0ffo3j/udistrict.bin.zip?dl=0
data/system/maps/west_seattle.bin,75f3395beeb04bd477faf2c2efdc017e,https://www.dropbox.com/s/wlg18qsw9sewkji/west_seattle.bin.zip?dl=0
data/system/cities/seattle.bin,7019f93dac8ba704566049f6d253e533,https://www.dropbox.com/s/1k23g2q1nrmbh1m/seattle.bin.zip?dl=0
data/system/maps/ballard.bin,c2f643a65c0b9ecbc8374d1e2cc60bcf,https://www.dropbox.com/s/fil9kcrk5l7r1fn/ballard.bin.zip?dl=0
data/system/maps/downtown.bin,603198543115ae2b72e69d0b1ca96e54,https://www.dropbox.com/s/u1b92n7126strx3/downtown.bin.zip?dl=0
data/system/maps/huge_krakow.bin,27096c2d517cff77476824327546eadb,https://www.dropbox.com/s/qyrjzbl8010a76n/huge_krakow.bin.zip?dl=0
data/system/maps/huge_seattle.bin,21cea6688896df39b84ae8d5295ebe63,https://www.dropbox.com/s/gfylby17ljl6quv/huge_seattle.bin.zip?dl=0
data/system/maps/lakeslice.bin,5e49702c7af8d635f5b0fe2271c1eaa6,https://www.dropbox.com/s/bk5nmfjpya688ao/lakeslice.bin.zip?dl=0
data/system/maps/montlake.bin,c63ec0e9c07fe4d471795def80f595cc,https://www.dropbox.com/s/xph355bczlkv21a/montlake.bin.zip?dl=0
data/system/maps/south_seattle.bin,01aab7ac2da951a8ee146c89f30a918d,https://www.dropbox.com/s/31p4wctn2zu0yfa/south_seattle.bin.zip?dl=0
data/system/maps/udistrict.bin,a967aaa7071c7d89072f2c69d9316eb8,https://www.dropbox.com/s/4l6ti36v11uvowv/udistrict.bin.zip?dl=0
data/system/maps/west_seattle.bin,c39d362ef2d95ece021d009da814aabe,https://www.dropbox.com/s/47e0ovfolaiyojw/west_seattle.bin.zip?dl=0
data/system/prebaked_results/lakeslice/weekday.bin,53ba42ec207e868eab5506e3b7363064,https://www.dropbox.com/s/84wu1rwie10aoce/weekday.bin.zip?dl=0
data/system/prebaked_results/montlake/car vs bike contention.bin,1fac82d6dcd567874fd6e0b106956dd9,https://www.dropbox.com/s/jefg0ikjy9dsrdd/car%20vs%20bike%20contention.bin.zip?dl=0
data/system/prebaked_results/montlake/weekday.bin,d32acd99d4c1fe1792f822da980ddade,https://www.dropbox.com/s/rgi9ovr2j9iep0p/weekday.bin.zip?dl=0
data/system/scenarios/ballard/weekday.bin,ece364faff895fd189e74352fe8626d4,https://www.dropbox.com/s/7wjlqrb5zfifluy/weekday.bin.zip?dl=0
data/system/scenarios/downtown/weekday.bin,68aa6c83137960aa06853596342dbbf0,https://www.dropbox.com/s/ri7gi7fld5qodei/weekday.bin.zip?dl=0
data/system/scenarios/huge_seattle/weekday.bin,63972f6752f4613a1446a3902fededf3,https://www.dropbox.com/s/1n5vhtr447viyxe/weekday.bin.zip?dl=0
data/system/scenarios/lakeslice/weekday.bin,e6c33cc6b5abf817daa04e7bb2b3354a,https://www.dropbox.com/s/zl0v3ymv2lelwkh/weekday.bin.zip?dl=0
data/system/scenarios/montlake/weekday.bin,3b1454d83901a671b0f532c74ca76a3f,https://www.dropbox.com/s/q79la99l7cychba/weekday.bin.zip?dl=0
data/system/scenarios/south_seattle/weekday.bin,ccbf5ac5138bbabef8e9fcf6e6f1900a,https://www.dropbox.com/s/i7fs1kgif8otldz/weekday.bin.zip?dl=0
data/system/scenarios/udistrict/weekday.bin,b18b0ab6b0e13e9f927f557e49edfb0f,https://www.dropbox.com/s/mff06ifv2onx4qx/weekday.bin.zip?dl=0
data/system/scenarios/west_seattle/weekday.bin,211172f12d5e2e93721336bb215b6a55,https://www.dropbox.com/s/o89xmcl5a2r07dl/weekday.bin.zip?dl=0
data/system/prebaked_results/montlake/weekday.bin,f240b53fd33e45a29039553705d8a576,https://www.dropbox.com/s/3wsw4f6kkxvk1sr/weekday.bin.zip?dl=0
data/system/scenarios/ballard/weekday.bin,d2b581d266ee9aa53310daa194427a92,https://www.dropbox.com/s/2zi0nkbx10y8w8b/weekday.bin.zip?dl=0
data/system/scenarios/downtown/weekday.bin,b7b41aa8ab9b80ae0b92ec15ba7a9232,https://www.dropbox.com/s/043aw8ayw6ay17m/weekday.bin.zip?dl=0
data/system/scenarios/huge_seattle/weekday.bin,7fa3e6752fd1d5af6c63d752ccd14171,https://www.dropbox.com/s/xvu146rho6af5r5/weekday.bin.zip?dl=0
data/system/scenarios/lakeslice/weekday.bin,a8747683db13ca949c2765781a742a4a,https://www.dropbox.com/s/v03onrceyzvsdni/weekday.bin.zip?dl=0
data/system/scenarios/montlake/weekday.bin,5196126cec763107224da08cc39149da,https://www.dropbox.com/s/vquzt1jzy39doms/weekday.bin.zip?dl=0
data/system/scenarios/south_seattle/weekday.bin,931639cb0920c79090dbbd5f0f0d9b61,https://www.dropbox.com/s/ts3snue8p5rug80/weekday.bin.zip?dl=0
data/system/scenarios/udistrict/weekday.bin,b1d9ddb99eaa349d5692b020b1e14e65,https://www.dropbox.com/s/u6qr3vusohl2uwt/weekday.bin.zip?dl=0
data/system/scenarios/west_seattle/weekday.bin,0029a60e744fddf299648b331621bafd,https://www.dropbox.com/s/y402to715i8zvyl/weekday.bin.zip?dl=0

View File

@ -18,12 +18,10 @@ pub fn intersection_polygon(
if i.roads.is_empty() {
panic!("{} has no roads", i.id);
}
let mut road_endpts: Vec<Pt2D> = Vec::new();
// Turn all of the incident roads into two PolyLines (the "forwards" and "backwards" borders of
// the road, if the roads were oriented to both be incoming to the intersection), both ending
// at the intersection (which may be different points for merged intersections!), and the last
// segment of the center line.
// at the intersection, and the last segment of the center line.
// TODO Maybe express the two incoming PolyLines as the "right" and "left"
let mut lines: Vec<(OriginalRoad, Line, PolyLine, PolyLine)> = i
.roads
@ -38,22 +36,14 @@ pub fn intersection_polygon(
} else {
panic!("Incident road {} doesn't have an endpoint at {}", id, i.id);
};
road_endpts.push(pl.last_pt());
let pl_normal = driving_side.right_shift(pl.clone(), r.half_width);
let pl_reverse = driving_side.left_shift(pl.clone(), r.half_width);
(*id, pl.last_line(), pl_normal, pl_reverse)
})
.collect();
// Find the average of all road endpoints at the intersection. This is usually just a single
// point, except for merged intersections.
road_endpts.sort_by_key(|pt| pt.to_hashable());
road_endpts.dedup();
let intersection_center = Pt2D::center(&road_endpts);
// Sort the polylines by the angle their last segment makes to the "center". This is normally
// equivalent to the angle of the last line, except when the intersection has been merged.
// Sort the polylines by the angle their last segment makes to the common point.
let intersection_center = lines[0].1.pt2();
lines.sort_by_key(|(_, l, _, _)| {
l.pt1().angle_to(intersection_center).normalized_degrees() as i64
});
@ -74,11 +64,10 @@ fn generalized_trim_back(
) -> (Vec<Pt2D>, Vec<(String, Polygon)>) {
let mut debug = Vec::new();
let mut road_lines: Vec<(OriginalRoad, PolyLine, PolyLine)> = Vec::new();
let mut road_lines: Vec<(OriginalRoad, PolyLine)> = Vec::new();
for (r, _, pl1, pl2) in lines {
// TODO Argh, just use original lines.
road_lines.push((*r, pl1.clone(), pl2.clone()));
road_lines.push((*r, pl2.clone(), pl1.clone()));
road_lines.push((*r, pl1.clone()));
road_lines.push((*r, pl2.clone()));
if false {
debug.push((
@ -92,11 +81,10 @@ fn generalized_trim_back(
}
}
let mut new_road_centers: BTreeMap<OriginalRoad, PolyLine> = BTreeMap::new();
// Intersect every road's boundary lines with all the other lines. Only side effect here is to
// populate new_road_centers.
for (r1, pl1, other_pl1) in &road_lines {
let mut new_road_centers: BTreeMap<OriginalRoad, PolyLine> = BTreeMap::new();
for (r1, pl1) in &road_lines {
// road_center ends at the intersection.
let road_center = if roads[r1].dst_i == i {
roads[r1].trimmed_center_pts.clone()
@ -116,7 +104,7 @@ fn generalized_trim_back(
road_center.clone()
};
for (r2, pl2, _) in &road_lines {
for (r2, pl2) in &road_lines {
if r1 == r2 {
continue;
}
@ -138,10 +126,8 @@ fn generalized_trim_back(
(pl1.clone(), pl2.clone())
};
// TODO This only happens in Austin so far, haven't dove into why.
if use_pl1 == use_pl2 {
timer.warn(format!("{} and {} wind up with the same polyline", r1, r2));
continue;
panic!("{} and {} wind up with the same polyline", r1, r2);
}
if let Some((hit, angle)) = use_pl1.intersection(&use_pl2) {
@ -172,29 +158,6 @@ fn generalized_trim_back(
// We could also do the update for r2, but we'll just get to it later.
}
// Another check... sometimes a boundary line crosss the perpendicular end of another
// road.
// TODO Reduce DEGENERATE_INTERSECTION_HALF_LENGTH to play with this.
if false {
let perp = Line::must_new(pl1.last_pt(), other_pl1.last_pt());
if perp.intersection(&pl2.last_line()).is_some() {
let new_perp = Line::must_new(
pl2.last_pt(),
pl2.last_pt()
.project_away(Distance::meters(1.0), perp.angle()),
)
.infinite();
// Find the hit closest to the intersection -- this matters for very curvy
// roads, like highway ramps.
if let Some(trim_to) = road_center.reversed().intersection_infinite(&new_perp) {
let trimmed = road_center.get_slice_ending_at(trim_to).unwrap();
if trimmed.length() < shortest_center.length() {
shortest_center = trimmed;
}
}
}
}
}
let new_center = if roads[r1].dst_i == i {
@ -231,19 +194,6 @@ fn generalized_trim_back(
{
if let Some((hit, _)) = fwd_pl.second_half().intersection(&adj_fwd_pl.second_half()) {
endpoints.push(hit);
} else {
// Style 1
/*endpoints.push(fwd_pl.last_pt());
endpoints.push(adj_fwd_pl.last_pt());*/
// Style 2
/*if let Some(hit) = fwd_pl
.last_line()
.infinite()
.intersection(&adj_fwd_pl.last_line().infinite())
{
endpoints.push(hit);
}*/
}
} else {
timer.warn(format!(
@ -286,19 +236,6 @@ fn generalized_trim_back(
.intersection(&adj_back_pl.second_half())
{
endpoints.push(hit);
} else {
// Style 1
/*endpoints.push(back_pl.last_pt());
endpoints.push(adj_back_pl.last_pt());*/
// Style 2
/*if let Some(hit) = back_pl
.last_line()
.infinite()
.intersection(&adj_back_pl.last_line().infinite())
{
endpoints.push(hit);
}*/
}
} else {
timer.warn(format!(
@ -307,22 +244,12 @@ fn generalized_trim_back(
id
));
}
/*if *id == OriginalRoad(384) {
let thin = Distance::meters(1.0);
debug.push((format!("back of {}", id), back_pl.make_polygons(thin)));
debug.push((
format!("adj back of {}", adj_back_id),
adj_back_pl.make_polygons(thin),
));
}*/
}
let main_result = close_off_polygon(Pt2D::approx_dedupe(endpoints, Distance::meters(0.1)));
// There are bad polygons caused by weird short roads. As a temporary workaround, detect cases
// where polygons dramatically double back on themselves and force the polygon to proceed
// around its center.
let main_result = close_off_polygon(Pt2D::approx_dedupe(endpoints, Distance::meters(0.1)));
let mut deduped = main_result.clone();
deduped.pop();
deduped.sort_by_key(|pt| pt.to_hashable());
@ -341,7 +268,7 @@ fn generalized_trim_back(
(deduped, debug)
}
// TODO Or always sort points?
// TODO Or always sort points? Helps some cases, hurts other for downtown Seattle.
/*endpoints.sort_by_key(|pt| pt.to_hashable());
endpoints = Pt2D::approx_dedupe(endpoints, Distance::meters(0.1));
let center = Pt2D::center(&endpoints);

View File

@ -1256,6 +1256,9 @@ impl TripManager {
pub fn all_arrivals_at_border(&self, at: IntersectionID) -> Vec<(Time, TripMode)> {
let mut times = Vec::new();
for t in &self.trips {
if t.aborted {
continue;
}
if let TripEndpoint::Border(i, _) = t.start {
if i == at {
times.push((t.departure, t.mode));