Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finish the Polygon cutover #988

Merged
merged 6 commits into from
Sep 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 99 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ abstutil = { path = "abstutil" }
polylabel = { git = "https://github.com/urschrei/polylabel-rs", rev = "b919b8587b491b9a952a6d4c0670558bfd38e034" }

# To temporarily work on dependencies locally, uncomment this
#[patch."https://github.com/a-b-street/osm2streets"]
#import_streets = { path = "/home/dabreegster/osm2streets/import_streets" }
#street_network = { path = "/home/dabreegster/osm2streets/street_network" }
# TODO Do not commit. Update each repo
[patch."https://github.com/a-b-street/osm2streets"]
import_streets = { path = "/home/dabreegster/osm2streets/import_streets" }
street_network = { path = "/home/dabreegster/osm2streets/street_network" }
1 change: 1 addition & 0 deletions apps/game/src/debug/blockfinder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ impl SimpleState<App> for OneBlock {
self.block
.polygon
.get_outer_ring()
.clone()
.into_points()
.into_iter()
.map(polygons::Item::Point)
Expand Down
2 changes: 2 additions & 0 deletions apps/game/src/debug/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,7 @@ impl ContextualActions for Actions {
.get_i(i)
.polygon
.get_outer_ring()
.clone()
.into_points();
let mut pts_without_last = pts.clone();
pts_without_last.pop();
Expand Down Expand Up @@ -838,6 +839,7 @@ impl ContextualActions for Actions {
.get_a(a)
.polygon
.get_outer_ring()
.clone()
.into_points();
let center = if pts[0] == *pts.last().unwrap() {
// TODO The center looks really wrong for Volunteer Park and others, but I
Expand Down
12 changes: 5 additions & 7 deletions apps/game/src/devtools/kml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,13 +314,11 @@ fn make_object(
let polygon = if pts.len() == 1 {
Circle::new(pts[0], RADIUS).to_polygon()
} else if let Ok(ring) = Ring::new(pts.clone()) {
// TODO Ideally we could choose this in the UI
if attribs.get("spatial_type") == Some(&"Polygon".to_string()) {
color = cs.rotating_color_plot(obj_idx).alpha(0.8);
ring.into_polygon()
} else {
ring.to_outline(THICKNESS)
}
// TODO If the below isn't true, show it as an outline instead? Can't make that a Polygon,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slight regression in functionality here, but this debug tool is not used much at all and has pre-existing problems

// though
// if attribs.get("spatial_type") == Some(&"Polygon".to_string()) {
color = cs.rotating_color_plot(obj_idx).alpha(0.8);
ring.into_polygon()
} else {
let backup = pts[0];
match PolyLine::new(pts) {
Expand Down
2 changes: 1 addition & 1 deletion apps/game/src/devtools/story.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ impl State<App> for DrawFreehand {
Transition::ModifyState(Box::new(move |state, ctx, app| {
let editor = state.downcast_mut::<StoryMapEditor>().unwrap();
editor.story.markers.push(Marker {
pts: polygon.get_outer_ring().into_points(),
pts: polygon.into_outer_ring().into_points(),
label: String::new(),
});

Expand Down
4 changes: 2 additions & 2 deletions apps/game/src/edit/roads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1016,8 +1016,8 @@ fn fade_irrelevant(app: &App, r: RoadID) -> GeomBatch {
match Polygon::convex_hull(holes) {
Ok(hole) => {
let fade_area = Polygon::with_holes(
map.get_boundary_polygon().get_outer_ring(),
vec![hole.get_outer_ring()],
map.get_boundary_polygon().get_outer_ring().clone(),
vec![hole.into_outer_ring()],
);
GeomBatch::from(vec![(app.cs.fade_map_dark, fade_area)])
}
Expand Down
8 changes: 6 additions & 2 deletions apps/game/src/edit/traffic_signals/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -981,8 +981,12 @@ pub fn fade_irrelevant(app: &App, members: &BTreeSet<IntersectionID>) -> GeomBat
match Polygon::convex_hull(holes) {
Ok(hole) => {
let fade_area = Polygon::with_holes(
app.primary.map.get_boundary_polygon().get_outer_ring(),
vec![hole.get_outer_ring()],
app.primary
.map
.get_boundary_polygon()
.get_outer_ring()
.clone(),
vec![hole.into_outer_ring()],
);
GeomBatch::from(vec![(app.cs.fade_map_dark, fade_area)])
}
Expand Down
2 changes: 1 addition & 1 deletion apps/game/src/sandbox/dashboards/commuter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ fn group_bldgs(
if group.proper {
lanes.insert(bldg.sidewalk());
}
hull_points.append(&mut bldg.polygon.get_outer_ring().into_points());
hull_points.append(&mut bldg.polygon.get_outer_ring().clone().into_points());
}
if group.proper {
// TODO Even better, glue the loop of sidewalks together and fill that area.
Expand Down
2 changes: 1 addition & 1 deletion apps/ltn/src/customize_boundary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl CustomizeBoundary {
.session
.partitioning
.neighbourhood_boundary_polygon(app, id)
.get_outer_ring()
.into_outer_ring()
.into_points();
Box::new(Self {
id,
Expand Down
2 changes: 1 addition & 1 deletion apps/ltn/src/draw_cells.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ impl RenderCellsBuilder {
// enum with 3 cases, just assign a new index to mean "boundary."
let boundary_marker = neighbourhood.cells.len();
for (pt, _) in
geom::PolyLine::unchecked_new(boundary_polygon.get_outer_ring().into_points())
geom::PolyLine::unchecked_new(boundary_polygon.get_outer_ring().clone().into_points())
.step_along(Distance::meters(RESOLUTION_M / 2.0), Distance::ZERO)
{
// TODO Refactor helpers to transform between map-space and the grid tiles. Possibly
Expand Down
4 changes: 2 additions & 2 deletions apps/ltn/src/neighbourhood.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ impl Neighbourhood {
n.borders.insert(road.dst_i);
}
let fade_area = Polygon::with_holes(
map.get_boundary_polygon().get_outer_ring(),
map.get_boundary_polygon().get_outer_ring().clone(),
vec![app
.session
.partitioning
.neighbourhood_boundary_polygon(app, id)
.get_outer_ring()],
.into_outer_ring()],
);
n.fade_irrelevant = GeomBatch::from(vec![(app.cs.fade_map_dark, fade_area)]).upload(ctx);

Expand Down
6 changes: 3 additions & 3 deletions apps/santa/src/after_level.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use abstutil::prettyprint_usize;
use geom::{Distance, PolyLine, Polygon, Pt2D};
use geom::{Distance, PolyLine, Pt2D, Tessellation};
use widgetry::tools::{ColorLegend, PopupMsg};
use widgetry::{
Color, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, Line, Panel,
Expand Down Expand Up @@ -257,8 +257,8 @@ impl RecordPath {
self.pts.push(pt);
}

pub fn render(mut self, thickness: Distance) -> Polygon {
pub fn render(mut self, thickness: Distance) -> Tessellation {
self.pts.dedup();
PolyLine::unchecked_new(self.pts).make_polygons(thickness)
PolyLine::unchecked_new(self.pts).thicken_tessellation(thickness)
}
}
16 changes: 7 additions & 9 deletions apps/santa/src/game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,13 @@ impl Game {
// TODO I couldn't quite work out how to get the partial outline from Figma working
let center = Pt2D::new(0.0, 0.0);
let outer = Distance::meters(30.0);
let draw = GeomBatch::from(vec![
(Color::WHITE, Circle::new(center, outer).to_polygon()),
(
Color::hex("#5D92C2"),
Circle::new(center, outer).to_partial_polygon(pct),
),
])
.autocrop()
.into_widget(ctx);
let mut batch = GeomBatch::new();
batch.push(Color::WHITE, Circle::new(center, outer).to_polygon());
batch.push(
Color::hex("#5D92C2"),
Circle::new(center, outer).to_partial_tessellation(pct),
);
let draw = batch.autocrop().into_widget(ctx);
self.time_panel.replace(ctx, "time circle", draw);
}

Expand Down
4 changes: 3 additions & 1 deletion apps/santa/src/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ impl Player {
} else {
// Find the exact point on the boundary where we go out of bounds
let old_ring = match self.on {
On::Intersection(i) => app.map.get_i(i).polygon.get_outer_ring(),
On::Intersection(i) => {
app.map.get_i(i).polygon.get_outer_ring().clone()
}
On::Road(r, _, _) => {
let road = app.map.get_r(r);
road.center_pts.to_thick_ring(road.get_width())
Expand Down
Loading