Examples of TripEntry


Examples of org.onebusaway.transit_data_federation.services.transit_graph.TripEntry

    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());
View Full Code Here

Examples of org.onebusaway.transit_data_federation.services.transit_graph.TripEntry

  public double getDistanceAlongBlockForIndex(int index) {

    int tripIndex = tripIndices[index];

    BlockTripEntry blockTrip = trips.get(tripIndex);
    TripEntry trip = blockTrip.getTrip();

    List<StopTimeEntry> stopTimes = trip.getStopTimes();
    int stopTimeIndex = index - accumulatedStopTimeIndices[tripIndex];
    StopTimeEntry stopTime = stopTimes.get(stopTimeIndex);

    return blockTrip.getDistanceAlongBlock() + stopTime.getShapeDistTraveled();
  }
View Full Code Here

Examples of org.onebusaway.transit_data_federation.services.transit_graph.TripEntry

  private StopTimeEntry getStopTimeForIndex(int index) {
    int tripIndex = tripIndices[index];

    BlockTripEntry blockTrip = trips.get(tripIndex);
    TripEntry trip = blockTrip.getTrip();

    List<StopTimeEntry> stopTimes = trip.getStopTimes();
    int stopTimeIndex = index - accumulatedStopTimeIndices[tripIndex];
    StopTimeEntry stopTime = stopTimes.get(stopTimeIndex);
    return stopTime;
  }
View Full Code Here

Examples of org.onebusaway.transit_data_federation.services.transit_graph.TripEntry

      for (StopTimeInstance sti : stopTimesForRoute) {

        BlockStopTimeEntry bst = sti.getStopTime();
        BlockTripEntry blockTrip = sti.getTrip();
        BlockConfigurationEntry blockConfig = blockTrip.getBlockConfiguration();
        TripEntry trip = blockTrip.getTrip();

        AgencyAndId tripId = trip.getId();
        AgencyAndId serviceId = trip.getServiceId().getId();

        TripNarrative narrative = _narrativeService.getTripForId(tripId);

        StopTimeInstanceBean stiBean = new StopTimeInstanceBean();
        stiBean.setTripId(AgencyAndIdLibrary.convertToString(tripId));
        stiBean.setServiceDate(sti.getServiceDate());
        stiBean.setArrivalTime(sti.getArrivalTime());
        stiBean.setDepartureTime(sti.getDepartureTime());
        stiBean.setServiceId(AgencyAndIdLibrary.convertToString(serviceId));

        stiBean.setArrivalEnabled(bst.getBlockSequence() > 0);
        stiBean.setDepartureEnabled(bst.getBlockSequence() + 1 < blockConfig.getStopTimes().size());

        String directionId = trip.getDirectionId();
        if (directionId == null)
          directionId = "0";

        String tripHeadsign = narrative.getTripHeadsign();

        TripHeadsignStopTimeGroupKey groupKey = new TripHeadsignStopTimeGroupKey(
            tripHeadsign);
        ContinuesAsStopTimeGroupKey continuesAsGroupKey = getContinuesAsGroupKeyForStopTimeInstance(sti);

        StopTimeByDirectionEntry stopTimesForDirection = stopTimesByDirection.get(directionId);

        stopTimesForDirection.addEntry(stiBean, tripHeadsign, groupKey,
            continuesAsGroupKey);
      }

      List<StopTimeInstance> frequenciesForRoute = frequenciesByRouteCollectionId.get(routeId);

      for (StopTimeInstance sti : frequenciesForRoute) {

        BlockStopTimeEntry blockStopTime = sti.getStopTime();
        BlockTripEntry blockTrip = blockStopTime.getTrip();
        TripEntry trip = blockTrip.getTrip();
        BlockConfigurationEntry blockConfig = blockTrip.getBlockConfiguration();

        AgencyAndId tripId = trip.getId();
        AgencyAndId serviceId = trip.getServiceId().getId();

        TripNarrative narrative = _narrativeService.getTripForId(tripId);

        FrequencyInstanceBean bean = new FrequencyInstanceBean();
        bean.setTripId(AgencyAndIdLibrary.convertToString(tripId));
        bean.setServiceDate(sti.getServiceDate());
        bean.setStartTime(sti.getServiceDate()
            + sti.getFrequency().getStartTime() * 1000);
        bean.setEndTime(sti.getServiceDate() + sti.getFrequency().getEndTime()
            * 1000);
        bean.setHeadwaySecs(sti.getFrequency().getHeadwaySecs());
        bean.setServiceId(AgencyAndIdLibrary.convertToString(serviceId));
        bean.setArrivalEnabled(blockStopTime.getBlockSequence() > 0);
        bean.setDepartureEnabled(blockStopTime.getBlockSequence() + 1 < blockConfig.getStopTimes().size());

        String directionId = trip.getDirectionId();
        if (directionId == null)
          directionId = "0";

        StopTimeByDirectionEntry stopTimesForDirection = stopTimesByDirection.get(directionId);
        stopTimesForDirection.addEntry(bean, narrative.getTripHeadsign());
View Full Code Here

Examples of org.onebusaway.transit_data_federation.services.transit_graph.TripEntry

    }

    private double computeTotalBlockDistance() {
      double distance = 0;
      for (int i = 0; i < trips.size(); i++) {
        TripEntry trip = trips.get(i);
        distance += trip.getTotalTripDistance() + tripGapDistances[i];
      }
      return distance;
    }
View Full Code Here

Examples of org.onebusaway.transit_data_federation.services.transit_graph.TripEntry

      Date serviceDate = date.getAsDate(serviceIds.getTimeZone());

      for (BlockStopTimeEntry stopTime : index.getStopTimes()) {

        BlockTripEntry blockTrip = stopTime.getTrip();
        TripEntry trip = blockTrip.getTrip();
        AgencyAndId routeCollectionId = trip.getRouteCollection().getId();

        FrequencyEntry frequencyLabel = trip.getFrequencyLabel();
        InstanceState state = new InstanceState(serviceDate.getTime(),
            frequencyLabel);
        StopTimeInstance sti = new StopTimeInstance(stopTime, state);

        if (frequencyLabel == null) {
View Full Code Here

Examples of org.onebusaway.transit_data_federation.services.transit_graph.TripEntry

      for (TripEntry trip : trips)
        n += trip.getStopTimes().size();
      int[] tripIndices = new int[n];
      int index = 0;
      for (int tripIndex = 0; tripIndex < trips.size(); tripIndex++) {
        TripEntry trip = trips.get(tripIndex);
        for (int i = 0; i < trip.getStopTimes().size(); i++)
          tripIndices[index++] = tripIndex;
      }
      return tripIndices;
    }
View Full Code Here

Examples of org.onebusaway.transit_data_federation.services.transit_graph.TripEntry

      for (FrequencyBlockStopTimeEntry entry : index.getFrequencyStopTimes()) {

        BlockStopTimeEntry stopTime = entry.getStopTime();

        BlockTripEntry blockTrip = stopTime.getTrip();
        TripEntry trip = blockTrip.getTrip();
        AgencyAndId routeCollectionId = trip.getRouteCollection().getId();
        InstanceState state = new InstanceState(serviceDate.getTime(),
            entry.getFrequency());

        StopTimeInstance sti = new StopTimeInstance(stopTime, state);
View Full Code Here

Examples of org.onebusaway.transit_data_federation.services.transit_graph.TripEntry

    BlockTripEntry nextTrip = blockTrip.getNextTrip();
    if (nextTrip == null)
      return null;

    TripEntry prevTrip = blockTrip.getTrip();
    AgencyAndId prevLineId = prevTrip.getRouteCollection().getId();
    AgencyAndId nextLineId = nextTrip.getTrip().getRouteCollection().getId();
    if (prevLineId.equals(nextLineId))
      return null;

    List<BlockStopTimeEntry> stopTimes = blockTrip.getStopTimes();
View Full Code Here

Examples of org.onebusaway.transit_data_federation.services.transit_graph.TripEntry

      StopTimeEntry prevTripStopTime = null;
      double prevTripAvgVelocity = 0;

      for (short i = 0; i < trips.size(); i++) {

        TripEntry tripEntry = trips.get(i);
        List<StopTimeEntry> stopTimes = tripEntry.getStopTimes();

        /**
         * See if there is any slack time in the schedule in the transition
         * between the two trips. We take the distance between the last stop of
         * the previous trip and the first stop of the next trip, along with the
         * average travel velocity from the previous trip, and compute the
         * estimated travel time. Any time that's left over is slack.
         */
        if (prevTripStopTime != null) {
          StopTimeEntry nextStopTime = stopTimes.get(0);
          int slackTime = nextStopTime.getArrivalTime()
              - prevTripStopTime.getDepartureTime();
          double distance = (distanceAlongBlock - (prevTrip.getDistanceAlongBlock() + prevTripStopTime.getShapeDistTraveled()))
              + nextStopTime.getShapeDistTraveled();
          if (prevTripAvgVelocity > 0) {
            int timeToTravel = (int) (distance / prevTripAvgVelocity);
            slackTime -= Math.min(timeToTravel, slackTime);
          }

          accumulatedSlackTime += slackTime;
        }

        BlockTripEntryImpl blockTripEntry = new BlockTripEntryImpl();
        blockTripEntry.setTrip(tripEntry);
        blockTripEntry.setBlockConfiguration(blockConfiguration);
        blockTripEntry.setSequence(i);
        blockTripEntry.setAccumulatedStopTimeIndex(accumulatedStopTimeIndex);
        blockTripEntry.setAccumulatedSlackTime(accumulatedSlackTime);
        blockTripEntry.setDistanceAlongBlock(distanceAlongBlock);

        if (prevTrip != null) {
          prevTrip.setNextTrip(blockTripEntry);
          blockTripEntry.setPreviousTrip(prevTrip);
        }

        blockTrips.add(blockTripEntry);

        accumulatedStopTimeIndex += stopTimes.size();

        if (accumulatedSlackTime < 0)
          throw new IllegalStateException(
              "I didn't think this was possible, but the number of stop times in a particular block exceeded "
                  + Short.MAX_VALUE
                  + " causing a wrap-around in the accumulated stop time index: blockId="
                  + blockConfiguration.getBlock().getId());

        for (StopTimeEntry stopTime : stopTimes)
          accumulatedSlackTime += stopTime.getSlackTime();

        prevTripAvgVelocity = computeAverageTripTravelVelocity(stopTimes);

        distanceAlongBlock += tripEntry.getTotalTripDistance()
            + tripGapDistances[i];

        prevTrip = blockTripEntry;
        prevTripStopTime = stopTimes.get(stopTimes.size() - 1);

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.