modules/query/StopsTable.js
function getStopByStatusId(db, statusId, callback) {

  // Make sure statusId is not -1
  if ( statusId === "-1" ) {
    return callback(
      new Error('Stop does not have a valid Status ID')
    );
  }

  // Check cache for stop
  let cacheKey = db.id + "-" + statusId;
  let cache = cache_stopByStatusId.get(cacheKey);
  if ( cache !== null ) {
    return callback(null, cache);
  }


  // Build select statement
  let select = "SELECT gtfs_stops.stop_id, stop_name, stop_desc, stop_lat, stop_lon, stop_url, " +
    "gtfs_stops.zone_id AS gtfs_zone_id, stop_code, wheelchair_boarding, location_type, parent_station, stop_timezone, " +
    "rt_stops_extra.status_id, display_name, transfer_weight, rt_stops_extra.zone_id AS rt_zone_id " +
    "FROM gtfs_stops, rt_stops_extra " +
    "WHERE gtfs_stops.stop_id=rt_stops_extra.stop_id AND " +
    "rt_stops_extra.status_id='" + statusId + "';";

  // Query the database
  db.get(select, function(err, result) {

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

    // No Stop found...
    if ( result === undefined ) {
      return callback(null, undefined);
    }

    // Use rt display_name if provided
    let final_name = result.stop_name;
    if ( result.display_name !== undefined && result.display_name !== "" ) {
      final_name = result.display_name;
    }

    // Get zone_id from rt_stops_extra if not defined in gtfs_stops
    let zone_id = result.gtfs_zone_id;
    if ( zone_id === null || zone_id === undefined ) {
      zone_id = result.rt_zone_id;
    }

    // build the Stop
    let stop = new Stop(
      result.stop_id,
      final_name,
      result.stop_lat,
      result.stop_lon,
      {
        code: result.stop_code,
        description: result.stop_desc,
        zoneId: zone_id,
        url: result.stop_url,
        locationType: result.location_type,
        parentStation: result.parent_station,
        timezone: result.stop_timezone,
        wheelchairBoarding: result.wheelchair_boarding,
        statusId: result.status_id,
        transferWeight: result.transfer_weight
      }
    );

    // Add Stop to cache
    cache_stopByStatusId.put(cacheKey, stop);

    // return the Stop in the callback
    return callback(null, stop);

  });

}
function getStopByStatusId(db, statusId, callback) {

  // Make sure statusId is not -1
  if ( statusId === "-1" ) {
    return callback(
      new Error('Stop does not have a valid Status ID')
    );
  }

  // Check cache for stop
  let cacheKey = db.id + "-" + statusId;
  let cache = cache_stopByStatusId.get(cacheKey);
  if ( cache !== null ) {
    return callback(null, cache);
  }


  // Build select statement
  let select = "SELECT gtfs_stops.stop_id, stop_name, stop_desc, stop_lat, stop_lon, stop_url, " +
    "gtfs_stops.zone_id AS gtfs_zone_id, stop_code, wheelchair_boarding, location_type, parent_station, stop_timezone, " +
    "rt_stops_extra.status_id, display_name, transfer_weight, rt_stops_extra.zone_id AS rt_zone_id " +
    "FROM gtfs_stops, rt_stops_extra " +
    "WHERE gtfs_stops.stop_id=rt_stops_extra.stop_id AND " +
    "rt_stops_extra.status_id='" + statusId + "';";

  // Query the database
  db.get(select, function(err, result) {

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

    // No Stop found...
    if ( result === undefined ) {
      return callback(null, undefined);
    }

    // Use rt display_name if provided
    let final_name = result.stop_name;
    if ( result.display_name !== undefined && result.display_name !== "" ) {
      final_name = result.display_name;
    }

    // Get zone_id from rt_stops_extra if not defined in gtfs_stops
    let zone_id = result.gtfs_zone_id;
    if ( zone_id === null || zone_id === undefined ) {
      zone_id = result.rt_zone_id;
    }

    // build the Stop
    let stop = new Stop(
      result.stop_id,
      final_name,
      result.stop_lat,
      result.stop_lon,
      {
        code: result.stop_code,
        description: result.stop_desc,
        zoneId: zone_id,
        url: result.stop_url,
        locationType: result.location_type,
        parentStation: result.parent_station,
        timezone: result.stop_timezone,
        wheelchairBoarding: result.wheelchair_boarding,
        statusId: result.status_id,
        transferWeight: result.transfer_weight
      }
    );

    // Add Stop to cache
    cache_stopByStatusId.put(cacheKey, stop);

    // return the Stop in the callback
    return callback(null, stop);

  });

}
function getStopByStatusId ( db , statusId , callback ) { // Make sure statusId is not -1 if ( statusId === "-1" ) { return callback ( new Error ( 'Stop does not have a valid Status ID' ) ) ; } // Check cache for stop let cacheKey = db . id + "-" + statusId ; let cache = cache_stopByStatusId . get ( cacheKey ) ; if ( cache !== null ) { return callback ( null , cache ) ; } // Build select statement let select = "SELECT gtfs_stops.stop_id, stop_name, stop_desc, stop_lat, stop_lon, stop_url, " + "gtfs_stops.zone_id AS gtfs_zone_id, stop_code, wheelchair_boarding, location_type, parent_station, stop_timezone, " + "rt_stops_extra.status_id, display_name, transfer_weight, rt_stops_extra.zone_id AS rt_zone_id " + "FROM gtfs_stops, rt_stops_extra " + "WHERE gtfs_stops.stop_id=rt_stops_extra.stop_id AND " + "rt_stops_extra.status_id='" + statusId + "';" ; // Query the database db . get ( select , function ( err , result ) { // Database Error if ( err ) { return callback ( err ) ; } // No Stop found... if ( result === undefined ) { return callback ( null , undefined ) ; } // Use rt display_name if provided let final_name = result . stop_name ; if ( result . display_name !== undefined && result . display_name !== "" ) { final_name = result . display_name ; } // Get zone_id from rt_stops_extra if not defined in gtfs_stops let zone_id = result . gtfs_zone_id ; if ( zone_id === null || zone_id === undefined ) { zone_id = result . rt_zone_id ; } // build the Stop let stop = new Stop ( result . stop_id , final_name , result . stop_lat , result . stop_lon , { code : result . stop_code , description : result . stop_desc , zoneId : zone_id , url : result . stop_url , locationType : result . location_type , parentStation : result . parent_station , timezone : result . stop_timezone , wheelchairBoarding : result . wheelchair_boarding , statusId : result . status_id , transferWeight : result . transfer_weight } ) ; // Add Stop to cache cache_stopByStatusId . put ( cacheKey , stop ) ; // return the Stop in the callback return callback ( null , stop ) ; } ) ; }
Get the Stop specified by status id from the passed database

@param {RightTrackDB} db The Right Track Database to query
@param {string} statusId the status id of the Stop
@param {function} callback Callback function
@param {Error} callback.error Database Query Error
@param {Stop} [callback.stop] The selected Stop
Get the Stop specified by status id from the passed database