Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update GTFS parser according to the specifications #398

Merged
merged 63 commits into from
Oct 16, 2019
Merged
Show file tree
Hide file tree
Changes from 61 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
c72eb1f
Add some logging in the sanitizer
woshilapin Oct 4, 2019
e843e2c
Add 'source' object code for 'stop_point'
woshilapin Oct 7, 2019
fd463f6
Add 'gtfs_stop_code' in the specification
woshilapin Oct 8, 2019
0be2ab5
Add prefix to Frequency
woshilapin Oct 8, 2019
f54e322
read / write pathways
patochectp Sep 12, 2019
48863ff
read / write levels.txt
patochectp Sep 13, 2019
b07a1f5
manage level_id on stops
patochectp Sep 13, 2019
819cf06
update test
patochectp Sep 13, 2019
24b5f33
stops.txt : read / write StopLocation
patochectp Sep 18, 2019
24599a9
fix bug on id
patochectp Sep 19, 2019
c9009a5
refactoring
patochectp Sep 25, 2019
8123147
update test
patochectp Sep 25, 2019
416debd
gtfs parser refactoring
patochectp Oct 2, 2019
0033f9b
ntfs parser refactoring
patochectp Oct 3, 2019
7cbee69
add test
patochectp Oct 7, 2019
a75cb17
consideration of comments
patochectp Oct 8, 2019
b2d2d2a
fix fmt error
patochectp Oct 9, 2019
49c1acf
Merge pull request #404 from woshilapin/prefix-frequencies
mergify[bot] Oct 9, 2019
5231aaa
Merge branch 'master' into gtfs_stop_code
mergify[bot] Oct 9, 2019
43cc7da
Merge pull request #403 from woshilapin/gtfs_stop_code
mergify[bot] Oct 9, 2019
79d12ce
Merge branch 'master' into stop-point-source
mergify[bot] Oct 9, 2019
b0fc2d2
Merge pull request #401 from woshilapin/stop-point-source
mergify[bot] Oct 9, 2019
7a4492b
Merge branch 'master' into sanitize-logs
mergify[bot] Oct 10, 2019
b9c8a4d
Merge pull request #399 from woshilapin/sanitize-logs
mergify[bot] Oct 10, 2019
ceee671
Bump version 0.9.0
Oct 10, 2019
fa5f96d
Provide a 'only_child' blanket implementation
woshilapin Oct 11, 2019
307195f
Transform Into implementation into From
woshilapin Oct 11, 2019
9a00759
Tests stops without geolocation and pathways with stairs
woshilapin Oct 11, 2019
0f76596
upgrade minidom
Oct 11, 2019
c3d37e4
[Fix] [KV1] Skip route (and line) if no vj above (instead of fail pro…
ArnaudOggy Oct 11, 2019
81e7ecd
Merge pull request #410 from ArnaudOggy/fix_kv1_orphan_routes
mergify[bot] Oct 14, 2019
72a88ac
Force a boolean to be 0 or 1 in deserialization
woshilapin Oct 14, 2019
4e70b2c
Merge branch 'master' into upgrade-minidom
mergify[bot] Oct 14, 2019
26858fb
Merge pull request #409 from datanel/upgrade-minidom
mergify[bot] Oct 14, 2019
f085744
Remove useless packages
Oct 11, 2019
cca8c24
Merge branch 'master' into only-child
mergify[bot] Oct 14, 2019
940f844
Merge pull request #408 from woshilapin/only-child
mergify[bot] Oct 14, 2019
83c445d
Merge pull request #1 from woshilapin/update_gtfs_parser-from
patochectp Oct 14, 2019
7151602
Merge pull request #2 from woshilapin/update_gtfs_parser-tests
patochectp Oct 14, 2019
d8503f0
Merge branch 'master' into remove_packages
mergify[bot] Oct 14, 2019
f047bd1
Merge pull request #411 from datanel/remove_packages
mergify[bot] Oct 14, 2019
3ccc041
read / write pathways
patochectp Sep 12, 2019
d482f64
read / write levels.txt
patochectp Sep 13, 2019
2e6140c
manage level_id on stops
patochectp Sep 13, 2019
131b38c
update test
patochectp Sep 13, 2019
d64a748
stops.txt : read / write StopLocation
patochectp Sep 18, 2019
ac407c5
fix bug on id
patochectp Sep 19, 2019
0d8825b
refactoring
patochectp Sep 25, 2019
c5fe66e
update test
patochectp Sep 25, 2019
feaa4f3
gtfs parser refactoring
patochectp Oct 2, 2019
2ace6bc
ntfs parser refactoring
patochectp Oct 3, 2019
168f155
add test
patochectp Oct 7, 2019
dd7c3b4
consideration of comments
patochectp Oct 8, 2019
30fd259
fix fmt error
patochectp Oct 9, 2019
c9382c9
Transform Into implementation into From
woshilapin Oct 11, 2019
957f6be
Tests stops without geolocation and pathways with stairs
woshilapin Oct 11, 2019
c2c788c
fix bug after rebase
patochectp Oct 15, 2019
90e1b13
Merge pull request #3 from woshilapin/update_gtfs_parser-bool
patochectp Oct 15, 2019
3f64e4b
Force a boolean to be 0 or 1 in deserialization
patochectp Oct 15, 2019
d8de89a
add conditional compilation : stop_location
patochectp Oct 15, 2019
8d9037a
update fixture with new version ntfs
patochectp Oct 15, 2019
b60f26f
Manage pathways refactoring
ArnaudOggy Oct 15, 2019
bf086d9
Merge pull request #4 from ArnaudOggy/update_gtfs_parser
patochectp Oct 15, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,19 @@ travis-ci = { repository = "CanalTP/transit_model" }
chrono = "0.4"
csv = "1.0"
derivative = "1"
env_logger = "0.6"
failure = "0.1"
geo = "0.12"
geo-types = "0.4"
iso4217 = "0.3"
lazy_static = "1.2"
log = "0.4"
minidom = "0.9"
minidom = "0.11"
num-traits = "0.2"
pretty_assertions = "0.6"
proj = { version = "0.10", optional = true }
rust_decimal = "1.0"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
structopt = "0.3"
tempfile = "3"
time-parse = "0.1"
transit_model_procmacro = { version = "0.1", path = "./transit_model_procmacro" }
Expand Down
1 change: 0 additions & 1 deletion examples/gtfs_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ fn run() -> Result<()> {
}

fn main() {
env_logger::init();
if let Err(err) = run() {
for cause in err.iter_chain() {
eprintln!("{}", cause);
Expand Down
1 change: 0 additions & 1 deletion examples/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ fn run() -> Result<()> {
}

fn main() {
env_logger::init();
if let Err(err) = run() {
for cause in err.iter_chain() {
eprintln!("{}", cause);
Expand Down
4 changes: 4 additions & 0 deletions src/add_prefix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ impl AddPrefix for Collections {
self.lines.add_prefix(&prefix);
self.routes.add_prefix(&prefix);
self.vehicle_journeys.add_prefix(&prefix);
self.frequencies.add_prefix(&prefix);
self.stop_areas.add_prefix(&prefix);
self.stop_points.add_prefix(&prefix);
self.stop_locations.add_prefix(&prefix);
self.calendars.add_prefix(&prefix);
self.companies.add_prefix(&prefix);
self.comments.add_prefix(&prefix);
Expand All @@ -76,6 +78,8 @@ impl AddPrefix for Collections {
self.ticket_uses.add_prefix(&prefix);
self.ticket_use_perimeters.add_prefix(&prefix);
self.ticket_use_restrictions.add_prefix(&prefix);
self.pathways.add_prefix(&prefix);
self.levels.add_prefix(&prefix);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/documentation/gtfs_to_ntfs_specs.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ Like the GTFS, the NTFS group stop_points and stop_areas in on file : stops.txt.
The `parent_station` of the stop_point should then contain the generated `stop_area.id`.

(2) The `stop_code` field is added as a complementary `object_code` with the following properties:
+ `object_type` : _stop_point_ or _stop_area_ accordingly to the `location_type` value
+ `object_type` : `stop_point` or `stop_area` accordingly to the `location_type` value
+ `object_id` : NTFS `stop_id`
+ `object_system` : Fixed value "source"
+ `object_system` : Fixed value `gtfs_stop_code`
+ `object_code` : value of the `stop_code` property

(3) The `comment` object is a complex type with additional properties :
Expand Down
53 changes: 41 additions & 12 deletions src/gtfs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,30 @@ enum StopLocationType {
BoardingArea,
}

impl From<StopLocationType> for StopType {
fn from(stop_location_type: StopLocationType) -> StopType {
match stop_location_type {
StopLocationType::StopPoint => StopType::Point,
StopLocationType::StopArea => StopType::Zone,
StopLocationType::StopEntrance => StopType::StopEntrance,
StopLocationType::GenericNode => StopType::GenericNode,
StopLocationType::BoardingArea => StopType::BoardingArea,
}
}
}

impl From<StopType> for StopLocationType {
fn from(stop_type: StopType) -> StopLocationType {
match stop_type {
StopType::Point => StopLocationType::StopPoint,
StopType::Zone => StopLocationType::StopArea,
StopType::StopEntrance => StopLocationType::StopEntrance,
StopType::GenericNode => StopLocationType::GenericNode,
StopType::BoardingArea => StopLocationType::BoardingArea,
}
}
}

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
struct Stop {
#[serde(rename = "stop_id", deserialize_with = "de_without_slashes")]
Expand All @@ -98,18 +122,16 @@ struct Stop {
code: Option<String>,
#[serde(rename = "stop_name")]
name: String,
#[serde(default, rename = "stop_desc")]
desc: String,
#[serde(
rename = "stop_lon",
deserialize_with = "de_location_trim_with_default"
)]
lon: f64,
#[serde(
rename = "stop_lat",
deserialize_with = "de_location_trim_with_default"
default,
rename = "stop_desc",
deserialize_with = "de_option_empty_string"
)]
lat: f64,
desc: Option<String>,
#[serde(rename = "stop_lon")]
lon: String,
#[serde(rename = "stop_lat")]
lat: String,
#[serde(rename = "zone_id")]
fare_zone_id: Option<String>,
#[serde(rename = "stop_url")]
Expand All @@ -120,6 +142,7 @@ struct Stop {
parent_station: Option<String>,
#[serde(rename = "stop_timezone")]
timezone: Option<String>,
level_id: Option<String>,
#[serde(deserialize_with = "de_with_empty_default", default)]
wheelchair_boarding: Availability,
platform_code: Option<String>,
Expand Down Expand Up @@ -259,10 +282,12 @@ where
let (networks, companies) = read::read_agency(file_handler)?;
collections.networks = networks;
collections.companies = companies;
let (stop_areas, stop_points) = read::read_stops(file_handler, &mut comments, &mut equipments)?;
let (stop_areas, stop_points, stop_locations) =
read::read_stops(file_handler, &mut comments, &mut equipments)?;
collections.transfers = read::read_transfers(file_handler, &stop_points)?;
collections.stop_areas = stop_areas;
collections.stop_points = stop_points;
collections.stop_locations = stop_locations;

read::manage_shapes(&mut collections, file_handler)?;

Expand All @@ -271,7 +296,8 @@ where
collections.comments = comments;
read::manage_stop_times(&mut collections, file_handler)?;
read::manage_frequencies(&mut collections, file_handler)?;

collections.pathways = read::read_pathways(&mut collections, file_handler)?;
collections.levels = read_utils::read_opt_collection(file_handler, "levels.txt")?;
collections.sanitize()?;

//add prefixes
Expand Down Expand Up @@ -404,6 +430,7 @@ pub fn write<P: AsRef<Path>>(model: Model, path: P) -> Result<()> {
path,
&model.stop_points,
&model.stop_areas,
&model.stop_locations,
&model.comments,
&model.equipments,
)?;
Expand All @@ -423,6 +450,8 @@ pub fn write<P: AsRef<Path>>(model: Model, path: P) -> Result<()> {
&model.stop_time_headsigns,
)?;
write::write_shapes(path, &model.geometries)?;
write_collection_with_id(path, "pathways.txt", &model.pathways)?;
write_collection_with_id(path, "levels.txt", &model.levels)?;

Ok(())
}
Loading