mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-24 09:24:26 +03:00
Few adjustments to KML viewer to make it easier to deal with huge .kml files
This commit is contained in:
parent
037e22e69e
commit
e5bb98511a
@ -38,7 +38,14 @@ impl ViewKML {
|
|||||||
ctx.loading_screen("load kml", |ctx, mut timer| {
|
ctx.loading_screen("load kml", |ctx, mut timer| {
|
||||||
let raw_shapes = if let Some(ref path) = path {
|
let raw_shapes = if let Some(ref path) = path {
|
||||||
if path.ends_with(".kml") {
|
if path.ends_with(".kml") {
|
||||||
kml::load(&path, &app.primary.map.get_gps_bounds(), true, &mut timer).unwrap()
|
let shapes =
|
||||||
|
kml::load(&path, &app.primary.map.get_gps_bounds(), true, &mut timer)
|
||||||
|
.unwrap();
|
||||||
|
// Assuming this is some huge file, conveniently convert the extract to .bin.
|
||||||
|
// The new file will show up as untracked in git, so it'll be obvious this
|
||||||
|
// happened.
|
||||||
|
abstutil::write_binary(path.replace(".kml", ".bin"), &shapes);
|
||||||
|
shapes
|
||||||
} else {
|
} else {
|
||||||
abstutil::read_binary::<ExtraShapes>(path.to_string(), &mut timer)
|
abstutil::read_binary::<ExtraShapes>(path.to_string(), &mut timer)
|
||||||
}
|
}
|
||||||
@ -175,7 +182,10 @@ impl State for ViewKML {
|
|||||||
app.primary.map.get_city_name()
|
app.primary.map.get_city_name()
|
||||||
))))
|
))))
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|x| x.ends_with(".bin") && !x.ends_with("popdat.bin"))
|
.filter(|x| {
|
||||||
|
(x.ends_with(".bin") || x.ends_with(".kml"))
|
||||||
|
&& !x.ends_with("popdat.bin")
|
||||||
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
),
|
),
|
||||||
Box::new(|path, ctx, app| {
|
Box::new(|path, ctx, app| {
|
||||||
|
Loading…
Reference in New Issue
Block a user