@@ -2,8 +2,8 @@ fn main() {
22 /* Gtfs::new will try to guess if you provide a path, a local zip file or a remote zip file.
33 You can also use Gtfs::from_path, Gtfs::from_url
44 */
5- let gtfs = gtfs_structures:: GtfsReader :: default ( )
6- . read_stop_times ( false )
5+ let mut gtfs = gtfs_structures:: GtfsReader :: default ( )
6+ . read_stop_times ( true )
77 . read ( "fixtures/basic" )
88 . expect ( "impossible to read gtfs" ) ;
99 gtfs. print_stats ( ) ;
@@ -12,4 +12,30 @@ fn main() {
1212
1313 let route_1 = gtfs. routes . get ( "1" ) . expect ( "no route 1" ) ;
1414 println ! ( "{}: {:?}" , route_1. short_name, route_1) ;
15+
16+ // you can access a stop by a &str
17+ let _ = gtfs
18+ . get_stop_by_raw_id ( "stop1" )
19+ . expect ( "unable to find stop Stop Area" ) ;
20+
21+ let trip = gtfs. trips . get ( "trip1" ) . expect ( "no route 1" ) ;
22+ let stop_id: & gtfs_structures:: Id < gtfs_structures:: Stop > =
23+ & trip. stop_times . first ( ) . expect ( "no stoptimes" ) . stop ;
24+
25+ // or with a typed id if you have one
26+
27+ // if no stops have been removed from the gtfs, you can safely access the stops by it's id
28+ let s = & gtfs. stops [ stop_id] ;
29+ println ! ( "stop name: {}" , & s. name) ;
30+
31+ // if some removal have been done, you can also you those method to get an Option<Stop>
32+ let s = gtfs. get_stop ( stop_id) . expect ( "this stop should exists" ) ;
33+ println ! ( "stop description: {}" , & s. description) ;
34+
35+ // or you can access it via `stops.get`
36+ let s = gtfs. stops . get ( stop_id) . expect ( "this stop should exists" ) ;
37+ println ! ( "stop location type: {:?}" , & s. location_type) ;
38+
39+ let mut s = gtfs. stops . get_mut ( stop_id) . expect ( "this stop should exists" ) ;
40+ s. code = Some ( "code" . into ( ) ) ;
1541}
0 commit comments