-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Implement unusable_trip rule Fixes #206. * Fix implementation * Properly plug the new rule
- Loading branch information
Showing
10 changed files
with
62 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use std::collections::HashSet; | ||
|
||
use gtfs_structures::Trip; | ||
|
||
use crate::issues::Issue; | ||
use crate::{IssueType, Severity}; | ||
|
||
pub fn validate(gtfs: >fs_structures::Gtfs) -> Vec<Issue> { | ||
gtfs.trips | ||
.values() | ||
.filter_map(|trip| { | ||
let mut stops = HashSet::new(); | ||
for stop_time in &trip.stop_times { | ||
stops.insert(stop_time.stop.id.to_owned()); | ||
if stops.len() > 1 { | ||
break; | ||
} | ||
} | ||
if stops.len() < 2 { | ||
Some(mk_issue(trip)) | ||
} else { | ||
None | ||
} | ||
}) | ||
.collect() | ||
} | ||
|
||
fn mk_issue(trip: &Trip) -> Issue { | ||
Issue::new_with_obj(Severity::Error, IssueType::UnusableTrip, trip) | ||
} | ||
|
||
#[test] | ||
fn test() { | ||
let gtfs = gtfs_structures::Gtfs::new("test_data/unusable_trip").unwrap(); | ||
let issues = validate(>fs); | ||
|
||
assert_eq!(1, issues.len()); | ||
assert_eq!("AB1", issues[0].object_id); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
agency_id,agency_name,agency_url,agency_timezone | ||
DTA,Demo Transit Authority,http://google.com,America/Los_Angeles |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
route_id,agency_id,route_short_name,route_long_name,route_desc,route_type,route_url,route_color,route_text_color | ||
AB,DTA,,Airport - Bullfrog,,3,,, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
trip_id,arrival_time,departure_time,stop_id,stop_sequence,stop_headsign,pickup_type,drop_off_type,shape_dist_traveled | ||
AB1,8:00:00,8:00:00,BEATTY_AIRPORT,1,,,, | ||
AB1,10:00:00,10:00:00,BEATTY_AIRPORT,1,,,, | ||
AB2,10:00:00,10:00:00,BEATTY_AIRPORT,1,,,, | ||
AB2,12:00:00,12:00:00,CENTRAL_STATION,1,,,, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
stop_id,stop_name,stop_desc,stop_lat,stop_lon,zone_id,stop_url,location_type,parent_station | ||
BEATTY_AIRPORT,Nye County Airport (Demo),,36.868446,-116.784582,,,, | ||
CENTRAL_STATION,Central Station (Demo),,36.924526,-115.741512,,,, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
route_id,service_id,trip_id,trip_headsign,direction_id,block_id,shape_id | ||
AB,FULLW,AB1,to Bullfrog,0,1, | ||
AB,FULLW,AB2,to Bullfrog,0,1, |