fix up synthetic's boundary_polygon, and remove more dead geom code

This commit is contained in:
Dustin Carlino 2019-08-26 16:03:29 -07:00
parent 0a39f4bd77
commit 636e6328cb
2 changed files with 32 additions and 35 deletions

View File

@ -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)

View File

@ -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));