modules/search/search.js
function _getTransferStops(db, origin, destination, stop, trip, callback) {

  // List of Transfer Stops
  let rtn = [];

  // Get Next Stops from this Stop
  LineGraphTable.getNextStops(db, origin.id, destination.id, stop.id, function(err, nextStops) {

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

    // Get Remaining Stops on Trip
    let remainingStops = [];
    let stopFound = false;
    for ( let i = 0; i < trip.stopTimes.length; i++ ) {
      if ( !stopFound && trip.stopTimes[i].stop.id === stop.id ) {
        stopFound = true;
      }
      else if ( stopFound ) {
        remainingStops.push(trip.stopTimes[i].stop.id);
      }
    }

    // Get Next Stops that are remaining on this Trip
    for ( let i = 0; i < nextStops.length; i++ ) {
      if ( remainingStops.indexOf(nextStops[i]) > -1 ) {
        rtn.push(
          trip.getStopTime(nextStops[i]).stop
        );
      }
    }

    // Return only the top 3 transfer Stops
    if ( rtn.length > 3 ) {
      rtn = [rtn[0], rtn[1], rtn[2]];
    }

    return callback(null, rtn);

  });

}
function _getTransferStops(db, origin, destination, stop, trip, callback) {

  // List of Transfer Stops
  let rtn = [];

  // Get Next Stops from this Stop
  LineGraphTable.getNextStops(db, origin.id, destination.id, stop.id, function(err, nextStops) {

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

    // Get Remaining Stops on Trip
    let remainingStops = [];
    let stopFound = false;
    for ( let i = 0; i < trip.stopTimes.length; i++ ) {
      if ( !stopFound && trip.stopTimes[i].stop.id === stop.id ) {
        stopFound = true;
      }
      else if ( stopFound ) {
        remainingStops.push(trip.stopTimes[i].stop.id);
      }
    }

    // Get Next Stops that are remaining on this Trip
    for ( let i = 0; i < nextStops.length; i++ ) {
      if ( remainingStops.indexOf(nextStops[i]) > -1 ) {
        rtn.push(
          trip.getStopTime(nextStops[i]).stop
        );
      }
    }

    // Return only the top 3 transfer Stops
    if ( rtn.length > 3 ) {
      rtn = [rtn[0], rtn[1], rtn[2]];
    }

    return callback(null, rtn);

  });

}
function _getTransferStops ( db , origin , destination , stop , trip , callback ) { // List of Transfer Stops let rtn = [ ] ; // Get Next Stops from this Stop LineGraphTable . getNextStops ( db , origin . id , destination . id , stop . id , function ( err , nextStops ) { // Database Query Error if ( err ) { return callback ( err ) ; } // Get Remaining Stops on Trip let remainingStops = [ ] ; let stopFound = false ; for ( let i = 0 ; i < trip . stopTimes . length ; i ++ ) { if ( ! stopFound && trip . stopTimes [ i ] . stop . id === stop . id ) { stopFound = true ; } else if ( stopFound ) { remainingStops . push ( trip . stopTimes [ i ] . stop . id ) ; } } // Get Next Stops that are remaining on this Trip for ( let i = 0 ; i < nextStops . length ; i ++ ) { if ( remainingStops . indexOf ( nextStops [ i ] ) > - 1 ) { rtn . push ( trip . getStopTime ( nextStops [ i ] ) . stop ) ; } } // Return only the top 3 transfer Stops if ( rtn . length > 3 ) { rtn = [ rtn [ 0 ] , rtn [ 1 ] , rtn [ 2 ] ] ; } return callback ( null , rtn ) ; } ) ; }
Get a list of Stop IDs, sorted by transfer weight, that can be
used as a Transfer Stop for this Trip
@param {RightTrackDB} db The Right Track DB to query
@param {Stop} origin Origin Stop
@param {Stop} destination Destination Stop
@param {Stop} stop Reference Stop
@param {Trip} trip Trip to transfer from
@param {function} callback Callback function(err, stops)
@private
Get a list of Stop IDs sorted by transfer weight that can be used as a Transfer Stop for this Trip