mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-25 07:25:47 +03:00
Import any mode type from grid2demand
This commit is contained in:
parent
8826af31cb
commit
077fef92de
@ -1,4 +1,4 @@
|
||||
use anyhow::{anyhow, Result};
|
||||
use anyhow::{anyhow, bail, Result};
|
||||
use serde::Deserialize;
|
||||
|
||||
use abstutil::{prettyprint_usize, CmdArgs, Timer};
|
||||
@ -41,8 +41,13 @@ fn parse_trips(csv_path: String) -> Result<Vec<ExternalPerson>> {
|
||||
let mut people = Vec::new();
|
||||
for rec in csv::Reader::from_reader(std::fs::File::open(csv_path)?).deserialize() {
|
||||
let rec: Record = rec?;
|
||||
// Only one mode is encoded by input_agents.csv right now.
|
||||
assert_eq!(rec.agent_type, "v");
|
||||
let mode = match rec.agent_type.as_ref() {
|
||||
"v" => TripMode::Drive,
|
||||
"b" => TripMode::Bike,
|
||||
"p" => TripMode::Walk,
|
||||
"t" => TripMode::Transit,
|
||||
x => bail!("Unknown agent_type {}", x),
|
||||
};
|
||||
let (origin, destination) = parse_linestring(&rec.geometry)
|
||||
.ok_or_else(|| anyhow!("didn't parse geometry {}", rec.geometry))?;
|
||||
let departure = parse_time(rec.departure_time)?;
|
||||
@ -53,7 +58,7 @@ fn parse_trips(csv_path: String) -> Result<Vec<ExternalPerson>> {
|
||||
trips: vec![ExternalTrip {
|
||||
departure,
|
||||
destination: ExternalTripEndpoint::Position(destination),
|
||||
mode: TripMode::Drive,
|
||||
mode,
|
||||
purpose: TripPurpose::Work,
|
||||
}],
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user