remove parcels too far from sidewalks

This commit is contained in:
Dustin Carlino 2018-09-16 16:44:59 -07:00
parent 5348ed6c7b
commit 18a5a2f2f8
5 changed files with 61 additions and 13 deletions

View File

@ -12,8 +12,6 @@
- https://data-seattlecitygis.opendata.arcgis.com/datasets/curb-ramps - https://data-seattlecitygis.opendata.arcgis.com/datasets/curb-ramps
- high quality thick roads: https://seattlecitygis.maps.arcgis.com/apps/webappviewer/index.html?id=86cb6824307c4d63b8e180ebcff58ce2 - high quality thick roads: https://seattlecitygis.maps.arcgis.com/apps/webappviewer/index.html?id=86cb6824307c4d63b8e180ebcff58ce2
- trim parcels that're nowhere near roads (aka, the bbox is kinda wrong)
- maybe also the time to split into different lane types? what's similar/not between them? - maybe also the time to split into different lane types? what's similar/not between them?
- graph querying? - graph querying?
- rendering (and other UI/editor interactions)? - rendering (and other UI/editor interactions)?

View File

@ -36,7 +36,7 @@ pub(crate) fn make_all_buildings(
let line = trim_front_path(&points, Line::new(bldg_center.into(), sidewalk_pt)); let line = trim_front_path(&points, Line::new(bldg_center.into(), sidewalk_pt));
// Trim buildings that are too far away from their sidewalk // Trim buildings that are too far away from their sidewalk
if line.length() > 200.0 * si::M { if line.length() > 100.0 * si::M {
continue; continue;
} }

View File

@ -1,6 +1,7 @@
mod buildings; mod buildings;
mod bus_stops; mod bus_stops;
mod lanes; mod lanes;
mod parcels;
mod sidewalk_finder; mod sidewalk_finder;
mod trim_lines; mod trim_lines;
mod turns; mod turns;
@ -8,5 +9,6 @@ mod turns;
pub(crate) use self::buildings::make_all_buildings; pub(crate) use self::buildings::make_all_buildings;
pub(crate) use self::bus_stops::make_bus_stops; pub(crate) use self::bus_stops::make_bus_stops;
pub(crate) use self::lanes::get_lane_specs; pub(crate) use self::lanes::get_lane_specs;
pub(crate) use self::parcels::make_all_parcels;
pub(crate) use self::trim_lines::trim_lines; pub(crate) use self::trim_lines::trim_lines;
pub(crate) use self::turns::make_all_turns; pub(crate) use self::turns::make_all_turns;

View File

@ -0,0 +1,55 @@
use dimensioned::si;
use geom::{Bounds, HashablePt2D, Line, Pt2D};
use geometry;
use make::sidewalk_finder::find_sidewalk_points;
use raw_data;
use std::collections::HashSet;
use {Lane, Parcel, ParcelID};
pub(crate) fn make_all_parcels(
results: &mut Vec<Parcel>,
input: &Vec<raw_data::Parcel>,
bounds: &Bounds,
lanes: &Vec<Lane>,
) {
let mut pts_per_parcel: Vec<Vec<Pt2D>> = Vec::new();
let mut center_per_parcel: Vec<HashablePt2D> = Vec::new();
let mut query: HashSet<HashablePt2D> = HashSet::new();
for p in input {
let pts = p
.points
.iter()
.map(|coord| Pt2D::from_gps(coord, bounds))
.collect();
let center: HashablePt2D = geometry::center(&pts).into();
pts_per_parcel.push(pts);
center_per_parcel.push(center);
query.insert(center);
}
let sidewalk_pts = find_sidewalk_points(query, lanes);
for (idx, center) in center_per_parcel.into_iter().enumerate() {
let (sidewalk, dist_along) = sidewalk_pts[&center];
let (sidewalk_pt, _) = lanes[sidewalk.0].dist_along(dist_along);
let line = Line::new(center.into(), sidewalk_pt);
// Trim parcels that are too far away from the nearest sidewalk
if line.length() > 100.0 * si::M {
continue;
}
let id = ParcelID(results.len());
results.push(Parcel {
id,
points: pts_per_parcel[idx].clone(),
block: input[idx].block,
});
}
let discarded = input.len() - results.len();
if discarded > 0 {
println!(
"Discarded {} parcels that weren't close enough to a sidewalk",
discarded
);
}
}

View File

@ -185,16 +185,9 @@ impl Map {
} }
} }
for (idx, p) in data.parcels.iter().enumerate() { {
m.parcels.push(Parcel { let _guard = flame::start_guard(format!("make {} parcels", data.parcels.len()));
id: ParcelID(idx), make::make_all_parcels(&mut m.parcels, &data.parcels, &bounds, &m.lanes);
points: p
.points
.iter()
.map(|coord| Pt2D::from_gps(coord, &bounds))
.collect(),
block: p.block,
});
} }
for (idx, a) in data.areas.iter().enumerate() { for (idx, a) in data.areas.iter().enumerate() {