mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-24 09:24:26 +03:00
Add a tool to convert maps from JSON back to binary, to enable experiments with modifying parking per buildings. Except... apparently we can't read back in JSON maps?!
This commit is contained in:
parent
4ab98b1477
commit
6a2c391b8b
@ -108,6 +108,20 @@ cargo run --bin dump_map data/system/seattle/maps/montlake.bin > montlake.json
|
||||
See some example code that
|
||||
[reads this JSON and finds buildings](https://github.com/dabreegster/abstreet/blob/master/headless/examples/generate_traffic.py).
|
||||
|
||||
You could also edit the map JSON, convert it back to binary, and use it in the
|
||||
simulation. This isn't recommended generally, but one possible use case could be
|
||||
tuning the amount of offstreet parking per building. The map JSON has a list
|
||||
called `buildings`, and each object there has a field `parking`. You coud set
|
||||
this object to `{ "Private": [100, false] }` to indicate 100 parking spots, for
|
||||
a building not explicitly designated in OpenStreetMap as a garage. After editing
|
||||
the JSON, you have to convert it back to the binary format:
|
||||
|
||||
```
|
||||
cargo run --bin json_to_binary_map -- --input=montlake.json out=data/system/seattle/maps/montlake_modified.bin`
|
||||
```
|
||||
|
||||
... Except this tool doesn't seem to work yet!
|
||||
|
||||
The format of the map isn't well-documented yet. See the
|
||||
[generated API docs](https://dabreegster.github.io/abstreet/rustdoc/map_model/index.html)
|
||||
and [the map model docs](../map/index.md) in the meantime.
|
||||
|
11
importer/src/bin/json_to_binary_map.rs
Normal file
11
importer/src/bin/json_to_binary_map.rs
Normal file
@ -0,0 +1,11 @@
|
||||
use abstutil::{CmdArgs, Timer};
|
||||
use map_model::Map;
|
||||
|
||||
fn main() {
|
||||
let mut args = CmdArgs::new();
|
||||
// TODO This can't handle the output of dump_map! What?!
|
||||
let mut map: Map = abstutil::read_json(args.required("--input"), &mut Timer::throwaway());
|
||||
map.map_loaded_directly();
|
||||
abstutil::write_binary(args.required("--output"), &map);
|
||||
args.done();
|
||||
}
|
Loading…
Reference in New Issue
Block a user