modules/search/search.js
function _getTripsFromStop(db, origin, destination, stop, tripSearchDates, excludeTrips, callback) {

  // Get all possible following stops
  LineGraphTable.getNextStops(db, origin.id, destination.id, stop.id, function(err, nextStops) {

    // Database Query Error
    if ( err ) {
      return callback(err);
    }

    // Get Trips from Stop
    query.getTripsFromStop(db, stop, tripSearchDates, nextStops, function(err, trips) {

      // Database Query Error
      if ( err ) {
        return callback(err);
      }

      // List of Direct and Indirect Trips
      let direct = [];
      let indirect = [];

      // Sort Trips
      for ( let i = 0; i < trips.length; i++ ) {
        if ( excludeTrips.indexOf(trips[i].id) === -1 ) {
          if ( _tripGoesTo(trips[i], stop, destination) ) {
            direct.push(trips[i]);
          }
          else {
            indirect.push(trips[i]);
          }
        }
      }

      // Return the Trips
      return callback(null, direct, indirect);

    });

  });

}
function _getTripsFromStop(db, origin, destination, stop, tripSearchDates, excludeTrips, callback) {

  // Get all possible following stops
  LineGraphTable.getNextStops(db, origin.id, destination.id, stop.id, function(err, nextStops) {

    // Database Query Error
    if ( err ) {
      return callback(err);
    }

    // Get Trips from Stop
    query.getTripsFromStop(db, stop, tripSearchDates, nextStops, function(err, trips) {

      // Database Query Error
      if ( err ) {
        return callback(err);
      }

      // List of Direct and Indirect Trips
      let direct = [];
      let indirect = [];

      // Sort Trips
      for ( let i = 0; i < trips.length; i++ ) {
        if ( excludeTrips.indexOf(trips[i].id) === -1 ) {
          if ( _tripGoesTo(trips[i], stop, destination) ) {
            direct.push(trips[i]);
          }
          else {
            indirect.push(trips[i]);
          }
        }
      }

      // Return the Trips
      return callback(null, direct, indirect);

    });

  });

}
function _getTripsFromStop ( db , origin , destination , stop , tripSearchDates , excludeTrips , callback ) { // Get all possible following stops LineGraphTable . getNextStops ( db , origin . id , destination . id , stop . id , function ( err , nextStops ) { // Database Query Error if ( err ) { return callback ( err ) ; } // Get Trips from Stop query . getTripsFromStop ( db , stop , tripSearchDates , nextStops , function ( err , trips ) { // Database Query Error if ( err ) { return callback ( err ) ; } // List of Direct and Indirect Trips let direct = [ ] ; let indirect = [ ] ; // Sort Trips for ( let i = 0 ; i < trips . length ; i ++ ) { if ( excludeTrips . indexOf ( trips [ i ] . id ) === - 1 ) { if ( _tripGoesTo ( trips [ i ] , stop , destination ) ) { direct . push ( trips [ i ] ) ; } else { indirect . push ( trips [ i ] ) ; } } } // Return the Trips return callback ( null , direct , indirect ) ; } ) ; } ) ; }
Get a List of Trips from the reference Stop that operate during the
TripSearchDates and along the Line Graph paths between the origin
and destination Stops
@param {RightTrackDB} db The Right Track DB to query
@param {Stop} origin Trip Origin Stop
@param {Stop} destination Trip Destination Stop
@param {Stop} stop Reference Stop
@param {TripSearchDate[]} tripSearchDates Trip Search Dates
@param {String[]} excludeTrips List of Trip IDs to exclude
@param {function} callback Callback function(err, direct, indirect)
@private
Get a List of Trips from the reference Stop that operate during the TripSearchDates and along the Line Graph paths between the origin and destination Stops