mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-24 09:24:26 +03:00
Fix parking aisle loops that cross the parking lot polygon. Closes #242
This commit is contained in:
parent
b54f26b631
commit
2e93fdbf54
@ -105,7 +105,7 @@ pub fn extract_osm(map: &mut RawMap, opts: &Options, timer: &mut Timer) -> OsmEx
|
||||
continue;
|
||||
} else if way.tags.is(osm::HIGHWAY, "service") {
|
||||
// If we got here, is_road didn't interpret it as a normal road
|
||||
map.parking_aisles.push(way.pts.clone());
|
||||
map.parking_aisles.push((id, way.pts.clone()));
|
||||
|
||||
extra_service_roads.shapes.push(ExtraShape {
|
||||
points: map.gps_bounds.convert_back(&way.pts),
|
||||
|
@ -285,7 +285,11 @@ pub fn snap_bus_stops(
|
||||
// If this road is missing a sidewalk (likely because it's a motorway), add one.
|
||||
// https://www.openstreetmap.org/way/325148569 is a motivating example. When we understand
|
||||
// bus platforms properly, won't need this hack.
|
||||
let tags = &mut raw.roads.get_mut(&road).unwrap().osm_tags;
|
||||
let tags = &mut raw
|
||||
.roads
|
||||
.get_mut(&road)
|
||||
.ok_or_else(|| format!("{} isn't an extracted road", road))?
|
||||
.osm_tags;
|
||||
if tags.is(osm::INFERRED_SIDEWALKS, "true") {
|
||||
let current = tags.get(osm::SIDEWALK).unwrap();
|
||||
if current == "none" {
|
||||
|
@ -9,22 +9,22 @@ data/input/krakow/footways.bin,017e85fd6da69b67a1a7a790506f52ff,https://www.drop
|
||||
data/input/krakow/osm/krakow_center.osm,b914bbcd42a7f769a40a90970cea35f2,https://www.dropbox.com/s/pf3avtszpw732jd/krakow_center.osm.zip?dl=0
|
||||
data/input/krakow/osm/malopolskie-latest.osm.pbf,9505917bbacc478177e36605e89b6d77,https://www.dropbox.com/s/vehjfvwx25v1qnd/malopolskie-latest.osm.pbf.zip?dl=0
|
||||
data/input/krakow/service_roads.bin,a6a5d22bb3dba66b5a4cad72f6842eb9,https://www.dropbox.com/s/is31c2ejl8nun28/service_roads.bin.zip?dl=0
|
||||
data/input/raw_maps/ballard.bin,646afc62183790fe1376f94cf9f4518b,https://www.dropbox.com/s/c0u96d6yvwtf428/ballard.bin.zip?dl=0
|
||||
data/input/raw_maps/berlin_center.bin,da2682d471bc09b02dee69caafe0932d,https://www.dropbox.com/s/3wrvekhmj5yite2/berlin_center.bin.zip?dl=0
|
||||
data/input/raw_maps/downtown.bin,a012a63cde86974a6c372dd9a49df301,https://www.dropbox.com/s/qazd051i04up5tl/downtown.bin.zip?dl=0
|
||||
data/input/raw_maps/huge_seattle.bin,b2a45d49ffc653854e1a52f811afa372,https://www.dropbox.com/s/eeupo17y7hyvinm/huge_seattle.bin.zip?dl=0
|
||||
data/input/raw_maps/krakow_center.bin,34198594517edfc83ff4b62ffb12bafd,https://www.dropbox.com/s/v03ssy0fgfn2v8l/krakow_center.bin.zip?dl=0
|
||||
data/input/raw_maps/lakeslice.bin,276f94e9ecc39c25f1c5a808433b9a96,https://www.dropbox.com/s/tiim8m72q135id7/lakeslice.bin.zip?dl=0
|
||||
data/input/raw_maps/montlake.bin,73922ac812b537daeef40068c01cce8d,https://www.dropbox.com/s/vdslqoicc6o5cr9/montlake.bin.zip?dl=0
|
||||
data/input/raw_maps/south_seattle.bin,7881e280e2f5d72f00147c0c10f305c4,https://www.dropbox.com/s/6cd15ll3c61ayk0/south_seattle.bin.zip?dl=0
|
||||
data/input/raw_maps/udistrict.bin,2208dd4d8adc416b76693b46ee15146f,https://www.dropbox.com/s/04xwvvr0mryr945/udistrict.bin.zip?dl=0
|
||||
data/input/raw_maps/west_seattle.bin,adc409ea690442ee85cb587b211711f1,https://www.dropbox.com/s/jy0gnzkkpmz47m8/west_seattle.bin.zip?dl=0
|
||||
data/input/raw_maps/ballard.bin,0b5da4a0452e430a5022155434cceb27,https://www.dropbox.com/s/1q4cw64db6f9tbh/ballard.bin.zip?dl=0
|
||||
data/input/raw_maps/berlin_center.bin,a0250354241babf125ba73165a67a711,https://www.dropbox.com/s/zdsmujzk6y9y1te/berlin_center.bin.zip?dl=0
|
||||
data/input/raw_maps/downtown.bin,84d213f4276646657cd5fcb032913b4f,https://www.dropbox.com/s/vpls0ejra51u9md/downtown.bin.zip?dl=0
|
||||
data/input/raw_maps/huge_seattle.bin,f64a9d0cda9a792c4235391045c1a5eb,https://www.dropbox.com/s/h9xz3a1p4haoep6/huge_seattle.bin.zip?dl=0
|
||||
data/input/raw_maps/krakow_center.bin,3dd41c5750b806f279c7c17e24e03c17,https://www.dropbox.com/s/3dbqhhcwfyo4r9c/krakow_center.bin.zip?dl=0
|
||||
data/input/raw_maps/lakeslice.bin,921750ab58f2b823f617f1ba647f9842,https://www.dropbox.com/s/tzzr1kbwjps4u1p/lakeslice.bin.zip?dl=0
|
||||
data/input/raw_maps/montlake.bin,f9e296121b0768014746972541535c2d,https://www.dropbox.com/s/mhn879ielih1dcg/montlake.bin.zip?dl=0
|
||||
data/input/raw_maps/south_seattle.bin,b742339572f0061cf7b9582224973afe,https://www.dropbox.com/s/1jxepx4ioagmhgg/south_seattle.bin.zip?dl=0
|
||||
data/input/raw_maps/udistrict.bin,800a2082062e81428ff29624f05a71e5,https://www.dropbox.com/s/hhc4n8gk6h6p9bs/udistrict.bin.zip?dl=0
|
||||
data/input/raw_maps/west_seattle.bin,d096c02526da41ab7cbed3884e942f48,https://www.dropbox.com/s/ze3wcrq1rj0a6ab/west_seattle.bin.zip?dl=0
|
||||
data/input/raw_maps/xian.bin,e3e8b30278c89a5954b737b2442dffea,https://www.dropbox.com/s/d3n7gtuctmq4vji/xian.bin.zip?dl=0
|
||||
data/input/screenshots/downtown.zip,43c3b8bc849c821ada33b06caf72f847,https://www.dropbox.com/s/qawd35wz62m2acl/downtown.zip.zip?dl=0
|
||||
data/input/screenshots/krakow_center.zip,31b8f51826b4c5e5866327ea3bf30fd8,https://www.dropbox.com/s/azea6v6mnxbe0vc/krakow_center.zip.zip?dl=0
|
||||
data/input/screenshots/lakeslice.zip,6030ef70e37a777f930e6a6a0bd32d17,https://www.dropbox.com/s/06mwgdt6orow3rk/lakeslice.zip.zip?dl=0
|
||||
data/input/screenshots/montlake.zip,104c6eac3004589aa1dac970df9f34c5,https://www.dropbox.com/s/eblgq5zj3gflhwx/montlake.zip.zip?dl=0
|
||||
data/input/screenshots/udistrict.zip,4e992be0bddeba62177ca39d23477384,https://www.dropbox.com/s/ecnt1tyza48y9o2/udistrict.zip.zip?dl=0
|
||||
data/input/screenshots/downtown.zip,4ab38372458c65cd173b7700f9db5e55,https://www.dropbox.com/s/qawd35wz62m2acl/downtown.zip.zip?dl=0
|
||||
data/input/screenshots/krakow_center.zip,93decd22f642acc6d5b7273424e894df,https://www.dropbox.com/s/azea6v6mnxbe0vc/krakow_center.zip.zip?dl=0
|
||||
data/input/screenshots/lakeslice.zip,0bcc0361d399e94becbb488f7a7c7926,https://www.dropbox.com/s/06mwgdt6orow3rk/lakeslice.zip.zip?dl=0
|
||||
data/input/screenshots/montlake.zip,52f80ff4a2d4ef0cd7bf1240bd43f3d6,https://www.dropbox.com/s/eblgq5zj3gflhwx/montlake.zip.zip?dl=0
|
||||
data/input/screenshots/udistrict.zip,d466ad472bf967ed3e854c41c7be6c6c,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
|
||||
@ -62,25 +62,25 @@ data/input/xian/osm/china-latest.osm.pbf,0108807f1dc321d5de5579622ac3f4cf,https:
|
||||
data/input/xian/osm/xian.osm,4084c665ad947bb40173a43cb33fdec8,https://www.dropbox.com/s/j5qwt33bs077sd2/xian.osm.zip?dl=0
|
||||
data/input/xian/service_roads.bin,2130675f49282a5e9fe3db870b089e98,https://www.dropbox.com/s/5djufzeqgdp43ek/service_roads.bin.zip?dl=0
|
||||
data/system/cities/seattle.bin,4c23d8a7fbf0981a65c7e9499a1c7185,https://www.dropbox.com/s/1vg3138khp81kyi/seattle.bin.zip?dl=0
|
||||
data/system/maps/ballard.bin,1ff13ad11bbfac8137d96235015373b6,https://www.dropbox.com/s/n7oghzcfbye9fml/ballard.bin.zip?dl=0
|
||||
data/system/maps/berlin_center.bin,ace7bb9c6dba31958a43c89eb47aa9e6,https://www.dropbox.com/s/824wuz69ekmm9is/berlin_center.bin.zip?dl=0
|
||||
data/system/maps/downtown.bin,223d435838567a178047ef27240c3e55,https://www.dropbox.com/s/w21k0kv1vde2f4a/downtown.bin.zip?dl=0
|
||||
data/system/maps/huge_seattle.bin,72298166b3a62e5948027eace7ceeefb,https://www.dropbox.com/s/k8vuefb4vnfzii3/huge_seattle.bin.zip?dl=0
|
||||
data/system/maps/krakow_center.bin,ed9352c460b6a160d3bcf13bc241ec99,https://www.dropbox.com/s/72w3xpk7lfxp4m6/krakow_center.bin.zip?dl=0
|
||||
data/system/maps/lakeslice.bin,ecfc2cea5e489cf818b45970c00e57e3,https://www.dropbox.com/s/jc5hmrolgynd4h5/lakeslice.bin.zip?dl=0
|
||||
data/system/maps/montlake.bin,653d0b2f30b659bf37817fe52ea21968,https://www.dropbox.com/s/jggn4swppwtz1k3/montlake.bin.zip?dl=0
|
||||
data/system/maps/south_seattle.bin,4e7d70c334bd805da68d6e85e03c04f3,https://www.dropbox.com/s/2mhx2n88xjfaz3l/south_seattle.bin.zip?dl=0
|
||||
data/system/maps/ballard.bin,46c69f175206e07db8a9e2f4e34c68b8,https://www.dropbox.com/s/mxw5linw3gzaa1n/ballard.bin.zip?dl=0
|
||||
data/system/maps/berlin_center.bin,2eb5d0d161fafdc88b38635d4f864334,https://www.dropbox.com/s/04nelwk5p3zywm8/berlin_center.bin.zip?dl=0
|
||||
data/system/maps/downtown.bin,1a1d7f34428e6d0c992a6c0c24587a99,https://www.dropbox.com/s/cfeht5uebk0mlsm/downtown.bin.zip?dl=0
|
||||
data/system/maps/huge_seattle.bin,03f7da0685d3cbbfbd102bd5d8f207bd,https://www.dropbox.com/s/4voa0b9u4nc2taz/huge_seattle.bin.zip?dl=0
|
||||
data/system/maps/krakow_center.bin,cc20d659f62d2f6181642202040862e8,https://www.dropbox.com/s/l0nepc3knk5zi3l/krakow_center.bin.zip?dl=0
|
||||
data/system/maps/lakeslice.bin,56f917514799237684f47d431ebfc34c,https://www.dropbox.com/s/xb7y5m3wc69u45l/lakeslice.bin.zip?dl=0
|
||||
data/system/maps/montlake.bin,1f2456d3cae43a08715d0529ff215f70,https://www.dropbox.com/s/5zkve80em6pw4at/montlake.bin.zip?dl=0
|
||||
data/system/maps/south_seattle.bin,274b8f9d532d83491cd03edff7c02f26,https://www.dropbox.com/s/rxzpzxgb6shdu7n/south_seattle.bin.zip?dl=0
|
||||
data/system/maps/udistrict.bin,0b05788c8d3b9170558b8588c1ab6e03,https://www.dropbox.com/s/jfqjxfhrp2hvc2p/udistrict.bin.zip?dl=0
|
||||
data/system/maps/west_seattle.bin,c4960ab69538b119377ee8345fb073dc,https://www.dropbox.com/s/wjit26emy6p71m9/west_seattle.bin.zip?dl=0
|
||||
data/system/maps/west_seattle.bin,830c9f6c2e54ccf5fbe1fb8aa14278e9,https://www.dropbox.com/s/gajnhwbyudl8i6e/west_seattle.bin.zip?dl=0
|
||||
data/system/maps/xian.bin,a63be02191cd100b5a00a3469f4dbbdd,https://www.dropbox.com/s/9hfwjzrg0b5l6oe/xian.bin.zip?dl=0
|
||||
data/system/prebaked_results/lakeslice/weekday.bin,f5bae6db7cbb443a255016d46bdd400b,https://www.dropbox.com/s/rpz6rjipi0dy688/weekday.bin.zip?dl=0
|
||||
data/system/prebaked_results/lakeslice/weekday.bin,d5448fc0463b80af9611cf3948c58be9,https://www.dropbox.com/s/g6sy505evz4utv6/weekday.bin.zip?dl=0
|
||||
data/system/prebaked_results/montlake/car vs bike contention.bin,faa041af70a41bb8fcacd3dfd7a7d467,https://www.dropbox.com/s/jefg0ikjy9dsrdd/car%20vs%20bike%20contention.bin.zip?dl=0
|
||||
data/system/prebaked_results/montlake/weekday.bin,91831b8fda857deeaedf3a03be3e2bcd,https://www.dropbox.com/s/xk51cbpivk7q196/weekday.bin.zip?dl=0
|
||||
data/system/scenarios/ballard/weekday.bin,96e998ef8b9364e8f2bd7c1b6823ed94,https://www.dropbox.com/s/v1mti248uptfvsb/weekday.bin.zip?dl=0
|
||||
data/system/scenarios/downtown/weekday.bin,3f7686bfa8370ffbb19243b6a1cf65d6,https://www.dropbox.com/s/ok9egknbigctu03/weekday.bin.zip?dl=0
|
||||
data/system/prebaked_results/montlake/weekday.bin,2c4c697099764fda20555dc82cdb4fda,https://www.dropbox.com/s/fw61gu07uuhr9rq/weekday.bin.zip?dl=0
|
||||
data/system/scenarios/ballard/weekday.bin,8fba0bf4e623552d75c27e9c210ce469,https://www.dropbox.com/s/62pwtz3pn098v84/weekday.bin.zip?dl=0
|
||||
data/system/scenarios/downtown/weekday.bin,d789b5b7fe2a536f65ae330abb575823,https://www.dropbox.com/s/2ia9ssy9gza86sw/weekday.bin.zip?dl=0
|
||||
data/system/scenarios/huge_seattle/weekday.bin,9892f03c2998b3661384f086dbc6c4bb,https://www.dropbox.com/s/hk3sr90owfr3hzc/weekday.bin.zip?dl=0
|
||||
data/system/scenarios/lakeslice/weekday.bin,92a975e89afcbb7b9a5531bb25b2db8d,https://www.dropbox.com/s/zwzwxh1gegopdjb/weekday.bin.zip?dl=0
|
||||
data/system/scenarios/montlake/weekday.bin,5160439e9720167376af73b342af3a35,https://www.dropbox.com/s/musq1buw0bgukbp/weekday.bin.zip?dl=0
|
||||
data/system/scenarios/south_seattle/weekday.bin,29bd9a85974f3769c09c1a934c6c4173,https://www.dropbox.com/s/s24l6z9aksxv3ns/weekday.bin.zip?dl=0
|
||||
data/system/scenarios/udistrict/weekday.bin,bdb1afc5d1fa02df30b9a55617fc9f91,https://www.dropbox.com/s/50b94nliahpwnp2/weekday.bin.zip?dl=0
|
||||
data/system/scenarios/west_seattle/weekday.bin,030e858096317643991454c835117a15,https://www.dropbox.com/s/yeht4luur7bn7jv/weekday.bin.zip?dl=0
|
||||
data/system/scenarios/lakeslice/weekday.bin,6f4a4c8b976b93704398e944bece92da,https://www.dropbox.com/s/e6qec5upp06kw1s/weekday.bin.zip?dl=0
|
||||
data/system/scenarios/montlake/weekday.bin,b5517f6dd4dd8dc39719a54537e0bab9,https://www.dropbox.com/s/pq1wjy1sihp0b5u/weekday.bin.zip?dl=0
|
||||
data/system/scenarios/south_seattle/weekday.bin,1a49ff2f0629105ab2a1298fe32ac3d4,https://www.dropbox.com/s/2bs00g1w9xeyx3e/weekday.bin.zip?dl=0
|
||||
data/system/scenarios/udistrict/weekday.bin,2fed03d12b2833c2b3e1f702badd4dde,https://www.dropbox.com/s/575kjedo59o372j/weekday.bin.zip?dl=0
|
||||
data/system/scenarios/west_seattle/weekday.bin,787147afc60160897ec2e6914f5a83b8,https://www.dropbox.com/s/vj525vlvdiy75m5/weekday.bin.zip?dl=0
|
||||
|
10
data/other_polygons/shinjuku.poly
Normal file
10
data/other_polygons/shinjuku.poly
Normal file
@ -0,0 +1,10 @@
|
||||
shinjuku
|
||||
1
|
||||
139.6963119506836 35.7381525002691
|
||||
139.67897415161133 35.71223166737142
|
||||
139.6798324584961 35.65297231312245
|
||||
139.74712371826172 35.64822966366532
|
||||
139.77716445922852 35.68504754570482
|
||||
139.6963119506836 35.7381525002691
|
||||
END
|
||||
END
|
@ -352,14 +352,39 @@ impl Polygon {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO Doesn't really handle anything but the simplest case right now
|
||||
// TODO Only handles a few cases
|
||||
pub fn clip_ring(&self, input: &Ring) -> Option<Vec<Pt2D>> {
|
||||
for pt in input.points() {
|
||||
if !self.contains_pt(*pt) {
|
||||
return None;
|
||||
let ring = Ring::must_new(self.points.clone());
|
||||
let hits = ring.all_intersections(&PolyLine::unchecked_new(input.clone().into_points()));
|
||||
|
||||
if hits.len() == 0 {
|
||||
// If the first point is inside, then all must be
|
||||
if self.contains_pt(input.points()[0]) {
|
||||
return Some(input.points().clone());
|
||||
}
|
||||
} else if hits.len() == 2 {
|
||||
let (pl1, pl2) = input.get_both_slices_btwn(hits[0], hits[1])?;
|
||||
|
||||
// One of these should be partly outside the polygon. The endpoints won't be in the
|
||||
// polygon itself, but they'll be on the ring.
|
||||
if pl1
|
||||
.points()
|
||||
.iter()
|
||||
.all(|pt| self.contains_pt(*pt) || ring.contains_pt(*pt))
|
||||
{
|
||||
return Some(pl1.into_points());
|
||||
}
|
||||
if pl2
|
||||
.points()
|
||||
.iter()
|
||||
.all(|pt| self.contains_pt(*pt) || ring.contains_pt(*pt))
|
||||
{
|
||||
return Some(pl2.into_points());
|
||||
}
|
||||
// Huh?
|
||||
}
|
||||
Some(input.points().clone())
|
||||
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -265,19 +265,22 @@ impl PolyLine {
|
||||
// No excess leftover distance allowed.
|
||||
// TODO Lot of callers of this. Make safer later.
|
||||
pub fn exact_slice(&self, start: Distance, end: Distance) -> PolyLine {
|
||||
self.maybe_exact_slice(start, end).unwrap()
|
||||
}
|
||||
pub fn maybe_exact_slice(&self, start: Distance, end: Distance) -> Result<PolyLine, String> {
|
||||
let (pl, leftover) = self
|
||||
.slice(start, end)
|
||||
.unwrap_or_else(|_| panic!("exact_slice({}, {}) yielded empty slice", start, end));
|
||||
.map_err(|_| format!("exact_slice({}, {}) yielded empty slice", start, end))?;
|
||||
if leftover > EPSILON_DIST {
|
||||
panic!(
|
||||
return Err(format!(
|
||||
"exact_slice({}, {}) on a PL of length {} yielded leftover distance of {}",
|
||||
start,
|
||||
end,
|
||||
self.length(),
|
||||
leftover
|
||||
);
|
||||
));
|
||||
}
|
||||
pl
|
||||
Ok(pl)
|
||||
}
|
||||
|
||||
pub fn first_half(&self) -> PolyLine {
|
||||
|
@ -79,7 +79,7 @@ impl Ring {
|
||||
hits
|
||||
}
|
||||
|
||||
pub fn get_shorter_slice_btwn(&self, pt1: Pt2D, pt2: Pt2D) -> PolyLine {
|
||||
pub fn get_both_slices_btwn(&self, pt1: Pt2D, pt2: Pt2D) -> Option<(PolyLine, PolyLine)> {
|
||||
assert!(pt1 != pt2);
|
||||
let pl = PolyLine::unchecked_new(self.pts.clone());
|
||||
|
||||
@ -88,11 +88,20 @@ impl Ring {
|
||||
if dist1 > dist2 {
|
||||
std::mem::swap(&mut dist1, &mut dist2);
|
||||
}
|
||||
if dist1 == dist2 {
|
||||
return None;
|
||||
}
|
||||
|
||||
let candidate1 = pl.exact_slice(dist1, dist2);
|
||||
let candidate1 = pl.maybe_exact_slice(dist1, dist2).ok()?;
|
||||
let candidate2 = pl
|
||||
.exact_slice(dist2, pl.length())
|
||||
.must_extend(pl.exact_slice(Distance::ZERO, dist1));
|
||||
.maybe_exact_slice(dist2, pl.length())
|
||||
.ok()?
|
||||
.must_extend(pl.maybe_exact_slice(Distance::ZERO, dist1).ok()?);
|
||||
Some((candidate1, candidate2))
|
||||
}
|
||||
|
||||
pub fn get_shorter_slice_btwn(&self, pt1: Pt2D, pt2: Pt2D) -> PolyLine {
|
||||
let (candidate1, candidate2) = self.get_both_slices_btwn(pt1, pt2).unwrap();
|
||||
if candidate1.length() < candidate2.length() {
|
||||
candidate1
|
||||
} else {
|
||||
@ -131,6 +140,12 @@ impl Ring {
|
||||
}
|
||||
Ok((polylines, rings))
|
||||
}
|
||||
|
||||
pub fn contains_pt(&self, pt: Pt2D) -> bool {
|
||||
PolyLine::unchecked_new(self.pts.clone())
|
||||
.dist_along_of_point(pt)
|
||||
.is_some()
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Ring {
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::make::match_points_to_lanes;
|
||||
use crate::raw::RawParkingLot;
|
||||
use crate::{
|
||||
Map, ParkingLot, ParkingLotID, PathConstraints, Position, NORMAL_LANE_THICKNESS,
|
||||
osm, Map, ParkingLot, ParkingLotID, PathConstraints, Position, NORMAL_LANE_THICKNESS,
|
||||
PARKING_LOT_SPOT_LENGTH,
|
||||
};
|
||||
use abstutil::Timer;
|
||||
@ -10,7 +10,7 @@ use std::collections::HashSet;
|
||||
|
||||
pub fn make_all_parking_lots(
|
||||
input: &Vec<RawParkingLot>,
|
||||
aisles: &Vec<Vec<Pt2D>>,
|
||||
aisles: &Vec<(osm::WayID, Vec<Pt2D>)>,
|
||||
map: &Map,
|
||||
timer: &mut Timer,
|
||||
) -> Vec<ParkingLot> {
|
||||
@ -106,7 +106,7 @@ pub fn make_all_parking_lots(
|
||||
closest.add(lot.id, lot.polygon.points());
|
||||
}
|
||||
timer.start_iter("match parking aisles", aisles.len());
|
||||
for pts in aisles {
|
||||
for (aisle_id, pts) in aisles {
|
||||
timer.next();
|
||||
// Use the center of all the aisle points to match it to a lot
|
||||
let candidates: Vec<ParkingLotID> = closest
|
||||
@ -115,27 +115,34 @@ pub fn make_all_parking_lots(
|
||||
.map(|(id, _, _)| id)
|
||||
.collect();
|
||||
|
||||
if let Ok((polylines, rings)) = Ring::split_points(pts) {
|
||||
'PL: for pl in polylines {
|
||||
for id in &candidates {
|
||||
let lot = &mut results[id.0];
|
||||
for segment in lot.polygon.clip_polyline(&pl) {
|
||||
lot.aisles.push(segment);
|
||||
continue 'PL;
|
||||
match Ring::split_points(pts) {
|
||||
Ok((polylines, rings)) => {
|
||||
'PL: for pl in polylines {
|
||||
for id in &candidates {
|
||||
let lot = &mut results[id.0];
|
||||
if let Some(segment) = lot.polygon.clip_polyline(&pl) {
|
||||
lot.aisles.push(segment);
|
||||
continue 'PL;
|
||||
}
|
||||
}
|
||||
}
|
||||
'RING: for ring in rings {
|
||||
for id in &candidates {
|
||||
let lot = &mut results[id.0];
|
||||
if let Some(segment) = lot.polygon.clip_ring(&ring) {
|
||||
lot.aisles.push(segment);
|
||||
continue 'RING;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
'RING: for ring in rings {
|
||||
for id in &candidates {
|
||||
let lot = &mut results[id.0];
|
||||
for segment in lot.polygon.clip_ring(&ring) {
|
||||
lot.aisles.push(segment);
|
||||
continue 'RING;
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
timer.warn(format!(
|
||||
"Parking aisle {} has weird geometry: {}",
|
||||
aisle_id, err
|
||||
));
|
||||
}
|
||||
}
|
||||
// TODO Should plumb along the OSM ID too and warn here
|
||||
}
|
||||
|
||||
timer.start_iter("generate parking lot spots", results.len());
|
||||
|
@ -29,7 +29,7 @@ pub struct RawMap {
|
||||
pub bus_routes: Vec<RawBusRoute>,
|
||||
pub areas: Vec<RawArea>,
|
||||
pub parking_lots: Vec<RawParkingLot>,
|
||||
pub parking_aisles: Vec<Vec<Pt2D>>,
|
||||
pub parking_aisles: Vec<(osm::WayID, Vec<Pt2D>)>,
|
||||
|
||||
pub boundary_polygon: Polygon,
|
||||
pub gps_bounds: GPSBounds,
|
||||
|
Loading…
Reference in New Issue
Block a user