/// Performs a routing request from source to target.
Performs a routing request from source to target.
Performs a routing request from source to target .
pub fn route(&self, source: i64, target: i64) -> (Vec<Vec<f64>>, f32) {
        let source_id = self.get_id_from_osm(source);
        let target_id = self.get_id_from_osm(target);
        match self.djikstra(source_id, target_id) {
            Some((pred, dist)) => {
                let max_length = self.edges.len();
                println!(" ˪— Backtracking from {}, having {} edges. Total cost: {}.",
                         target_id, max_length, dist[target_id]);
                let mut trace = Vec::new();
                let mut current_node = target_id;
                trace.push(self.get_loc_from_id(current_node));
                let mut count = 0;
                while current_node != source_id {
                    current_node = pred[current_node];
                    trace.push(self.get_loc_from_id(current_node));
                    count = count + 1;
                    // Make sure this doesn't run forever.
                    if count > max_length {
                        current_node = source_id;
                    }
                }
                (trace, dist[target_id])
            },
            None => (Vec::new(), 0 as f32)
        }
    }
pub fn route ( & self , source : i64 , target : i64 ) -> ( Vec < Vec < f64 > > , f32 ) { let source_id = self . get_id_from_osm ( source ) ; let target_id = self . get_id_from_osm ( target ) ; match self . djikstra ( source_id , target_id ) { Some ( ( pred , dist ) ) => { let max_length = self . edges . len ( ) ; println ! ( " target_id max_length dist [ target_id ] ) ; let mut trace = Vec :: new ( ) ; let mut current_node = target_id ; trace . push ( self . get_loc_from_id ( current_node ) ) ; let mut count = 0 ; while current_node != source_id { current_node = pred [ current_node ] ; trace . push ( self . get_loc_from_id ( current_node ) ) ; count = count + 1 ; // Make sure this doesn't run forever. if count > max_length { current_node = source_id ; } } ( trace , dist [ target_id ] ) } , None => ( Vec :: new ( ) , 0 as f32 ) } }
Performs a routing request from source to target.
Performs a routing request from source to target .
&self
source
i64
target
i64