Package org.onebusaway.transit_data_federation.services.transit_graph

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


    for (BlockEntry block : _transitGraphDao.getAllBlocks()) {
      for (BlockConfigurationEntry blockConfig : block.getConfigurations()) {

        List<BlockStopTimeEntry> stopTimes = blockConfig.getStopTimes();
        BlockStopTimeEntry prevBlockStopTime = null;

        for (BlockStopTimeEntry blockStopTime : stopTimes) {

          if (prevBlockStopTime != null) {

            StopTimeEntry from = prevBlockStopTime.getStopTime();
            StopTimeEntry to = blockStopTime.getStopTime();
            int time = to.getArrivalTime() - from.getDepartureTime();

            StopEntry stopFrom = from.getStop();
            StopEntry stopTo = to.getStop();
View Full Code Here


  public double distance(Vertex v) {

    // We can do a quick calc if the vertices are along the same block
    if (v instanceof AbstractBlockVertex) {
      AbstractBlockVertex bsv = (AbstractBlockVertex) v;
      BlockStopTimeEntry bst1 = _instance.getBlockStopTime();
      BlockStopTimeEntry bst2 = bsv._instance.getBlockStopTime();
      if (bst1.getTrip().getBlockConfiguration() == bst2.getTrip().getBlockConfiguration())
        return Math.abs(bst1.getDistanceAlongBlock()
            - bst2.getDistanceAlongBlock());
    }

    return super.distance(v);
  }
View Full Code Here

      List<StopTimeInstance> stopTimesForRoute = stopTimesByRouteCollectionId.get(routeId);

      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";

View Full Code Here

  @Override
  public String toString() {
    List<BlockSequence> sequences = _index.getSequences();
    BlockSequence sequence = sequences.get(0);
    List<BlockStopTimeEntry> stopTimes = sequence.getStopTimes();
    BlockStopTimeEntry bst = stopTimes.get(_offset);
    return bst.toString();
  }
View Full Code Here

   ****/

  private ServiceInterval computeServiceInterval(BlockSequenceIndex index,
      int stopIndex) {
    List<BlockSequence> sequences = _index.getSequences();
    BlockStopTimeEntry fromBst = sequences.get(0).getStopTimes().get(stopIndex);
    BlockStopTimeEntry toBst = sequences.get(sequences.size() - 1).getStopTimes().get(
        stopIndex);

    StopTimeEntry fromSt = fromBst.getStopTime();
    StopTimeEntry toSt = toBst.getStopTime();

    return new ServiceInterval(fromSt.getArrivalTime(),
        fromSt.getDepartureTime(), toSt.getArrivalTime(),
        toSt.getDepartureTime());
  }
View Full Code Here

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

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

      BlockTripEntry nextBlockTrip) {

    List<BlockStopTimeEntry> prevStopTimes = prevBlockTrip.getStopTimes();
    List<BlockStopTimeEntry> nextStopTimes = nextBlockTrip.getStopTimes();

    BlockStopTimeEntry from = prevStopTimes.get(prevStopTimes.size() - 1);
    BlockStopTimeEntry to = nextStopTimes.get(0);

    int slack = to.getAccumulatedSlackTime()
        - (from.getAccumulatedSlackTime() + from.getStopTime().getSlackTime());

    int schedTime = to.getStopTime().getArrivalTime()
        - from.getStopTime().getDepartureTime();

    /**
     * If the slack time is too much, the trips are not continuous
     */
 
View Full Code Here

    return true;
  }

  private double computeDirectionOfTravel(List<BlockStopTimeEntry> bsts) {
    BlockStopTimeEntry fromBst = bsts.get(0);
    BlockStopTimeEntry toBst = bsts.get(bsts.size() - 1);
    StopEntry fromStop = fromBst.getStopTime().getStop();
    StopEntry toStop = toBst.getStopTime().getStop();
    return SphericalGeometryLibrary.getOrientation(fromStop.getStopLat(),
        fromStop.getStopLon(), toStop.getStopLat(), toStop.getStopLon());
  }
View Full Code Here

    ScheduledBlockLocation to = inOrder ? scheduledBlockLocationB
        : scheduledBlockLocationA;

    int delta = to.getScheduledTime() - from.getScheduledTime();

    BlockStopTimeEntry fromStop = from.getNextStop();
    BlockStopTimeEntry toStop = to.getNextStop();

    int slack = toStop.getAccumulatedSlackTime()
        - fromStop.getAccumulatedSlackTime();

    int slackFrom = computeSlackToNextStop(from);
    slack += slackFrom;
    int slackTo = computeSlackToNextStop(to);
View Full Code Here

  }

  public static int computeSlackToNextStop(
      ScheduledBlockLocation scheduledBlockLocation) {

    BlockStopTimeEntry nextStop = scheduledBlockLocation.getNextStop();
    StopTimeEntry stopTime = nextStop.getStopTime();
    int t = scheduledBlockLocation.getScheduledTime();

    /**
     * If we are actually at the next stop already, we return a negative value:
     * the amount of slack time already consumed.
     */
    if (stopTime.getArrivalTime() <= t && t <= stopTime.getDepartureTime())
      return stopTime.getArrivalTime() - t;

    int sequence = nextStop.getBlockSequence();

    /**
     * Are we before the first stop in the block? Are we already at the stop or
     * on our way there? Not sure, for now, let's assume there is no slack to be
     * had
     */
    if (sequence == 0)
      return 0;

    BlockConfigurationEntry blockConfig = nextStop.getTrip().getBlockConfiguration();
    BlockStopTimeEntry previousStop = blockConfig.getStopTimes().get(
        sequence - 1);

    int slack = nextStop.getAccumulatedSlackTime()
        - previousStop.getAccumulatedSlackTime();
    slack -= previousStop.getStopTime().getSlackTime();

    int timeToNextStop = stopTime.getArrivalTime() - t;

    if (timeToNextStop > slack)
      return slack;
View Full Code Here

TOP

Related Classes of org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry

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.