removing old code for area clipping

This commit is contained in:
Dustin Carlino 2019-04-13 15:09:08 -07:00
parent 9d46cb1c0f
commit e873f79f67
5 changed files with 82 additions and 239 deletions

View File

@ -94,7 +94,6 @@ pub fn clip_map(map: &mut raw_data::Map, timer: &mut Timer) -> GPSBounds {
.all(|pt| boundary_poly.contains_pt(pt))
});
if true {
let mut result_areas = Vec::new();
for orig_area in map.areas.drain(..) {
let mut boundary_pts = CPolygon::from_vec(&boundary_poly.points().into_iter().map(|pt| [pt.x(), pt.y()]).collect());
@ -110,80 +109,6 @@ pub fn clip_map(map: &mut raw_data::Map, timer: &mut Timer) -> GPSBounds {
}
}
map.areas = result_areas;
}
// TODO This is close to working...
// - Might split one polygon into two disjoint, but that's fine
// - Need to add intermediate corners from the boundary
// - Handle when first point isn't in bounds, but probably not by cycling through stuff?
if false {
for area in map.areas.iter_mut() {
// Start with a point that's in-bounds. Must exist, because areas with nothing
// in-bounds should get filtered out.
let pts = bounds.must_convert(&area.points);
// TODO Worse results? :(
/*
loop {
if boundary_poly.contains_pt(pts[0]) {
break;
}
let pt = pts.pop().unwrap();
pts.insert(0, pt);
}
*/
let mut final_pts = Vec::new();
let mut last_oob_pt: Option<Pt2D> = None;
for pt in pts {
if boundary_poly.contains_pt(pt) {
if let Some(prev) = last_oob_pt {
// Going back in!
last_oob_pt = None;
let crossing = PolyLine::new(vec![prev, pt]);
let border_pt = boundary_lines
.iter()
.find_map(|l| crossing.intersection(l).map(|(pt, _)| pt))
.unwrap();
final_pts.push(border_pt);
// TODO Maybe add intermediate "corners" of the boundary polygon
}
final_pts.push(pt);
} else {
if last_oob_pt.is_none() {
// Going out!
last_oob_pt = Some(pt);
// TODO Worse results without this
if !final_pts.is_empty() {
let crossing = PolyLine::new(vec![*final_pts.last().unwrap(), pt]);
let border_pt = boundary_lines
.iter()
.find_map(|l| crossing.intersection(l).map(|(pt, _)| pt))
.unwrap();
final_pts.push(border_pt);
}
}
}
}
// TODO Worse results? :(
/*if let Some(prev) = last_oob_pt {
// Go back in!
let crossing = PolyLine::new(vec![prev, final_pts[0]]);
let border_pt = boundary_lines
.iter()
.find_map(|l| crossing.intersection(l).map(|(pt, _)| pt))
.unwrap();
final_pts.push(border_pt);
// TODO Maybe add intermediate "corners" of the boundary polygon
}*/
if *final_pts.last().unwrap() != final_pts[0] {
final_pts.push(final_pts[0]);
}
area.points = bounds.must_convert_back(&final_pts);
}
}
timer.stop("clipping map to boundary");
bounds

View File

@ -244,58 +244,12 @@ fn glue_multipolygon(
}
}
}
extrude_to_boundary(boundary_polygon, &mut result);
// Some ways of the multipolygon are clipped out. Connect the ends in the most straightforward
// way. Later polygon clipping will trim to the boundary.
if result[0] != *result.last().unwrap() {
result.push(result[0]);
}
polygons.push(result);
polygons
}
fn extrude_to_boundary(boundary_polygon: &Vec<LonLat>, result: &mut Vec<LonLat>) {
// Some ways of the multipolygon are clipped out. Connect the ends by traveling along the
// boundary polygon in the closest direction (clockwise or counter-clockwise).
let first_pt = result[0];
let last_pt = *result.last().unwrap();
if first_pt == last_pt {
return;
}
if true {
// Simple resolution:
result.push(first_pt);
} else {
// Proper resolution:
let closest_to_last = *boundary_polygon
.iter()
.min_by_key(|pt| pt.gps_dist_meters(last_pt))
.unwrap();
let closest_to_first = *boundary_polygon
.iter()
.min_by_key(|pt| pt.gps_dist_meters(first_pt))
.unwrap();
println!("first pt is {}, last pt is {}", first_pt, last_pt);
println!(
"boundary closest... first pt is {}, last pt is {}",
closest_to_first, closest_to_last
);
let slice1 = LonLat::find_slice(boundary_polygon, closest_to_last, closest_to_first);
let mut backwards_boundary: Vec<LonLat> = boundary_polygon.to_vec();
backwards_boundary.reverse();
let slice2 = LonLat::find_slice(&backwards_boundary, closest_to_last, closest_to_first);
if slice_len(&slice1) <= slice_len(&slice2) {
println!(" fwd won. adding {:?}", slice1);
result.extend(slice1);
} else {
println!(" back won. adding {:?}", slice2);
result.extend(slice2);
}
result.push(first_pt);
}
}
fn slice_len(pts: &Vec<LonLat>) -> Distance {
let mut dist = Distance::ZERO;
for pair in pts.windows(2) {
dist += pair[0].gps_dist_meters(pair[1]);
}
dist
}

View File

@ -1,84 +1,84 @@
b65283ebfc9689af9998c9801315ec1f ../data/screenshots/pending_montlake/01x01_i354.png
eeede8562e5ab310f8e3694f27f9e3c6 ../data/screenshots/pending_montlake/02x01.png
a99ca9a0e9ace213133a66fe6cbc9ab7 ../data/screenshots/pending_montlake/03x01.png
5b30603e56fb55a6ac02bee0b6bb5256 ../data/screenshots/pending_montlake/01x01_i354.png
2f428cfbef1329279e98c822fef869c1 ../data/screenshots/pending_montlake/02x01.png
2f428cfbef1329279e98c822fef869c1 ../data/screenshots/pending_montlake/03x01.png
2f428cfbef1329279e98c822fef869c1 ../data/screenshots/pending_montlake/04x01.png
2f428cfbef1329279e98c822fef869c1 ../data/screenshots/pending_montlake/05x01.png
2f428cfbef1329279e98c822fef869c1 ../data/screenshots/pending_montlake/06x01.png
7afd97711d37e8fc12fb455266963849 ../data/screenshots/pending_montlake/01x02.png
d68757d68d0117f4a7bc7e9d170152b6 ../data/screenshots/pending_montlake/02x02.png
3613f0fbc8cf9d5eba23ba6cbc3faade ../data/screenshots/pending_montlake/03x02.png
512a2514d206a91d796be5eda324972c ../data/screenshots/pending_montlake/04x02.png
c030e6fa35f9f6f67edc8f414a4ed1f8 ../data/screenshots/pending_montlake/05x02_i290.png
b7ba74eaab17a7f58cb9ef23735ff8ce ../data/screenshots/pending_montlake/06x02.png
6bfcb462803f22ac4f6e9068e116dc6e ../data/screenshots/pending_montlake/01x03_i87.png
8075785da2a85970085083577864f2f0 ../data/screenshots/pending_montlake/02x03_i66.png
04f53200a16a95b4bbb962ea9f6f9028 ../data/screenshots/pending_montlake/03x03.png
b49908a81b09fec864d9260fc73e0e7e ../data/screenshots/pending_montlake/04x03_i6.png
e1802c81e84dbd4bf27a6632c192db0e ../data/screenshots/pending_montlake/05x03_i4.png
6675ed768785b92d957d13d906ff529d ../data/screenshots/pending_montlake/06x03_i196.png
cbd78505242e0cf4a454b5913ee95791 ../data/screenshots/pending_montlake/01x04_i368.png
bdc8cf5cdbfcf3a68ac26087c80788fd ../data/screenshots/pending_montlake/02x04_i51.png
df78fc7e827b6252837a9088326d3513 ../data/screenshots/pending_montlake/03x04.png
55ec583123bdf0be6a2e5d15dc286cf7 ../data/screenshots/pending_montlake/04x04_i147.png
2558a1137531173ddc978c57eb4d65c6 ../data/screenshots/pending_montlake/05x04_i46.png
feef555fe7dad68d634b1ce029882fa4 ../data/screenshots/pending_montlake/06x04_i49.png
f557712b070a1395d2fcd4bc61f7d4e2 ../data/screenshots/pending_montlake/01x05_i113.png
0761b6ccefa0eea8a0c801d443a5cd29 ../data/screenshots/pending_montlake/02x05_i14.png
c7f0aae0a525a1950526365fb06a8ea5 ../data/screenshots/pending_montlake/03x05_i39.png
4f687cde233a27002c4bd69dd08b308f ../data/screenshots/pending_montlake/04x05_i10.png
6c7369905ac264eab54a2a2dfca4b628 ../data/screenshots/pending_montlake/05x05_i180.png
e68189953e4d79cdc957dffa0f8c90e6 ../data/screenshots/pending_montlake/06x05_i21.png
a31646afeaef75adbbe148742f63c77f ../data/screenshots/pending_montlake/01x06_i22.png
dcadf47c50bdb1bcb65ec0827afd2cf2 ../data/screenshots/pending_montlake/02x06_i8.png
35ef7fd81a613eed14044b7ec2feba3b ../data/screenshots/pending_montlake/03x06_i0.png
2a10bead713476f759d092848b0d6eae ../data/screenshots/pending_montlake/04x06_i101.png
c3191ce942ddc92280cd281493febe8e ../data/screenshots/pending_montlake/05x06_i109.png
17cb95cd6354c1c72e047b41727423c8 ../data/screenshots/pending_montlake/06x06_i20.png
dd23f0794403af2d5cd80bce1a8f18ab ../data/screenshots/pending_montlake/01x07_i56.png
c4d07a30a8ee84083d04df0c9dee4812 ../data/screenshots/pending_montlake/02x07_i8.png
2bc0ee861fa7d5441dbc716f565d6ed9 ../data/screenshots/pending_montlake/03x07_i54.png
06af124c37b5ed1fbf331de7aaec8073 ../data/screenshots/pending_montlake/04x07_i58.png
8e8896fb264a3807c095f14882c526f3 ../data/screenshots/pending_montlake/05x07_i32.png
a46750d073b83cd61c5f699e07728354 ../data/screenshots/pending_montlake/06x07_i33.png
6af4763d0ee98c5be395cd66f8310a79 ../data/screenshots/pending_montlake/01x08_i18.png
e02fb00a29359e87baf65b487c1e305e ../data/screenshots/pending_montlake/02x08_i19.png
408b68dc1ddda25683202c7528c44b76 ../data/screenshots/pending_montlake/03x08_i75.png
e23374a63d3ac911a3c1a4abe6a91962 ../data/screenshots/pending_montlake/04x08_i16.png
e8335ea1fa6ea1110e05bd82d389f371 ../data/screenshots/pending_montlake/05x08_i34.png
aa38ae16ecb33958293653f314528aed ../data/screenshots/pending_montlake/06x08_i1.png
6b21668aa6edf13ea5047935abe1dc38 ../data/screenshots/pending_montlake/01x09_i124.png
41b976659673289d28fb546174772f07 ../data/screenshots/pending_montlake/02x09_i125.png
c197eddcdc198b0ee319bd8ebf9efaa8 ../data/screenshots/pending_montlake/03x09_i40.png
85e1f95977da186bafe23099fed2bc00 ../data/screenshots/pending_montlake/04x09_i30.png
b8c74db0da307c8b0542bdb9880190f3 ../data/screenshots/pending_montlake/05x09_i24.png
e6da54a23b6d43c133a120d262364aa1 ../data/screenshots/pending_montlake/06x09_i62.png
abb8521955b833a9f208795ce8b171ea ../data/screenshots/pending_montlake/01x10_i252.png
7849a9e4ed174eb18b27d62f77dd5501 ../data/screenshots/pending_montlake/02x10_i336.png
1e440aaf0ced93e47e3196bb10414fef ../data/screenshots/pending_montlake/03x10_i333.png
a1cd7dc9fec4ba88562384d83824389b ../data/screenshots/pending_montlake/04x10_i79.png
dbfc82e4ae5bd9f7e82af8527e2d9a3f ../data/screenshots/pending_montlake/05x10_i298.png
596a0b379a7ab55dd9d685bdb356fc8c ../data/screenshots/pending_montlake/06x10_i176.png
e9905a37cd6a39c8d161d1836da68fa7 ../data/screenshots/pending_montlake/01x11.png
98b5336016cf869c4540f7a85ae03ee8 ../data/screenshots/pending_montlake/02x11.png
1ec39fb99cea0349f1a9f5fdadbb4982 ../data/screenshots/pending_montlake/03x11_i74.png
152da85a513d55dff1a187feb4d18ca6 ../data/screenshots/pending_montlake/04x11.png
73ba7c171b2782600cec951f72b449c0 ../data/screenshots/pending_montlake/05x11_i28.png
505c3be0c20f2b2b1ef16decea6a6258 ../data/screenshots/pending_montlake/06x11_i322.png
e59751621697a4d96d05d66e5f170397 ../data/screenshots/pending_montlake/01x12_i254.png
bcf002c25a7e03819c38c890d3ca32ca ../data/screenshots/pending_montlake/02x12_i254.png
1da314093f2bcf4d7e42c89d9be61130 ../data/screenshots/pending_montlake/03x12.png
da9a4891f08b75fbd922dbecb4e9547f ../data/screenshots/pending_montlake/04x12.png
cbcdf204496095dcfb5cc5a1e85a8a2f ../data/screenshots/pending_montlake/05x12.png
7a1be5a979f7ed328c1d691aa572217d ../data/screenshots/pending_montlake/01x02_i87.png
f18ee94421c2659bac18d8b1a01a8956 ../data/screenshots/pending_montlake/02x02_i66.png
38509b54ece61a218abd4b323bcfb2aa ../data/screenshots/pending_montlake/03x02.png
ba073f8a62ae0d8ea0dd61bc99190f51 ../data/screenshots/pending_montlake/04x02_i152.png
54c84445499639be933b3bbe5a0ef6d9 ../data/screenshots/pending_montlake/05x02_i152.png
f960dd62ec941793f49044abb5f19922 ../data/screenshots/pending_montlake/06x02.png
aabf5174cd6b9388d5000b2698d300d3 ../data/screenshots/pending_montlake/01x03_i87.png
e8b627b6100fd1ff644cc872b84920e7 ../data/screenshots/pending_montlake/02x03_i66.png
f9b0ea30274b308247644c20139241ed ../data/screenshots/pending_montlake/03x03.png
f26acb081651aca3d253363811890cd0 ../data/screenshots/pending_montlake/04x03_i2.png
33b763802b09be36012f6af6f8e9e155 ../data/screenshots/pending_montlake/05x03_i2.png
390e522b4961d9660a1f460170f4e066 ../data/screenshots/pending_montlake/06x03_i196.png
c87c58cea0c146d85b17e65988466081 ../data/screenshots/pending_montlake/01x04_i113.png
58e1ee976243101c02040a83543b1bc5 ../data/screenshots/pending_montlake/02x04_i45.png
2eae9e3275fc6d5bee0626bb1014ded0 ../data/screenshots/pending_montlake/03x04.png
48fef345919aaffef1fec6ab1333495f ../data/screenshots/pending_montlake/04x04_i146.png
2ff220ce581e6dc3fd162c18125928dc ../data/screenshots/pending_montlake/05x04_i46.png
0a0c4794f9b90587a3e7a7e8d1fd5334 ../data/screenshots/pending_montlake/06x04_i49.png
9effd5d248da271af10efa1126053e7b ../data/screenshots/pending_montlake/01x05_i113.png
8a5615891dc3cdd6f55e35365b947c15 ../data/screenshots/pending_montlake/02x05_i81.png
73010946d5111d490d89808079c40536 ../data/screenshots/pending_montlake/03x05_i38.png
09d72536f6d1f5bb1649a63d5d82e007 ../data/screenshots/pending_montlake/04x05_i10.png
44e85c107f0789ed69f4c66c7b7f1214 ../data/screenshots/pending_montlake/05x05_i180.png
4df602915cba48fb7625c0bf1bf4c97f ../data/screenshots/pending_montlake/06x05_i21.png
ba13627fa8ec05d71556ee657fc856ea ../data/screenshots/pending_montlake/01x06_i22.png
bb72e434769ea1cf9d98190d16033d42 ../data/screenshots/pending_montlake/02x06_i8.png
38b824ad015c5e9c3bcc9f9ebe472f76 ../data/screenshots/pending_montlake/03x06_i0.png
f9546bcd9648fdc20818b627e62961ba ../data/screenshots/pending_montlake/04x06_i59.png
f994474b45178422f8a4610fc9685157 ../data/screenshots/pending_montlake/05x06_i32.png
6c2d21792cfe9584f5d824d363b16853 ../data/screenshots/pending_montlake/06x06_i20.png
204bd0ba846d57c72db36499bb846061 ../data/screenshots/pending_montlake/01x07_i56.png
dc6f7b6cf159737cab83d963c94378ec ../data/screenshots/pending_montlake/02x07_i57.png
425f49686a1a2795a19412b677934026 ../data/screenshots/pending_montlake/03x07_i54.png
8db8d59463cb097c2be9cbe7892915dc ../data/screenshots/pending_montlake/04x07_i58.png
db8576da71a44ccfed3b4d1c23231fde ../data/screenshots/pending_montlake/05x07_i110.png
de8ecea845ab831c5b2fae595c95a971 ../data/screenshots/pending_montlake/06x07.png
73c44ae5efeec9d19c431fe60a4e657f ../data/screenshots/pending_montlake/01x08_i18.png
216a2d66007b18bece931ad364f16de8 ../data/screenshots/pending_montlake/02x08_i19.png
fe0f9b9edd36f749ac3de34f56bbccb8 ../data/screenshots/pending_montlake/03x08_i16.png
65fa3cc30a2687b290d3d634c2979055 ../data/screenshots/pending_montlake/04x08_i24.png
1565715bdd7c403bd063e42767690c09 ../data/screenshots/pending_montlake/05x08_i34.png
aa80a02c6dad39e16b5ae9f0ffa89791 ../data/screenshots/pending_montlake/06x08_i1.png
b57bbb1fc606564854066f22d923e60d ../data/screenshots/pending_montlake/01x09_i124.png
0739561e7dcf5bd2a286ca05c396413e ../data/screenshots/pending_montlake/02x09_i293.png
3698ea8d452d233195388a7be4500876 ../data/screenshots/pending_montlake/03x09_i40.png
dd68744dfca675e106311fe7db0d63e8 ../data/screenshots/pending_montlake/04x09_i30.png
1aeac622bd9b11dc60fc023aba8aea1b ../data/screenshots/pending_montlake/05x09_i25.png
72e9d6268d52ce644bc27f0f7478b7ad ../data/screenshots/pending_montlake/06x09_i62.png
7f9203a8ce70b76e7833573928b5fc43 ../data/screenshots/pending_montlake/01x10_i252.png
9686583d8a07d8d54b6d2a9975ca77a0 ../data/screenshots/pending_montlake/02x10_i333.png
a7c1c08470f9b22c9f8520d67d443ece ../data/screenshots/pending_montlake/03x10_i74.png
977f055aadd7249ed0f4e92d1adfcfcb ../data/screenshots/pending_montlake/04x10_i79.png
3df323556a3ae447c182ca2d3ec2cb25 ../data/screenshots/pending_montlake/05x10_i298.png
aba0e8ac028a763fec0f2dbc39f89bf8 ../data/screenshots/pending_montlake/06x10_i176.png
17501f76b13cf92c39ba47e35004fd9c ../data/screenshots/pending_montlake/01x11.png
2f428cfbef1329279e98c822fef869c1 ../data/screenshots/pending_montlake/02x11.png
565a19febbec716f4d6ae931019bc9a4 ../data/screenshots/pending_montlake/03x11.png
5edda449ff630318c34e0224444fbd6a ../data/screenshots/pending_montlake/04x11.png
7a0cc33f5781432ffb96555d3ef0a4a1 ../data/screenshots/pending_montlake/05x11_i28.png
2f428cfbef1329279e98c822fef869c1 ../data/screenshots/pending_montlake/06x11.png
4031d97fef956c4e72a27fe5bb6d357e ../data/screenshots/pending_montlake/01x12_i254.png
2f428cfbef1329279e98c822fef869c1 ../data/screenshots/pending_montlake/02x12.png
c4a5cd68377f1ae5b7a5d45488c08566 ../data/screenshots/pending_montlake/03x12.png
d0d46707fbbec970f1a35de07b022335 ../data/screenshots/pending_montlake/04x12.png
f412f4ef2c913f24b843d7c7f703fc6b ../data/screenshots/pending_montlake/05x12.png
2f428cfbef1329279e98c822fef869c1 ../data/screenshots/pending_montlake/06x12.png
2f428cfbef1329279e98c822fef869c1 ../data/screenshots/pending_montlake/01x13.png
2f428cfbef1329279e98c822fef869c1 ../data/screenshots/pending_montlake/02x13.png
2f5f2d344ebf9df69ab1be2cbad78b48 ../data/screenshots/pending_montlake/03x13.png
50c576c99bbb53e761cf574b582811b4 ../data/screenshots/pending_montlake/04x13.png
92e2c917ee89cfe268da44efc0bc772e ../data/screenshots/pending_montlake/05x13.png
261eb76c4c84975ba9dcd69cb00058d0 ../data/screenshots/pending_montlake/03x13.png
67ff86ee7e851cf4e4d188b207ff265e ../data/screenshots/pending_montlake/04x13.png
cc527092866e3ee22b07efb30bd8dbf9 ../data/screenshots/pending_montlake/05x13.png
2f428cfbef1329279e98c822fef869c1 ../data/screenshots/pending_montlake/06x13.png
2f428cfbef1329279e98c822fef869c1 ../data/screenshots/pending_montlake/01x14.png
2f428cfbef1329279e98c822fef869c1 ../data/screenshots/pending_montlake/02x14.png
4142fcf04035dcdf6f2eae06aacc769c ../data/screenshots/pending_montlake/03x14_i357.png
7b8fd1ed56fd6e9a6ac86d5a3e56cc8e ../data/screenshots/pending_montlake/04x14.png
c00c27b2f110e6145eda29a71c2163c6 ../data/screenshots/pending_montlake/05x14.png
f1475e8bb40be25cb1ae6330bc559a00 ../data/screenshots/pending_montlake/03x14_i357.png
1cafa3f24d63e7eff5c77875f01db29a ../data/screenshots/pending_montlake/04x14.png
395a1f9286ec26c6cdc5c91eb789bd1a ../data/screenshots/pending_montlake/05x14.png
2f428cfbef1329279e98c822fef869c1 ../data/screenshots/pending_montlake/06x14.png

View File

@ -2,21 +2,14 @@
## Boundary clipping
- lakes missing from small_seattle
- roads
- what if they start/end in bounds, but briefly dip out? arboretum place east
- intersections
- some intersections partly cross border, is that actually fine?
- areas
- it may split areas... that's not so bad really
- ensure first pt is in-bounds... thats making stuff worse though?
- include intermediate corners
- move the code to do this to clip. can probably get rid of find_blah_btwn for lonlat, right?
- some areas in small_seattle are borked or missing
- at least for lakeslice, we have points in good orders, but need to clip areas too.
- use real map background by default
## Geometry

View File

@ -52,35 +52,6 @@ impl LonLat {
pub fn to_hashable(&self) -> HashablePt2D {
HashablePt2D::new(self.longitude, self.latitude)
}
// TODO Refactor with Pt2D::find_pts_between
pub fn find_slice(pts: &Vec<LonLat>, start: LonLat, end: LonLat) -> Vec<LonLat> {
let mut result = Vec::new();
for pt in pts {
if result.is_empty() && *pt == start {
result.push(*pt);
} else if !result.is_empty() {
result.push(*pt);
}
// start and end might be the same.
if !result.is_empty() && *pt == end {
return result;
}
}
if result.is_empty() {
panic!("Couldn't find start");
}
// Go through again, looking for end
for pt in pts {
result.push(*pt);
if *pt == end {
return result;
}
}
panic!("Couldn't find end");
}
}
impl fmt::Display for LonLat {