mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-25 15:33:44 +03:00
Draw corners where shoulders and sidewalks meet more carefully.
This commit is contained in:
parent
0344e51170
commit
9eea3c9247
@ -536,9 +536,9 @@
|
|||||||
"compressed_size_bytes": 3242506
|
"compressed_size_bytes": 3242506
|
||||||
},
|
},
|
||||||
"data/input/gb/great_kneighton/screenshots/center.zip": {
|
"data/input/gb/great_kneighton/screenshots/center.zip": {
|
||||||
"checksum": "cce62738db1dd92440bc74e3dd9a136b",
|
"checksum": "a08d6da6f4d628b1936e0e33e3e859b7",
|
||||||
"uncompressed_size_bytes": 39127370,
|
"uncompressed_size_bytes": 39131751,
|
||||||
"compressed_size_bytes": 39111583
|
"compressed_size_bytes": 39116018
|
||||||
},
|
},
|
||||||
"data/input/gb/hampton/osm/cambridgeshire-latest.osm.pbf": {
|
"data/input/gb/hampton/osm/cambridgeshire-latest.osm.pbf": {
|
||||||
"checksum": "c4ec8f81dc604526443750f695886ebf",
|
"checksum": "c4ec8f81dc604526443750f695886ebf",
|
||||||
@ -996,9 +996,9 @@
|
|||||||
"compressed_size_bytes": 3865424
|
"compressed_size_bytes": 3865424
|
||||||
},
|
},
|
||||||
"data/input/pl/krakow/screenshots/center.zip": {
|
"data/input/pl/krakow/screenshots/center.zip": {
|
||||||
"checksum": "ead5a241b2afa3336d8f11ee0b2e59af",
|
"checksum": "cda45914d3783c17769d57060b65d344",
|
||||||
"uncompressed_size_bytes": 28338189,
|
"uncompressed_size_bytes": 28541114,
|
||||||
"compressed_size_bytes": 28333173
|
"compressed_size_bytes": 28536036
|
||||||
},
|
},
|
||||||
"data/input/pl/warsaw/osm/center.osm": {
|
"data/input/pl/warsaw/osm/center.osm": {
|
||||||
"checksum": "b41830dd375674ffc9f7ec15d6cf9c0c",
|
"checksum": "b41830dd375674ffc9f7ec15d6cf9c0c",
|
||||||
@ -1396,24 +1396,24 @@
|
|||||||
"compressed_size_bytes": 6234114
|
"compressed_size_bytes": 6234114
|
||||||
},
|
},
|
||||||
"data/input/us/seattle/screenshots/downtown.zip": {
|
"data/input/us/seattle/screenshots/downtown.zip": {
|
||||||
"checksum": "3b4f6486f5b842183492fcc7c4353c46",
|
"checksum": "981a0b2d1af0f3bc3ac1acc0f5646120",
|
||||||
"uncompressed_size_bytes": 22571887,
|
"uncompressed_size_bytes": 22566418,
|
||||||
"compressed_size_bytes": 22563432
|
"compressed_size_bytes": 22558043
|
||||||
},
|
},
|
||||||
"data/input/us/seattle/screenshots/lakeslice.zip": {
|
"data/input/us/seattle/screenshots/lakeslice.zip": {
|
||||||
"checksum": "764afab8073128dadae08ac60d766769",
|
"checksum": "7b5fabeb176ab7e6223c1549e36fa3b2",
|
||||||
"uncompressed_size_bytes": 21970128,
|
"uncompressed_size_bytes": 22210060,
|
||||||
"compressed_size_bytes": 21963553
|
"compressed_size_bytes": 22203619
|
||||||
},
|
},
|
||||||
"data/input/us/seattle/screenshots/montlake.zip": {
|
"data/input/us/seattle/screenshots/montlake.zip": {
|
||||||
"checksum": "4900bdfdda7b477e181a723e4763891f",
|
"checksum": "b2c7cc9ae9e982ab0881397813e2a7b3",
|
||||||
"uncompressed_size_bytes": 4326100,
|
"uncompressed_size_bytes": 4324585,
|
||||||
"compressed_size_bytes": 4325840
|
"compressed_size_bytes": 4324336
|
||||||
},
|
},
|
||||||
"data/input/us/seattle/screenshots/udistrict.zip": {
|
"data/input/us/seattle/screenshots/udistrict.zip": {
|
||||||
"checksum": "182944dbdf70f24edc8b0f62847e7c40",
|
"checksum": "5d2a932a8b44588c079e8ce33bffa894",
|
||||||
"uncompressed_size_bytes": 10597038,
|
"uncompressed_size_bytes": 10592157,
|
||||||
"compressed_size_bytes": 10593822
|
"compressed_size_bytes": 10588951
|
||||||
},
|
},
|
||||||
"data/input/us/seattle/trips_2014.csv": {
|
"data/input/us/seattle/trips_2014.csv": {
|
||||||
"checksum": "d4a8e733045b28c0385fb81359d6df03",
|
"checksum": "d4a8e733045b28c0385fb81359d6df03",
|
||||||
|
@ -229,37 +229,50 @@ pub fn calculate_corners(i: &Intersection, map: &Map) -> Vec<Polygon> {
|
|||||||
if map.get_l(turn.id.src).dst_i != i.id {
|
if map.get_l(turn.id.src).dst_i != i.id {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let width = map
|
|
||||||
.get_l(turn.id.src)
|
|
||||||
.width
|
|
||||||
.min(map.get_l(turn.id.dst).width);
|
|
||||||
|
|
||||||
// Special case for dead-ends: just thicken the geometry.
|
|
||||||
if i.roads.len() == 1 {
|
|
||||||
corners.push(turn.geom.make_polygons(width));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
let l1 = map.get_l(turn.id.src);
|
let l1 = map.get_l(turn.id.src);
|
||||||
let l2 = map.get_l(turn.id.dst);
|
let l2 = map.get_l(turn.id.dst);
|
||||||
|
|
||||||
if let Some(poly) = (|| {
|
// Special case for dead-ends: just thicken the geometry.
|
||||||
let mut pts = turn.geom.shift_left(width / 2.0).ok()?.into_points();
|
if i.roads.len() == 1 {
|
||||||
pts.push(l2.first_line().shift_left(width / 2.0).pt1());
|
corners.push(turn.geom.make_polygons(l1.width.min(l2.width)));
|
||||||
pts.push(l2.first_line().shift_right(width / 2.0).pt1());
|
continue;
|
||||||
pts.extend(
|
}
|
||||||
turn.geom
|
|
||||||
.shift_right(width / 2.0)
|
if l1.width == l2.width {
|
||||||
.ok()?
|
// When two sidewalks or two shoulders meet, use the turn geometry to create some
|
||||||
.reversed()
|
// nice rounding.
|
||||||
.into_points(),
|
let width = l1.width;
|
||||||
);
|
if let Some(poly) = (|| {
|
||||||
pts.push(l1.last_line().shift_right(width / 2.0).pt2());
|
let mut pts = turn.geom.shift_left(width / 2.0).ok()?.into_points();
|
||||||
pts.push(l1.last_line().shift_left(width / 2.0).pt2());
|
pts.push(l2.first_line().shift_left(width / 2.0).pt1());
|
||||||
|
pts.push(l2.first_line().shift_right(width / 2.0).pt1());
|
||||||
|
pts.extend(
|
||||||
|
turn.geom
|
||||||
|
.shift_right(width / 2.0)
|
||||||
|
.ok()?
|
||||||
|
.reversed()
|
||||||
|
.into_points(),
|
||||||
|
);
|
||||||
|
pts.push(l1.last_line().shift_right(width / 2.0).pt2());
|
||||||
|
pts.push(l1.last_line().shift_left(width / 2.0).pt2());
|
||||||
|
pts.push(pts[0]);
|
||||||
|
// Many resulting shapes aren't valid rings, but we can still triangulate them.
|
||||||
|
Some(Polygon::buggy_new(pts))
|
||||||
|
})() {
|
||||||
|
corners.push(poly);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// When a sidewalk and a shoulder meet, use a simpler shape to connect them.
|
||||||
|
let mut pts = vec![
|
||||||
|
l2.first_line().shift_left(l2.width / 2.0).pt1(),
|
||||||
|
l2.first_line().shift_right(l2.width / 2.0).pt1(),
|
||||||
|
l1.last_line().shift_right(l1.width / 2.0).pt2(),
|
||||||
|
l1.last_line().shift_left(l1.width / 2.0).pt2(),
|
||||||
|
];
|
||||||
pts.push(pts[0]);
|
pts.push(pts[0]);
|
||||||
Some(Polygon::buggy_new(pts))
|
if let Ok(ring) = Ring::new(pts) {
|
||||||
})() {
|
corners.push(ring.to_polygon());
|
||||||
corners.push(poly);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user