fn search_stops(&mut self, from: &str, to: &str) {
        let origin = strip_name(from);
        let destination = strip_name(to);
        let mut n = 0;
        for result in self.gtfs.stops() {
            n += 1;
            if let Ok(entry) = result {
                let id = entry.stop_id.clone();
                let name = entry.stop_name.clone();
                let stripped_name = strip_name(&entry.stop_name);

                if stripped_name.contains(&origin) {
                    self.stop_ids.insert(id.clone(), Step::Departure);
                    self.origins.push(name.clone());
                    self.stops.insert(id.clone(), entry);
                } else if stripped_name.contains(&destination) {
                    self.stop_ids.insert(id.clone(), Step::Arrival);
                    self.destinations.push(name.clone());
                    self.stops.insert(id.clone(), entry);
                }
            }
        }
        if self.debug {
            self.origins.sort();
            self.origins.dedup();
            self.destinations.sort();
            self.destinations.dedup();
            println!("{}: origins: {}", "Debug".cyan(), self.origins.join(", "));
            println!("{}: destinations: {}", "Debug".cyan(), self.destinations.join(", "));
            println!("{}: loaded {} stops ({} retained)", "Debug".cyan(), n, self.stop_ids.len());
        }
    }
// Search stop candidates for origin and destination
Search stop candidates for origin and destination
Search stop candidates for origin and destination
fn search_stops(&mut self, from: &str, to: &str) {
        let origin = strip_name(from);
        let destination = strip_name(to);
        let mut n = 0;
        for result in self.gtfs.stops() {
            n += 1;
            if let Ok(entry) = result {
                let id = entry.stop_id.clone();
                let name = entry.stop_name.clone();
                let stripped_name = strip_name(&entry.stop_name);
                if stripped_name.contains(&origin) {
                    self.stop_ids.insert(id.clone(), Step::Departure);
                    self.origins.push(name.clone());
                    self.stops.insert(id.clone(), entry);
                } else if stripped_name.contains(&destination) {
                    self.stop_ids.insert(id.clone(), Step::Arrival);
                    self.destinations.push(name.clone());
                    self.stops.insert(id.clone(), entry);
                }
            }
        }
        if self.debug {
            self.origins.sort();
            self.origins.dedup();
            self.destinations.sort();
            self.destinations.dedup();
            println!("{}: origins: {}", "Debug".cyan(), self.origins.join(", "));
            println!("{}: destinations: {}", "Debug".cyan(), self.destinations.join(", "));
            println!("{}: loaded {} stops ({} retained)", "Debug".cyan(), n, self.stop_ids.len());
        }
    }
fn search_stops ( & mut self , from : & str , to : & str ) { let origin = strip_name ( from ) ; let destination = strip_name ( to ) ; let mut n = 0 ; for result in self . gtfs . stops ( ) { n += 1 ; if let Ok ( entry ) = result { let id = entry . stop_id . clone ( ) ; let name = entry . stop_name . clone ( ) ; let stripped_name = strip_name ( & entry . stop_name ) ; if stripped_name . contains ( & origin ) { self . stop_ids . insert ( id . clone ( ) , Step :: Departure ) ; self . origins . push ( name . clone ( ) ) ; self . stops . insert ( id . clone ( ) , entry ) ; } else if stripped_name . contains ( & destination ) { self . stop_ids . insert ( id . clone ( ) , Step :: Arrival ) ; self . destinations . push ( name . clone ( ) ) ; self . stops . insert ( id . clone ( ) , entry ) ; } } } if self . debug { self . origins . sort ( ) ; self . origins . dedup ( ) ; self . destinations . sort ( ) ; self . destinations . dedup ( ) ; println ! ( " " " " cyan ( ) self origins join ( " " ) ) ; println ! ( " " " " cyan ( ) self destinations join ( " " ) ) ; println ! ( " " " " cyan ( ) n self stop_ids len ( ) ) ; } }
Search stop candidates for origin and destination
Search stop candidates for origin and destination
&mut self
from
&str
to
&str
&mut self
from
&str
to
&str