trimming front paths to building edges

This commit is contained in:
Dustin Carlino 2018-08-22 11:54:18 -07:00
parent 00056e6e81
commit a2399f6613
3 changed files with 21 additions and 6 deletions

View File

@ -112,12 +112,12 @@
0.7,
0.7,
0.7,
1.0
0.8
],
"BuildingPath": [
0.8,
0.8,
0.8,
0.6,
0.6,
0.6,
1.0
],
"BuildingBoundary": [

View File

@ -20,6 +20,10 @@ impl Line {
self.1
}
pub fn points(&self) -> Vec<Pt2D> {
vec![self.0, self.1]
}
// TODO valid to do euclidean distance on world-space points that're formed from
// Haversine?
pub fn length(&self) -> si::Meter<f64> {

View File

@ -1,5 +1,5 @@
use geo;
use geom::{Bounds, Line, Pt2D};
use geom::{Bounds, Line, Pt2D, PolyLine};
use geometry;
use ordered_float::NotNaN;
use raw_data;
@ -19,7 +19,7 @@ pub(crate) fn make_building(
.map(|coord| Pt2D::from_gps(coord, bounds))
.collect();
//let front_path = find_front_path_using_street_names(&points, &b.osm_tags, lanes, roads);
let front_path = find_front_path(&points, lanes);
let front_path = trim_front_path(&points, find_front_path(&points, lanes));
Building {
points,
@ -30,6 +30,17 @@ pub(crate) fn make_building(
}
}
// Adjust the path to start on the building's border, not center
fn trim_front_path(bldg_points: &Vec<Pt2D>, path: Line) -> Line {
let poly = PolyLine::new(bldg_points.clone());
if let Some(hit) = poly.intersection(&PolyLine::new(path.points())) {
Line::new(hit, path.pt2())
} else {
// Just give up
path
}
}
fn find_front_path(bldg_points: &Vec<Pt2D>, lanes: &Vec<Lane>) -> Line {
use geo::prelude::{ClosestPoint, EuclideanDistance};