mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-28 12:12:00 +03:00
trimming front paths to building edges
This commit is contained in:
parent
00056e6e81
commit
a2399f6613
@ -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": [
|
||||
|
@ -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> {
|
||||
|
@ -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};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user