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
Changes from 1 commit
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
1 change: 1 addition & 0 deletions src/add_prefix.rs
Original file line number Diff line number Diff line change
@@ -78,6 +78,7 @@ impl AddPrefix for Collections {
self.ticket_use_perimeters.add_prefix(&prefix);
self.ticket_use_restrictions.add_prefix(&prefix);
self.pathways.add_prefix(&prefix);
self.levels.add_prefix(&prefix);
}
}

2 changes: 2 additions & 0 deletions src/gtfs/mod.rs
Original file line number Diff line number Diff line change
@@ -272,6 +272,7 @@ where
read::manage_stop_times(&mut collections, file_handler)?;
read::manage_frequencies(&mut collections, file_handler)?;
collections.pathways = read_utils::read_opt_collection(file_handler, "pathways.txt")?;
collections.levels = read_utils::read_opt_collection(file_handler, "levels.txt")?;
collections.sanitize()?;

//add prefixes
@@ -424,6 +425,7 @@ pub fn write<P: AsRef<Path>>(model: Model, path: P) -> Result<()> {
)?;
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(())
}
1 change: 1 addition & 0 deletions src/model.rs
Original file line number Diff line number Diff line change
@@ -69,6 +69,7 @@ pub struct Collections {
pub ticket_use_perimeters: Collection<TicketUsePerimeter>,
pub ticket_use_restrictions: Collection<TicketUseRestriction>,
pub pathways: CollectionWithId<Pathway>,
pub levels: CollectionWithId<Level>,
}

impl Collections {
2 changes: 2 additions & 0 deletions src/ntfs/mod.rs
Original file line number Diff line number Diff line change
@@ -174,6 +174,7 @@ pub fn read<P: AsRef<path::Path>>(path: P) -> Result<Model> {
collections.ticket_use_perimeters = make_opt_collection(path, "ticket_use_perimeters.txt")?;
collections.ticket_use_restrictions = make_opt_collection(path, "ticket_use_restrictions.txt")?;
collections.pathways = make_opt_collection_with_id(path, "pathways.txt")?;
collections.levels = make_opt_collection_with_id(path, "levels.txt")?;
manage_calendars(&mut file_handle, &mut collections)?;
read::manage_geometries(&mut collections, path)?;
read::manage_feed_infos(&mut collections, path)?;
@@ -243,6 +244,7 @@ pub fn write<P: AsRef<path::Path>>(
write::write_object_properties(path, model)?;
write::write_fares_v1(path, &model)?;
write_collection_with_id(path, "pathways.txt", &model.pathways)?;
write_collection_with_id(path, "levels.txt", &model.levels)?;

Ok(())
}
16 changes: 16 additions & 0 deletions src/objects.rs
Original file line number Diff line number Diff line change
@@ -1113,6 +1113,22 @@ impl AddPrefix for Pathway {
}
impl_id!(Pathway);

#[derive(Serialize, Deserialize, Debug, PartialEq, Default, Clone)]
pub struct Level {
#[serde(rename = "level_id")]
pub id: String,
pub level_index: f32,
pub level_name: Option<String>,
}

impl AddPrefix for Level {
fn add_prefix(&mut self, prefix: &str) {
self.id = prefix.to_string() + &self.id;
}
}
impl_id!(Level);


pub type Date = chrono::NaiveDate;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
9 changes: 3 additions & 6 deletions src/utils.rs
Original file line number Diff line number Diff line change
@@ -186,8 +186,8 @@ where
Ok(number)
} else {
Err(D::Error::invalid_value(
Other("strictly negative integer number"),
&"positive integer number",
Other("strictly negative float number"),
&"positive float number",
))
}
}
@@ -242,10 +242,7 @@ where
match option {
Some(number) if number != 0 => Ok(option),
None => Ok(None),
_ => Err(D::Error::invalid_value(
Other("0"),
&"non null number",
)),
_ => Err(D::Error::invalid_value(Other("0"), &"non null number")),
}
}