Package org.onebusaway.transit_data.model

Examples of org.onebusaway.transit_data.model.ArrivalAndDepartureBean


    List<ArrivalAndDepartureBean> arrivalsAndDepartures = _service.getArrivalsAndDeparturesByStopId(
        stopB.getId(), query);

    assertEquals(2, arrivalsAndDepartures.size());

    ArrivalAndDepartureBean bean = arrivalsAndDepartures.get(0);
    assertEquals(1500, bean.getDistanceFromStop(), 0.0);
    assertEquals(lastUpdateTime, bean.getLastUpdateTime().longValue());
    assertEquals(1, bean.getNumberOfStopsAway());
    assertEquals(dateAsLong("2010-10-05 16:45"), bean.getPredictedArrivalTime());
    assertEquals(dateAsLong("2010-10-05 16:45"),
        bean.getPredictedDepartureTime());
    assertNull(bean.getRouteShortName());
    assertEquals(dateAsLong("2010-10-05 16:40"), bean.getScheduledArrivalTime());
    assertEquals(dateAsLong("2010-10-05 16:45"),
        bean.getScheduledDepartureTime());
    assertEquals(serviceDate, bean.getServiceDate());
    assertEquals("default", bean.getStatus());
    assertSame(stopBBean, bean.getStop());
    assertSame(tripABean, bean.getTrip());
    assertSame(tripStatusBeanA, bean.getTripStatus());
    assertEquals("Downtown", bean.getTripHeadsign());
    assertEquals("1_vehicle", bean.getVehicleId());

    bean = arrivalsAndDepartures.get(1);
    assertEquals(1600, bean.getDistanceFromStop(), 0.0);
    assertNull(bean.getLastUpdateTime());
    assertEquals(1, bean.getNumberOfStopsAway());
    assertEquals(0L, bean.getPredictedArrivalTime());
    assertEquals(0L, bean.getPredictedDepartureTime());
    assertEquals("XX", bean.getRouteShortName());
    assertEquals(dateAsLong("2010-10-05 16:50"), bean.getScheduledArrivalTime());
    assertEquals(dateAsLong("2010-10-05 16:55"),
        bean.getScheduledDepartureTime());
    assertEquals(serviceDate, bean.getServiceDate());
    assertEquals("default", bean.getStatus());
    assertSame(stopBBean, bean.getStop());
    assertSame(tripBBean, bean.getTrip());
    assertSame(tripStatusBeanB, bean.getTripStatus());
    assertNull(bean.getTripHeadsign());
    assertNull(bean.getVehicleId());
  }
View Full Code Here


      long to = frequency != null ? frequencyToTime : nonFrequencyToTime;

      if (!isArrivalAndDepartureInRange(instance, from, to))
        continue;

      ArrivalAndDepartureBean bean = getStopTimeInstanceAsBean(time, instance,
          stopBeanCache);
      applyBlockLocationToBean(instance, bean, time);
      applySituationsToBean(time, instance, bean);
      beans.add(bean);
    }
View Full Code Here

    ArrivalAndDepartureInstance instance = _arrivalAndDepartureService.getArrivalAndDepartureForStop(query);
    if (instance == null) {
      return null;
    }

    ArrivalAndDepartureBean bean = getStopTimeInstanceAsBean(time, instance,
        new HashMap<AgencyAndId, StopBean>());
    applyBlockLocationToBean(instance, bean, time);
    applySituationsToBean(time, instance, bean);

    if (!this.useScheduleDeviationHistory) {
      return bean;
    }
   
    int step = 120;

    ScheduleDeviationHistogram histo = _realTimeHistoryService.getScheduleDeviationHistogramForArrivalAndDepartureInstance(
        instance, step);

    if (histo != null) {

      int[] sds = histo.getScheduleDeviations();

      double[] values = new double[sds.length];
      String[] labels = new String[sds.length];
      for (int i = 0; i < sds.length; i++) {
        int sd = sds[i];
        values[i] = sd;
        labels[i] = Integer.toString(sd / 60);
      }

      HistogramBean hb = new HistogramBean();
      hb.setValues(values);
      hb.setCounts(histo.getCounts());
      hb.setLabels(labels);
      bean.setScheduleDeviationHistogram(hb);
    }

    return bean;
  }
View Full Code Here

  private ArrivalAndDepartureBean getStopTimeInstanceAsBean(long time,
      ArrivalAndDepartureInstance instance,
      Map<AgencyAndId, StopBean> stopBeanCache) {

    ArrivalAndDepartureBean pab = new ArrivalAndDepartureBean();

    pab.setServiceDate(instance.getServiceDate());

    BlockStopTimeEntry blockStopTime = instance.getBlockStopTime();
    BlockTripEntry blockTrip = blockStopTime.getTrip();
    BlockConfigurationEntry blockConfig = blockTrip.getBlockConfiguration();
    StopTimeEntry stopTime = blockStopTime.getStopTime();
    StopEntry stop = stopTime.getStop();
    TripEntry trip = stopTime.getTrip();

    TripBean tripBean = _tripBeanService.getTripForId(trip.getId());
    pab.setTrip(tripBean);
    pab.setBlockTripSequence(blockTrip.getSequence());

    pab.setArrivalEnabled(blockStopTime.getBlockSequence() > 0);
    pab.setDepartureEnabled(blockStopTime.getBlockSequence() + 1 < blockConfig.getStopTimes().size());

    StopTimeNarrative stopTimeNarrative = _narrativeService.getStopTimeForEntry(stopTime);
    pab.setRouteShortName(stopTimeNarrative.getRouteShortName());
    pab.setTripHeadsign(stopTimeNarrative.getStopHeadsign());

    StopBean stopBean = stopBeanCache.get(stop.getId());

    if (stopBean == null) {
      stopBean = _stopBeanService.getStopForId(stop.getId());
      stopBeanCache.put(stop.getId(), stopBean);
    }

    pab.setStop(stopBean);
    pab.setStopSequence(stopTime.getSequence());

    pab.setStatus("default");

    pab.setScheduledArrivalTime(instance.getScheduledArrivalTime());
    pab.setScheduledDepartureTime(instance.getScheduledDepartureTime());

    FrequencyEntry frequency = instance.getFrequencyLabel();
    pab.setFrequency(null);
    if (frequency != null) {
      FrequencyBean fb = FrequencyBeanLibrary.getBeanForFrequency(
          instance.getServiceDate(), frequency);
      pab.setFrequency(fb);
    }

    return pab;
  }
View Full Code Here

    StopsWithArrivalsAndDeparturesBean result = _model.getResult();
    Iterator<ArrivalAndDepartureBean> it = result.getArrivalsAndDepartures().iterator();

    while (it.hasNext()) {
      ArrivalAndDepartureBean bean = it.next();
      TripBean trip = bean.getTrip();
      RouteBean route = trip.getRoute();
      String routeName = RoutePresenter.getNameForRoute(route);
      if (!routes.contains(routeName))
        it.remove();
    }
View Full Code Here

      return setValidationErrorsResponse();

    if (_query.getTime() == 0)
      _query.setTime(System.currentTimeMillis());

    ArrivalAndDepartureBean result = _service.getArrivalAndDepartureForStop(_query);

    if (result == null)
      return setResourceNotFoundResponse();

    if (isVersion(V2)) {
View Full Code Here

        break;
      }
      case 1: {

        List<ArrivalAndDepartureBean> arrivalsAndDepartures = _data.getArrivalsAndDepartures();
        ArrivalAndDepartureBean arrival = arrivalsAndDepartures.get(rowIndex);

        Widget view = getCustomViewForArrivalAndDeparture(arrival);
        row.setCustomView(view);

        break;
View Full Code Here

TOP

Related Classes of org.onebusaway.transit_data.model.ArrivalAndDepartureBean

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.