mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-24 09:24:26 +03:00
switch popdat from cs2cs binary to gdal bindings. cleaner and will likely need gdal for elevation data anyway. also fix synthetic maps, which i accidentally broke few days ago with elevation
This commit is contained in:
parent
41aa42e552
commit
41f37f666c
@ -95,7 +95,7 @@ c891798df896dc8597402f64920fefa4 data/input/raw_maps/montlake.bin
|
||||
dcb6ddd5249cd89295aed2becaf8c472 data/input/raw_maps/23rd.bin
|
||||
2bc84e4d194d7cea6007ae3b93f3b11b data/input/neighborhoods.geojson
|
||||
9cd47678c7f9dfc2cb80d79f90699d6f data/input/offstreet_parking.kml
|
||||
830d2699be1215e051acaf430c2efe5f data/input/popdat.bin
|
||||
946f8d43a49fb9238c15670e4e928319 data/input/popdat.bin
|
||||
428bc2e92ea02089cedbb614ce1d8f25 data/input/polygons/caphill.poly
|
||||
4f291bbe84ac32a98d7d100be79ddc4b data/input/polygons/huge_seattle.poly
|
||||
418bcd5b335d12a1aa8ef556367e0bad data/input/polygons/montlake.poly
|
||||
@ -212,19 +212,19 @@ b513d9b8898bf4f182e9f56806ea776f data/system/maps/downtown.bin
|
||||
9db50445605d901230a47a25b775f5e7 data/system/maps/montlake.bin
|
||||
a9f1e53561af81158e3d25ef40a4c70e data/system/maps/intl_district.bin
|
||||
7a924369483f4f43d9d04ebffeb433f6 data/system/maps/23rd.bin
|
||||
d71169fc1789707c403e70e6f2cc27d4 data/system/synthetic_maps/signal_double.json
|
||||
407cf814c6b5c73b5e1857529b94a204 data/system/synthetic_maps/signal_single.json
|
||||
7e3b93d87b5c6cf4788122e7f65ecac1 data/system/synthetic_maps/signal_fan_in.json
|
||||
b0dd7a752d56046b641f3a88c8307605 data/system/scenarios/ballard/weekday.bin
|
||||
6c6ac61123e7f801daf1d9c6176cdbe3 data/system/scenarios/intl_district/weekday.bin
|
||||
429e1182cf703edbce4add362c5fec6d data/system/scenarios/23rd/weekday.bin
|
||||
515a34fd94860939e7e46a219e270393 data/system/scenarios/downtown/weekday.bin
|
||||
ef861b04f6163ee870e7b1b529e170ef data/system/scenarios/huge_seattle/weekday.bin
|
||||
3dd368ab33aec9583cedd27c56584a71 data/system/scenarios/caphill/weekday.bin
|
||||
f141f12e6560aa81801dd715f4c1e01d data/system/scenarios/montlake/weekday.bin
|
||||
5f78d73efbabf06aed28c0e80c6b6d5b data/system/prebaked_results/23rd/weekday.bin
|
||||
bd719a801b06c4191229b1991f58cadd data/system/synthetic_maps/signal_double.json
|
||||
75ea1d3aafa7fed11eeffe80949a8613 data/system/synthetic_maps/signal_single.json
|
||||
75828c890af7ba001e3c4a6a81ddb4f6 data/system/synthetic_maps/signal_fan_in.json
|
||||
c3fc9600f17f6da3066632f4ffb24b19 data/system/scenarios/ballard/weekday.bin
|
||||
bd654abaa8640af5552e77402de95564 data/system/scenarios/intl_district/weekday.bin
|
||||
31f908a30af3b11d985efb38fab399d5 data/system/scenarios/23rd/weekday.bin
|
||||
f9c376fed1c3342605c0eb21664c000a data/system/scenarios/downtown/weekday.bin
|
||||
4accdf621f9b96c95a9daf9b7d60cc76 data/system/scenarios/huge_seattle/weekday.bin
|
||||
0e81cca0bffeee701452c4a512881508 data/system/scenarios/caphill/weekday.bin
|
||||
315f8ac4ff4374c2eda609280c7dce01 data/system/scenarios/montlake/weekday.bin
|
||||
aca1bff071cecad4683254b95c5570d1 data/system/prebaked_results/23rd/weekday.bin
|
||||
39dc5028982cc7ef40da44ec00ab1020 data/system/prebaked_results/signal_single/tutorial lvl1.bin
|
||||
c4f5661e5c62c0c0ccccc7c2b9f2d365 data/system/prebaked_results/signal_single/tutorial lvl2.bin
|
||||
b8137879ec00add4cd2a39e8c985420f data/system/prebaked_results/montlake/car vs bike contention.bin
|
||||
3cb2adbb509617b15007b92b373a8b97 data/system/prebaked_results/montlake/weekday.bin
|
||||
7f9aec66506cc24bcf7b2e74dbcf38f4 data/system/prebaked_results/montlake/car vs bus contention.bin
|
||||
2662a2f6996e5f7452d4e8e047c95440 data/system/prebaked_results/montlake/weekday.bin
|
||||
449475f6f7b54bc5726f07e20a5ee342 data/system/prebaked_results/montlake/car vs bus contention.bin
|
||||
|
@ -8,4 +8,4 @@ rm -rf data/input data/system
|
||||
unzip seed_data.zip
|
||||
rm -f seed_data.zip
|
||||
# The zip clobbers the .gitignore symlinks; just let git take care of it
|
||||
git checkout data/system
|
||||
git checkout data/system data/input
|
||||
|
@ -243,7 +243,8 @@
|
||||
"inner_x": 105.2988,
|
||||
"inner_y": 59.97
|
||||
},
|
||||
"intersection_type": "Border"
|
||||
"intersection_type": "Border",
|
||||
"elevation": 0.0
|
||||
}
|
||||
],
|
||||
[
|
||||
@ -255,7 +256,8 @@
|
||||
"inner_x": 0.0,
|
||||
"inner_y": 56.2852
|
||||
},
|
||||
"intersection_type": "Border"
|
||||
"intersection_type": "Border",
|
||||
"elevation": 0.0
|
||||
}
|
||||
],
|
||||
[
|
||||
@ -267,7 +269,8 @@
|
||||
"inner_x": 54.0428,
|
||||
"inner_y": 58.1482
|
||||
},
|
||||
"intersection_type": "TrafficSignal"
|
||||
"intersection_type": "TrafficSignal",
|
||||
"elevation": 0.0
|
||||
}
|
||||
],
|
||||
[
|
||||
@ -279,7 +282,8 @@
|
||||
"inner_x": 108.3093,
|
||||
"inner_y": 85.7917
|
||||
},
|
||||
"intersection_type": "Border"
|
||||
"intersection_type": "Border",
|
||||
"elevation": 0.0
|
||||
}
|
||||
],
|
||||
[
|
||||
@ -291,7 +295,8 @@
|
||||
"inner_x": 2.4243,
|
||||
"inner_y": 84.7824
|
||||
},
|
||||
"intersection_type": "Border"
|
||||
"intersection_type": "Border",
|
||||
"elevation": 0.0
|
||||
}
|
||||
],
|
||||
[
|
||||
@ -303,7 +308,8 @@
|
||||
"inner_x": 53.9654,
|
||||
"inner_y": 119.3452
|
||||
},
|
||||
"intersection_type": "Border"
|
||||
"intersection_type": "Border",
|
||||
"elevation": 0.0
|
||||
}
|
||||
],
|
||||
[
|
||||
@ -315,7 +321,8 @@
|
||||
"inner_x": 54.1467,
|
||||
"inner_y": 88.4731
|
||||
},
|
||||
"intersection_type": "TrafficSignal"
|
||||
"intersection_type": "TrafficSignal",
|
||||
"elevation": 0.0
|
||||
}
|
||||
],
|
||||
[
|
||||
@ -327,7 +334,8 @@
|
||||
"inner_x": 55.1641,
|
||||
"inner_y": 0.0
|
||||
},
|
||||
"intersection_type": "Border"
|
||||
"intersection_type": "Border",
|
||||
"elevation": 0.0
|
||||
}
|
||||
]
|
||||
],
|
||||
@ -375,4 +383,4 @@
|
||||
"max_lon": -122.44015604243269,
|
||||
"max_lat": 47.7155
|
||||
}
|
||||
}
|
||||
}
|
@ -402,7 +402,8 @@
|
||||
"inner_x": 0.4655,
|
||||
"inner_y": 93.6788
|
||||
},
|
||||
"intersection_type": "Border"
|
||||
"intersection_type": "Border",
|
||||
"elevation": 0.0
|
||||
}
|
||||
],
|
||||
[
|
||||
@ -414,7 +415,8 @@
|
||||
"inner_x": 0.6069,
|
||||
"inner_y": 75.1818
|
||||
},
|
||||
"intersection_type": "Border"
|
||||
"intersection_type": "Border",
|
||||
"elevation": 0.0
|
||||
}
|
||||
],
|
||||
[
|
||||
@ -426,7 +428,8 @@
|
||||
"inner_x": 0.1557,
|
||||
"inner_y": 55.5923
|
||||
},
|
||||
"intersection_type": "Border"
|
||||
"intersection_type": "Border",
|
||||
"elevation": 0.0
|
||||
}
|
||||
],
|
||||
[
|
||||
@ -438,7 +441,8 @@
|
||||
"inner_x": 0.293,
|
||||
"inner_y": 44.3784
|
||||
},
|
||||
"intersection_type": "Border"
|
||||
"intersection_type": "Border",
|
||||
"elevation": 0.0
|
||||
}
|
||||
],
|
||||
[
|
||||
@ -450,7 +454,8 @@
|
||||
"inner_x": 1.0292,
|
||||
"inner_y": 32.0944
|
||||
},
|
||||
"intersection_type": "Border"
|
||||
"intersection_type": "Border",
|
||||
"elevation": 0.0
|
||||
}
|
||||
],
|
||||
[
|
||||
@ -462,7 +467,8 @@
|
||||
"inner_x": 0.1557,
|
||||
"inner_y": 12.6638
|
||||
},
|
||||
"intersection_type": "Border"
|
||||
"intersection_type": "Border",
|
||||
"elevation": 0.0
|
||||
}
|
||||
],
|
||||
[
|
||||
@ -474,7 +480,8 @@
|
||||
"inner_x": 0.0,
|
||||
"inner_y": 0.0
|
||||
},
|
||||
"intersection_type": "Border"
|
||||
"intersection_type": "Border",
|
||||
"elevation": 0.0
|
||||
}
|
||||
],
|
||||
[
|
||||
@ -486,7 +493,8 @@
|
||||
"inner_x": 70.6223,
|
||||
"inner_y": 72.7181
|
||||
},
|
||||
"intersection_type": "TrafficSignal"
|
||||
"intersection_type": "TrafficSignal",
|
||||
"elevation": 0.0
|
||||
}
|
||||
],
|
||||
[
|
||||
@ -498,7 +506,8 @@
|
||||
"inner_x": 61.904,
|
||||
"inner_y": 43.3266
|
||||
},
|
||||
"intersection_type": "TrafficSignal"
|
||||
"intersection_type": "TrafficSignal",
|
||||
"elevation": 0.0
|
||||
}
|
||||
],
|
||||
[
|
||||
@ -510,7 +519,8 @@
|
||||
"inner_x": 62.8491,
|
||||
"inner_y": 16.6987
|
||||
},
|
||||
"intersection_type": "TrafficSignal"
|
||||
"intersection_type": "TrafficSignal",
|
||||
"elevation": 0.0
|
||||
}
|
||||
],
|
||||
[
|
||||
@ -522,7 +532,8 @@
|
||||
"inner_x": 116.7975,
|
||||
"inner_y": 45.046
|
||||
},
|
||||
"intersection_type": "TrafficSignal"
|
||||
"intersection_type": "TrafficSignal",
|
||||
"elevation": 0.0
|
||||
}
|
||||
],
|
||||
[
|
||||
@ -534,7 +545,8 @@
|
||||
"inner_x": 157.3391,
|
||||
"inner_y": 45.721
|
||||
},
|
||||
"intersection_type": "Border"
|
||||
"intersection_type": "Border",
|
||||
"elevation": 0.0
|
||||
}
|
||||
]
|
||||
],
|
||||
@ -582,4 +594,4 @@
|
||||
"max_lon": -122.43950238710731,
|
||||
"max_lat": 47.7155
|
||||
}
|
||||
}
|
||||
}
|
@ -283,7 +283,8 @@
|
||||
"inner_x": 267.1578,
|
||||
"inner_y": 110.0065
|
||||
},
|
||||
"intersection_type": "Border"
|
||||
"intersection_type": "Border",
|
||||
"elevation": 0.0
|
||||
}
|
||||
],
|
||||
[
|
||||
@ -295,7 +296,8 @@
|
||||
"inner_x": 0.0,
|
||||
"inner_y": 111.7355
|
||||
},
|
||||
"intersection_type": "Border"
|
||||
"intersection_type": "Border",
|
||||
"elevation": 0.0
|
||||
}
|
||||
],
|
||||
[
|
||||
@ -307,7 +309,8 @@
|
||||
"inner_x": 134.1818,
|
||||
"inner_y": 0.0
|
||||
},
|
||||
"intersection_type": "Border"
|
||||
"intersection_type": "Border",
|
||||
"elevation": 0.0
|
||||
}
|
||||
],
|
||||
[
|
||||
@ -319,7 +322,8 @@
|
||||
"inner_x": 133.8374,
|
||||
"inner_y": 214.4221
|
||||
},
|
||||
"intersection_type": "Border"
|
||||
"intersection_type": "Border",
|
||||
"elevation": 0.0
|
||||
}
|
||||
],
|
||||
[
|
||||
@ -331,7 +335,8 @@
|
||||
"inner_x": 213.5767,
|
||||
"inner_y": 110.065
|
||||
},
|
||||
"intersection_type": "StopSign"
|
||||
"intersection_type": "StopSign",
|
||||
"elevation": 0.0
|
||||
}
|
||||
],
|
||||
[
|
||||
@ -343,7 +348,8 @@
|
||||
"inner_x": 41.8277,
|
||||
"inner_y": 111.5761
|
||||
},
|
||||
"intersection_type": "StopSign"
|
||||
"intersection_type": "StopSign",
|
||||
"elevation": 0.0
|
||||
}
|
||||
],
|
||||
[
|
||||
@ -355,7 +361,8 @@
|
||||
"inner_x": 133.2079,
|
||||
"inner_y": 170.6141
|
||||
},
|
||||
"intersection_type": "StopSign"
|
||||
"intersection_type": "StopSign",
|
||||
"elevation": 0.0
|
||||
}
|
||||
],
|
||||
[
|
||||
@ -367,7 +374,8 @@
|
||||
"inner_x": 133.8558,
|
||||
"inner_y": 110.6546
|
||||
},
|
||||
"intersection_type": "TrafficSignal"
|
||||
"intersection_type": "TrafficSignal",
|
||||
"elevation": 0.0
|
||||
}
|
||||
],
|
||||
[
|
||||
@ -379,7 +387,8 @@
|
||||
"inner_x": 133.6389,
|
||||
"inner_y": 44.5954
|
||||
},
|
||||
"intersection_type": "StopSign"
|
||||
"intersection_type": "StopSign",
|
||||
"elevation": 0.0
|
||||
}
|
||||
]
|
||||
],
|
||||
@ -427,4 +436,4 @@
|
||||
"max_lon": -122.43803830652608,
|
||||
"max_lat": 47.7155
|
||||
}
|
||||
}
|
||||
}
|
@ -62,7 +62,8 @@ build everything totally from scratch by running
|
||||
You'll need some extra dependencies:
|
||||
|
||||
- `osmconvert`: See https://wiki.openstreetmap.org/wiki/Osmconvert#Download
|
||||
- `cs2cs` from proj4: See https://proj.org
|
||||
- `libgdal-dev`: See https://gdal.org/ if your OS package manager doesn't have
|
||||
this
|
||||
|
||||
Some tips:
|
||||
|
||||
|
@ -9,6 +9,7 @@ abstutil = { path = "../abstutil" }
|
||||
csv = "1.0.1"
|
||||
failure = "0.1.2"
|
||||
geom = { path = "../geom" }
|
||||
gdal = "0.6.0"
|
||||
map_model = { path = "../map_model" }
|
||||
serde = "1.0.98"
|
||||
serde_derive = "1.0.98"
|
||||
|
@ -4,7 +4,7 @@ use map_model::Map;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use std::collections::{BTreeMap, HashMap, HashSet};
|
||||
use std::fs::File;
|
||||
use std::io::{BufRead, BufReader, BufWriter, Write};
|
||||
use std::io::Write;
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct Trip {
|
||||
@ -179,7 +179,10 @@ fn import_parcels(
|
||||
closest_bldg.add(b.osm_way_id, b.polygon.points());
|
||||
}
|
||||
|
||||
let mut coords = BufWriter::new(File::create("/tmp/parcels")?);
|
||||
let mut x_coords: Vec<f64> = Vec::new();
|
||||
let mut y_coords: Vec<f64> = Vec::new();
|
||||
// Dummy values
|
||||
let mut z_coords: Vec<f64> = Vec::new();
|
||||
// (parcel ID, number of households, number of employees, number of parking spots)
|
||||
let mut parcel_metadata = Vec::new();
|
||||
|
||||
@ -197,65 +200,43 @@ fn import_parcels(
|
||||
rec.emptot_p,
|
||||
rec.parkdy_p + rec.parkhr_p,
|
||||
));
|
||||
coords.write_fmt(format_args!("{} {}\n", rec.xcoord_p, rec.ycoord_p))?;
|
||||
x_coords.push(rec.xcoord_p);
|
||||
y_coords.push(rec.ycoord_p);
|
||||
z_coords.push(0.0);
|
||||
}
|
||||
done(timer);
|
||||
coords.flush()?;
|
||||
|
||||
// TODO Ideally we could just do the conversion directly without any dependencies, but the
|
||||
// formats are documented quite confusingly. Couldn't get the Rust crate for proj or GDAL
|
||||
// bindings to build. So just do this hack.
|
||||
timer.start(format!(
|
||||
"run cs2cs on {} points",
|
||||
prettyprint_usize(parcel_metadata.len())
|
||||
));
|
||||
let mut output = std::process::Command::new("cs2cs")
|
||||
.args(vec![
|
||||
"esri:102748",
|
||||
"+to",
|
||||
"epsg:4326",
|
||||
"-f",
|
||||
"%.5f",
|
||||
"/tmp/parcels",
|
||||
])
|
||||
.output()?;
|
||||
if !output.status.success() {
|
||||
// If you have an ancient version of cs2cs (like from Ubuntu's proj-bin package), the
|
||||
// command should instead be:
|
||||
// cs2cs +init=esri:102748 +to +init=epsg:4326 -f '%.5f' foo
|
||||
output = std::process::Command::new("cs2cs")
|
||||
.args(vec![
|
||||
"+init=esri:102748",
|
||||
"+to",
|
||||
"+init=epsg:4326",
|
||||
"-f",
|
||||
"%.5f",
|
||||
"/tmp/parcels",
|
||||
])
|
||||
.output()?;
|
||||
}
|
||||
assert!(output.status.success());
|
||||
timer.stop(format!(
|
||||
"run cs2cs on {} points",
|
||||
prettyprint_usize(parcel_metadata.len())
|
||||
));
|
||||
timer.start(format!("transform {} points", parcel_metadata.len()));
|
||||
|
||||
// From https://epsg.io/102748 to https://epsg.io/4326
|
||||
let transform = gdal::spatial_ref::CoordTransform::new(
|
||||
&gdal::spatial_ref::SpatialRef::from_proj4(
|
||||
"+proj=lcc +lat_1=47.5 +lat_2=48.73333333333333 +lat_0=47 +lon_0=-120.8333333333333 \
|
||||
+x_0=500000.0000000002 +y_0=0 +datum=NAD83 +units=us-ft +no_defs",
|
||||
)
|
||||
.expect("washington state plane"),
|
||||
&gdal::spatial_ref::SpatialRef::from_epsg(4326).unwrap(),
|
||||
)
|
||||
.expect("regular GPS");
|
||||
transform
|
||||
.transform_coords(&mut x_coords, &mut y_coords, &mut z_coords)
|
||||
.expect("transform coords");
|
||||
|
||||
timer.stop(format!("transform {} points", parcel_metadata.len()));
|
||||
|
||||
let bounds = map.get_gps_bounds();
|
||||
let reader = BufReader::new(output.stdout.as_slice());
|
||||
let mut result = HashMap::new();
|
||||
let mut metadata = BTreeMap::new();
|
||||
let mut oob = HashMap::new();
|
||||
let orig_parcels = parcel_metadata.len();
|
||||
timer.start_iter("read cs2cs output", parcel_metadata.len());
|
||||
for (line, (id, num_households, num_employees, offstreet_parking_spaces)) in
|
||||
reader.lines().zip(parcel_metadata.into_iter())
|
||||
timer.start_iter("finalize parcel output", parcel_metadata.len());
|
||||
for ((x, y), (id, num_households, num_employees, offstreet_parking_spaces)) in x_coords
|
||||
.into_iter()
|
||||
.zip(y_coords.into_iter())
|
||||
.zip(parcel_metadata.into_iter())
|
||||
{
|
||||
timer.next();
|
||||
let line = line?;
|
||||
let pieces: Vec<&str> = line.split_whitespace().collect();
|
||||
let lon: f64 = pieces[0].parse()?;
|
||||
let lat: f64 = pieces[1].parse()?;
|
||||
let pt = LonLat::new(lon, lat);
|
||||
let pt = LonLat::new(x, y);
|
||||
if bounds.contains(pt) {
|
||||
let osm_building = closest_bldg
|
||||
.closest_pt(Pt2D::forcibly_from_gps(pt, bounds), Distance::meters(30.0))
|
||||
|
Loading…
Reference in New Issue
Block a user