Ejemplo n.º 1
0
  @Override
  // returns list of buses associated with input stop
  public ArrayList<Bus> getBusesByStop(Context context, Stop stop) throws TrackerException {

    // query for all buses with a particular stop string in ROUTE table
    LocalDatabaseConnector db = new LocalDatabaseConnector(context);

    // from Stop to BaseStop
    BaseStop baseStop =
        new BaseStop(
            stop.getName(),
            stop.getStreet1(),
            stop.getStreet2(),
            stop.getLatitude(),
            stop.getLongitude());

    // make request
    ArrayList<BaseBus> baseBusList = db.getBusesForStop(baseStop.getName());

    // from BaseBus to Bus
    ArrayList<Bus> busList = new ArrayList<Bus>();
    for (BaseBus baseBus : baseBusList) busList.add(new Bus(baseBus));

    db = null;
    return busList;
  }