Package org.onebusaway.transit_data_federation.services.transit_graph

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


        _log.warn("no trip found with id=" + trip.getTripId());
      }
     
      return null;
    }
    BlockEntry block = tripEntry.getBlock();
    BlockDescriptor blockDescriptor = new BlockDescriptor();
    blockDescriptor.setBlockEntry(block);
    if (trip.hasStartDate())
      blockDescriptor.setStartDate(trip.getStartDate());
    if (trip.hasStartTime())
View Full Code Here


  }

  private void applyTripUpdatesToRecord(MonitoredResult result, BlockDescriptor blockDescriptor,
      List<TripUpdate> tripUpdates, VehicleLocationRecord record) {

    BlockEntry block = blockDescriptor.getBlockEntry();
    long t = currentTime();
    long timeFrom = t - 30 * 60 * 1000;
    long timeTo = t + 30 * 60 * 1000;

    List<BlockInstance> instances = _blockCalendarService.getActiveBlocks(
        block.getId(), timeFrom, timeTo);
    if (instances.isEmpty()) {
      instances = _blockCalendarService.getClosestActiveBlocks(block.getId(), t);
    }
    if (instances.isEmpty()) {
      if (result != null) {
        result.addUnmatchedBlockId(block.getId());
      }
      _log.warn("could not find any active schedules instance for the specified block="
          + block.getId() + " tripUpdates=" + tripUpdates);
      return;
    }

    /**
     * TODO: Eventually, use startDate and startTime to distinguish between
View Full Code Here

    if (blockRef == null || blockRef.getValue() == null)
      return null;

    for (String agencyId : endpointDetails.getDefaultAgencyIds()) {
      AgencyAndId blockId = new AgencyAndId(agencyId, blockRef.getValue());
      BlockEntry blockEntry = _transitGraphDao.getBlockEntryForId(blockId);
      if (blockEntry != null)
        return blockEntry;
    }

    /**
 
View Full Code Here

        throw new IllegalArgumentException(
            "at least one of blockId or tripId must be specified for VehicleLocationRecord");
      TripEntry tripEntry = _transitGraphDao.getTripEntryForId(tripId);
      if (tripEntry == null)
        throw new IllegalArgumentException("trip not found with id=" + tripId);
      BlockEntry block = tripEntry.getBlock();
      blockId = block.getId();
    }

    if (record.getServiceDate() == 0)
      throw new IllegalArgumentException("you must specify a serviceDate");
View Full Code Here

  @Override
  public int compare(BlockInstance o1, BlockInstance o2) {

    BlockConfigurationEntry bc1 = o1.getBlock();
    BlockConfigurationEntry bc2 = o2.getBlock();
    BlockEntry b1 = bc1.getBlock();
    BlockEntry b2 = bc2.getBlock();

    AgencyAndId bId1 = b1.getId();
    AgencyAndId bId2 = b2.getId();

    int rc = bId1.compareTo(bId2);

    if (rc != 0)
      return rc;
View Full Code Here

  }

  @Cacheable
  public BlockBean getBlockForId(AgencyAndId blockId) {

    BlockEntry blockEntry = _graph.getBlockEntryForId(blockId);

    if (blockEntry == null)
      return null;

    BlockBean bean = new BlockBean();

    bean.setId(AgencyAndIdLibrary.convertToString(blockEntry.getId()));

    List<BlockConfigurationBean> configBeans = new ArrayList<BlockConfigurationBean>();
    for (BlockConfigurationEntry blockConfiguration : blockEntry.getConfigurations()) {
      BlockConfigurationBean configBean = getBlockConfigurationAsBean(blockConfiguration);
      configBeans.add(configBean);
    }
    bean.setConfigurations(configBeans);
View Full Code Here

  }

  @Test
  public void testGetNextServiceDatesForDepartureInterval() {

    BlockEntry blockA = block("blockA");
    blockConfiguration(blockA, serviceIds(lsids("sA"), lsids()));

    List<BlockEntry> blocks = Arrays.asList(blockA);

    Mockito.when(_transitGraphDao.getAllBlocks()).thenReturn(blocks);
View Full Code Here

  }

  @Test
  public void testGetPreviousServiceDatesForArrivalInterval() {

    BlockEntry blockA = block("blockA");
    blockConfiguration(blockA, serviceIds(lsids("sA"), lsids()));

    List<BlockEntry> blocks = Arrays.asList(blockA);

    Mockito.when(_transitGraphDao.getAllBlocks()).thenReturn(blocks);
View Full Code Here

    @Override
    public List<BlockLocationRecord> getRecordsFromDao(long fromTime,
        long toTime) {
      BlockConfigurationEntry blockConfig = _blockInstance.getBlock();
      BlockEntry block = blockConfig.getBlock();
      return _blockLocationRecordDao.getBlockLocationRecordsForBlockServiceDateAndTimeRange(
          block.getId(), _blockInstance.getServiceDate(), fromTime, toTime);
    }
View Full Code Here

    TripEntry trip = _graph.getTripEntryForId(tripId);

    if (trip == null)
      return;

    BlockEntry block = trip.getBlock();

    TripProblemReportRecord record = new TripProblemReportRecord();
    record.setCode(problem.getCode());
    record.setServiceDate(problem.getServiceDate());

    String vehicleId = problem.getVehicleId();
    if (vehicleId != null)
      record.setVehicleId(AgencyAndIdLibrary.convertFromString(vehicleId));

    String stopId = problem.getStopId();
    if (stopId != null)
      record.setStopId(AgencyAndIdLibrary.convertFromString(stopId));

    record.setTime(problem.getTime());
    record.setTripId(tripId);
    record.setBlockId(block.getId());

    record.setUserComment(problem.getUserComment());

    if (problem.getUserLat() != null && !Double.isNaN(problem.getUserLat()))
      record.setUserLat(problem.getUserLat());
    if (problem.getUserLon() != null && !Double.isNaN(problem.getUserLon()))
      record.setUserLon(problem.getUserLon());
    if (problem.getUserLocationAccuracy() != null
        && !Double.isNaN(problem.getUserLocationAccuracy()))
      record.setUserLocationAccuracy(problem.getUserLocationAccuracy());

    record.setUserOnVehicle(problem.isUserOnVehicle());
    record.setUserVehicleNumber(problem.getUserVehicleNumber());

    Map<BlockInstance, List<BlockLocation>> locationsByInstance = _blockStatusService.getBlocks(
        block.getId(), problem.getServiceDate(), record.getVehicleId(),
        problem.getTime());

    BlockInstance blockInstance = getBestBlockInstance(locationsByInstance.keySet());

    if (blockInstance != null) {
View Full Code Here

TOP

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

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.