Package org.onebusaway.transit_data_federation.services.realtime

Examples of org.onebusaway.transit_data_federation.services.realtime.BlockLocation


      return false;

    Record record = records.get(records.size() - 1);

    AgencyAndId vehicleId = AgencyAndIdLibrary.convertFromString(query.getVehicleId());
    BlockLocation location = _blockLocationService.getLocationForVehicleAndTime(
        vehicleId, new TargetTime(record.getTimestamp()));

    if (location == null)
      return false;

    double d = SphericalGeometryLibrary.distance(record.getLocation(),
        location.getLocation());
    double p = _realTimeLocationDeviationModel.probability(d);

    if (p < _shortCutProbability)
      return false;
View Full Code Here


      double p = _realTimeLocationDeviationModel.probability(d);
      ps.add(p);
    }

    BlockLocation last = locations.get(locations.size() - 1);
    double mu = Descriptive.mean(ps);
    String debug = asString(ps);
    addResult(last, mu, debug, minProbabilityForConsideration, beans);
  }
View Full Code Here

    }

    blockLocations.add(lastLocation);
    updateProbabilitiesWithScheduleDeviations(records, blockLocations, ps);

    BlockLocation location = _blockLocationService.getLocationForBlockInstanceAndScheduledBlockLocation(
        blockInstance, lastLocation, lastRecord.getTimestamp());
    double mu = Descriptive.mean(ps);
    String debug = asString(ps);
    addResult(location, mu, debug, minProbabilityForConsideration, beans);
  }
View Full Code Here

  @Override
  public TripDetailsBean getTripForVehicle(AgencyAndId vehicleId, long time,
      TripDetailsInclusionBean inclusion) {

    BlockLocation blockLocation = _blockStatusService.getBlockForVehicle(
        vehicleId, time);
    if (blockLocation == null)
      return null;
    return getBlockLocationAsTripDetails(blockLocation.getActiveTripInstance(),
        blockLocation, inclusion, time);
  }
View Full Code Here

     ****/

    BlockInstance blockInstanceA = new BlockInstance(blockConfigA, serviceDate);
    long lastUpdateTime = dateAsLong("2010-10-05 16:15");

    BlockLocation blockLocationA = new BlockLocation();
    blockLocationA.setActiveTrip(bstAA.getTrip());
    blockLocationA.setBlockInstance(blockInstanceA);
    blockLocationA.setClosestStop(bstAA);
    blockLocationA.setDistanceAlongBlock(500);
    blockLocationA.setInService(true);
    blockLocationA.setLastUpdateTime(lastUpdateTime);
    blockLocationA.setNextStop(bstAA);
    blockLocationA.setPredicted(true);
    blockLocationA.setScheduledDistanceAlongBlock(600);
    blockLocationA.setScheduleDeviation(10 * 60);
    blockLocationA.setVehicleId(aid("vehicle"));

    /****
     *
     ****/

    BlockInstance blockInstanceB = new BlockInstance(blockConfigB, serviceDate);

    BlockLocation blockLocationB = new BlockLocation();
    blockLocationB.setActiveTrip(bstBA.getTrip());
    blockLocationB.setBlockInstance(blockInstanceA);
    blockLocationB.setClosestStop(bstBA);
    blockLocationB.setDistanceAlongBlock(400);
    blockLocationB.setInService(true);
    blockLocationB.setNextStop(bstAA);
    blockLocationB.setPredicted(false);
    blockLocationB.setScheduledDistanceAlongBlock(400);

    /****
     *
     ****/

 
View Full Code Here

    TargetTime target = new TargetTime(t(
        serviceDate, 0, 0), System.currentTimeMillis());

    BlockInstance blockInstance = new BlockInstance(blockConfig, serviceDate);
    BlockLocation location = _service.getLocationForBlockInstance(
        blockInstance, target);

    assertNull(location);

    ScheduledBlockLocation p = new ScheduledBlockLocation();
    p.setActiveTrip(blockConfig.getTrips().get(0));
    p.setClosestStop(blockConfig.getStopTimes().get(0));
    p.setClosestStopTimeOffset(0);
    p.setDistanceAlongBlock(0);
    p.setLocation(new CoordinatePoint(stopA.getStopLat(), stopA.getStopLon()));
    p.setInService(true);

    Mockito.when(
        _blockLocationService.getScheduledBlockLocationFromScheduledTime(
            blockConfig, 1800)).thenReturn(p);

    target = new TargetTime(t(serviceDate, 0, 30), System.currentTimeMillis());

    location = _service.getLocationForBlockInstance(blockInstance, target);

    assertTrue(location.isInService());
    assertEquals(blockConfig.getStopTimes().get(0), location.getClosestStop());
    assertEquals(0, location.getClosestStopTimeOffset());

    assertEquals(stopA.getStopLocation(), location.getLocation());

    assertFalse(location.isScheduleDeviationSet());
    assertTrue(Double.isNaN(location.getScheduleDeviation()));

    assertFalse(location.isDistanceAlongBlockSet());
    assertTrue(Double.isNaN(location.getDistanceAlongBlock()));

    assertEquals(blockInstance, location.getBlockInstance());
    assertEquals(0, location.getLastUpdateTime());
    assertEquals(blockConfig.getTrips().get(0), location.getActiveTrip());
    assertNull(location.getVehicleId());

    assertEquals(47.5, location.getLocation().getLat(), epsilon);
    assertEquals(-122.5, location.getLocation().getLon(), epsilon);
    assertEquals(blockConfig.getStopTimes().get(0), location.getClosestStop());
    assertEquals(0, location.getClosestStopTimeOffset());
  }
View Full Code Here

          effectiveScheduleTime);

      /**
       * We put the alarm in the schedule-only vs real-time queue as appropriate
       */
      BlockLocation blockLocation = instance.getBlockLocation();

      if (blockLocation == null || blockLocation.getVehicleId() == null) {

        _log.debug("schedule only for alarm: {}", instance);
        _noVehicleIdQueue.add(alarm);

      } else {

        _log.debug("real-time for alarm: {}", instance);
        AgencyAndId vehicleId = blockLocation.getVehicleId();
        VehicleInfo vehicleInfo = getVehicleInfoForVehicleId(vehicleId, true);
        if (blockLocation.isScheduleDeviationSet())
          vehicleInfo.setScheduleDeviation((int) blockLocation.getScheduleDeviation());
        else
          _log.warn("no schedule deviation for block location " + blockLocation);
        PriorityQueue<AlarmForBlockInstance> queue = vehicleInfo.getQueue();
        queue.add(alarm);
      }
View Full Code Here

    transitLeg.setFromStopSequence(fromStopTime.getSequence());

    leg.setFrom(fromStop.getStopLocation());

    BlockLocation blockLocation = fromStopTimeInstance.getBlockLocation();
    if (blockLocation != null) {
      AgencyAndId vehicleId = blockLocation.getVehicleId();
      transitLeg.setVehicleId(AgencyAndIdLibrary.convertToString(vehicleId));
    }
  }
View Full Code Here

    StopTimeEntry stopTime = blockStopTime.getStopTime();
    transitLeg.setToStopSequence(stopTime.getSequence());

    leg.setTo(toStop.getStopLocation());

    BlockLocation blockLocation = toStopTimeInstance.getBlockLocation();
    if (blockLocation != null) {
      AgencyAndId vehicleId = blockLocation.getVehicleId();
      transitLeg.setVehicleId(AgencyAndIdLibrary.convertToString(vehicleId));
    }
  }
View Full Code Here

    int result = 1;

    result = prime * result + instance.getBlockInstance().hashCode();
    result = prime * result + instance.getBlockStopTime().hashCode();

    BlockLocation blockLocation = instance.getBlockLocation();

    /**
     * There can be potentially multiple vehicles serving a block instance, so
     * we key off the vehicle id when applicable
     */
    if (blockLocation != null) {
      if (blockLocation.getVehicleId() != null)
        result = prime * result + blockLocation.getVehicleId().hashCode();
    }

    return result;
  }
View Full Code Here

TOP

Related Classes of org.onebusaway.transit_data_federation.services.realtime.BlockLocation

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.