Skip to content

Commit

Permalink
Remove the osm2polygons tests from #886. Instead, we now have goldenfile
Browse files Browse the repository at this point in the history
tests across larger chunks of OSM in
a-b-street/osm2streets#15.
  • Loading branch information
dabreegster committed May 21, 2022
1 parent 2c6bfba commit 150ec77
Show file tree
Hide file tree
Showing 12 changed files with 1 addition and 2,162 deletions.
24 changes: 1 addition & 23 deletions apps/map_editor/src/app.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use geom::{Distance, Line, Polygon, Pt2D};
use raw_map::osm;
use widgetry::mapspace::WorldOutcome;
use widgetry::tools::{open_browser, PopupMsg, URLManager};
use widgetry::tools::{open_browser, URLManager};
use widgetry::{
lctrl, Canvas, Color, EventCtx, GfxCtx, HorizontalAlignment, Key, Line, Outcome, Panel,
SharedAppState, State, Text, Toggle, Transition, VerticalAlignment, Widget,
Expand Down Expand Up @@ -107,10 +107,6 @@ impl MainState {
.btn_outline
.text("simplify RawMap")
.build_def(ctx),
ctx.style()
.btn_outline
.text("save osm2polygons input")
.build_def(ctx),
])
.section(ctx),
]),
Expand Down Expand Up @@ -213,24 +209,6 @@ impl State<App> for MainState {
WorldOutcome::Keypress("debug intersection geometry", ID::Intersection(i)) => {
app.model.debug_intersection_geometry(ctx, i);
}
WorldOutcome::Keypress("export to osm2polygon", ID::Intersection(i)) => {
let input = format!("{}_input.json", i.0);
let output = format!("{}_output.json", i.0);

app.model.map.save_osm2polygon_input(input.clone(), i);
return Transition::Push(
match raw_map::geometry::osm2polygon(input.clone(), output.clone()) {
Ok(()) => PopupMsg::new_state(
ctx,
"Exported",
vec![format!("{input} and {output} written")],
),
Err(err) => {
PopupMsg::new_state(ctx, "Error", vec![err.to_string()])
}
},
);
}
WorldOutcome::Keypress("debug in OSM", ID::Intersection(i)) => {
open_browser(i.to_string());
}
Expand Down
1 change: 0 additions & 1 deletion apps/map_editor/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ impl Model {
.hotkey(Key::T, "toggle stop sign / traffic signal")
.hotkey(Key::P, "debug intersection geometry")
.hotkey(Key::D, "debug in OSM")
.hotkey(Key::X, "export to osm2polygon")
.build(ctx);
}

Expand Down
186 changes: 0 additions & 186 deletions raw_map/src/geometry/geojson.rs

This file was deleted.

43 changes: 0 additions & 43 deletions raw_map/src/geometry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@
//! I wrote a novella about this: <https://a-b-street.github.io/docs/tech/map/geometry/index.html>
mod algorithm;
mod geojson;

use std::collections::BTreeMap;

use anyhow::Result;

use abstutil::Tags;
use geom::{Distance, PolyLine, Polygon};

Expand Down Expand Up @@ -42,43 +39,3 @@ pub struct Results {
/// Extra polygons with labels to debug the algorithm
pub debug: Vec<(String, Polygon)>,
}

/// Process the file produced by `save_osm2polygon_input`, then write the output as GeoJSON.
pub fn osm2polygon(input_path: String, output_path: String) -> Result<()> {
let (intersection_id, input_roads, gps_bounds) = geojson::read_osm2polygon_input(input_path)?;
let results = intersection_polygon(intersection_id, input_roads, &BTreeMap::new())?;
let debug_output = false;
results.save_to_geojson(output_path, &gps_bounds, debug_output)?;
Ok(())
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_osm2polygon() {
let mut any = false;
for entry in std::fs::read_dir("src/geometry/tests").unwrap() {
let input = entry.unwrap().path().display().to_string();
println!("Working on {input}");
if input.ends_with("output.json") {
continue;
}
any = true;

let expected_output_path = input.replace("input", "output");
let actual_output_path = "actual_osm2polygon_output.json";
osm2polygon(input.clone(), actual_output_path.to_string()).unwrap();
let expected_output = std::fs::read_to_string(expected_output_path.clone()).unwrap();
let actual_output = std::fs::read_to_string(actual_output_path).unwrap();

if expected_output != actual_output {
panic!("osm2polygon output changed. Manually compare {actual_output_path} and {expected_output_path}");
}

std::fs::remove_file(actual_output_path).unwrap();
}
assert!(any, "Didn't find any tests");
}
}
Loading

0 comments on commit 150ec77

Please sign in to comment.