Open Robinlovelace opened 3 years ago
Using the larger example in #17. Will try on the minimal one also...
Fixed the issue by multiplying by 1000 and making it an integer. Next issue is easier to debug:
cargo run --bin import_traffic -- \
--map=data/system/us/seattle/maps/montlake.bin \
--input=minimal_scenario.json
Finished dev [unoptimized + debuginfo] target(s) in 0.14s
Running `target/debug/import_traffic --map=data/system/us/seattle/maps/montlake.bin --input=minimal_scenario.json`
import traffic demand data...
Read data/system/us/seattle/maps/montlake.bin (3)... 0.4319s
parse minimal_scenario.json...
parse minimal_scenario.json took 0.0001s
thread 'main' panicked at 'Couldn't read_json(minimal_scenario.json): unknown variant `Leisure`, expected one of `Home`, `Work`, `School`, `Escort`, `PersonalBusiness`, `Shopping`, `Meal`, `Social`, `Recreation`, `Medical`, `ParkAndRideTransfer` at line 38 column 30', /mnt/57982e2a-2874-4246-a6fe-115c199bc6bd/orgs/a-b-street/abstreet/abstio/src/io.rs:26:21
PR incoming...
Oops, should probably check JSON in the docs more carefully. cargo run --bin dump_scenario -- data/system/us/seattle/scenarios/montlake/weekday.bin
serializes a real working scenario as JSON, so copying from / comparing with that is the safest bet...
Edit: got the file path wrong, it is not my day...
Awesome. It works!
...
{
"depart": 541800000,
"origin": {
"Bldg": 457
},
"destination": {
"Border": 499
},
"mode": "Drive",
"purpose": "Work",
"cancelled": false,
"modified": false
}
]
}
],
"only_seed_buses": null
}
Wait I'm really not thinking clearly. The Scenario format and the ExternalPerson
format are totally different. Ignore what I just said. Multiplying by 1000 and fixing the mode enum was fine.
All good. I'm looking at a landscape screen friendly scenario now...
Associated json below. Seem reasonable?
{
"scenario_name": "monday",
"people": [
{
"trips": [
{
"departure": 391200000,
"origin": {
"Position": {
"longitude": -122.303723,
"latitude": 47.6372834
}
},
"destination": {
"Position": {
"longitude": -122.3190500,
"latitude": 47.6378600
}
},
"mode": "Drive",
"purpose": "Shopping"
},
{
"departure": 430800000,
"origin": {
"Position": {
"longitude": -122.3075948,
"latitude": 47.6394773
}
},
"destination": {
"Position": {
"longitude": -122.3190500,
"latitude": 47.6378600
}
},
"mode": "Walk",
"purpose": "Recreation"
}
]
}
]
}
Although I would replace Drive with Bike as the distances are small.
Is origin and destination swapped for the second trip?
Looks like it...
Also, when I import it nothing shows. Any ideas why?
Reproducible example...
cargo run --bin import_traffic -- \\n --map=data/system/us/seattle/maps/montlake.bin \\n --input=minimal_scenario.json
cargo run --bin game -- --dev data/system/us/seattle/maps/montlake.bin\n
That's with:
{
"scenario_name": "monday",
"people": [
{
"trips": [
{
"departure": 391200000,
"origin": {
"Position": {
"longitude": -122.303723,
"latitude": 47.6372834
}
},
"destination": {
"Position": {
"longitude": -122.3190500,
"latitude": 47.6378600
}
},
"mode": "Bike",
"purpose": "Shopping"
},
{
"departure": 430800000,
"origin": {
"Position": {
"longitude": -122.3190500,
"latitude": 47.6378600
}
},
"destination": {
"Position": {
"longitude": -122.3075948,
"latitude": 47.6394773
}
},
"mode": "Walk",
"purpose": "Recreation"
}
]
}
]
}
as minimal_scenario.json
.
I've updated the times, e.g. to "departure": 10800000,
It's working! Slightly random time but that's fine...
Follow-up question, guess there's a simple question to this one, why don't they go by Bike as per the JSON (guess: there is not bike nearby or it's too near to cycle)?
Apologies, they are biking :tada:
On a midnight food mission.
It's worth doing but currently I get the following error message: