mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-27 00:12:55 +03:00
fix up synthetic's boundary_polygon, and remove more dead geom code
This commit is contained in:
parent
0a39f4bd77
commit
636e6328cb
@ -86,14 +86,6 @@ impl GPSBounds {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from(pts: &Vec<LonLat>) -> GPSBounds {
|
||||
let mut b = GPSBounds::new();
|
||||
for pt in pts {
|
||||
b.update(*pt);
|
||||
}
|
||||
b
|
||||
}
|
||||
|
||||
pub fn update(&mut self, pt: LonLat) {
|
||||
self.min_lon = self.min_lon.min(pt.longitude);
|
||||
self.max_lon = self.max_lon.max(pt.longitude);
|
||||
@ -108,28 +100,6 @@ impl GPSBounds {
|
||||
&& pt.latitude <= self.max_lat
|
||||
}
|
||||
|
||||
pub fn as_bbox(&self) -> Rect {
|
||||
Rect {
|
||||
top_left: Point {
|
||||
x: self.min_lon as f32,
|
||||
y: self.min_lat as f32,
|
||||
},
|
||||
bottom_right: Point {
|
||||
x: self.max_lon as f32,
|
||||
y: self.max_lat as f32,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_corners(&self) -> Vec<LonLat> {
|
||||
vec![
|
||||
LonLat::new(self.min_lon, self.min_lat),
|
||||
LonLat::new(self.max_lon, self.min_lat),
|
||||
LonLat::new(self.max_lon, self.max_lat),
|
||||
LonLat::new(self.min_lon, self.max_lat),
|
||||
]
|
||||
}
|
||||
|
||||
// TODO cache this
|
||||
pub fn get_max_world_pt(&self) -> Pt2D {
|
||||
let width = LonLat::new(self.min_lon, self.min_lat)
|
||||
|
@ -372,11 +372,38 @@ impl Model {
|
||||
});
|
||||
}
|
||||
|
||||
// TODO Argh need to do this manually now
|
||||
//map.compute_gps_bounds();
|
||||
//map.boundary_polygon = map.gps_bounds.get_corners();
|
||||
// Close off the polygon
|
||||
//map.boundary_polygon.push(map.boundary_polygon[0]);
|
||||
// Leave gps_bounds alone. We'll get nonsense answers when converting back to it, which is
|
||||
// fine.
|
||||
|
||||
let mut max_x = 0.0;
|
||||
let mut max_y = 0.0;
|
||||
for b in &map.buildings {
|
||||
for pt in b.polygon.points() {
|
||||
if pt.x() > max_x {
|
||||
max_x = pt.x();
|
||||
}
|
||||
if pt.y() > max_y {
|
||||
max_y = pt.y();
|
||||
}
|
||||
}
|
||||
}
|
||||
for r in map.roads.values() {
|
||||
for pt in &r.center_points {
|
||||
if pt.x() > max_x {
|
||||
max_x = pt.x();
|
||||
}
|
||||
if pt.y() > max_y {
|
||||
max_y = pt.y();
|
||||
}
|
||||
}
|
||||
}
|
||||
map.boundary_polygon = Polygon::new(&vec![
|
||||
Pt2D::new(0.0, 0.0),
|
||||
Pt2D::new(max_x, 0.0),
|
||||
Pt2D::new(max_x, max_y),
|
||||
Pt2D::new(0.0, max_y),
|
||||
Pt2D::new(0.0, 0.0),
|
||||
]);
|
||||
|
||||
let path = abstutil::path_raw_map(self.name.as_ref().expect("Model hasn't been named yet"));
|
||||
abstutil::write_binary(&path, &map).expect(&format!("Saving {} failed", path));
|
||||
|
Loading…
Reference in New Issue
Block a user