Package com.google.transit.realtime.GtfsRealtime

Examples of com.google.transit.realtime.GtfsRealtime.VehiclePosition


      update.block = entry.getKey();
      update.tripUpdates = entry.getValue();

      FeedEntity vehiclePositionEntity = vehiclePositionsByBlockDescriptor.get(update.block);
      if (vehiclePositionEntity != null) {
        VehiclePosition vehiclePosition = vehiclePositionEntity.getVehicle();
        update.vehiclePosition = vehiclePosition;
        if (vehiclePosition.hasVehicle()) {
          VehicleDescriptor vehicle = vehiclePosition.getVehicle();
          if (vehicle.hasId()) {
            update.block.setVehicleId(vehicle.getId());
          }
        }
      }
View Full Code Here


      FeedMessage vehiclePositions, boolean includeVehicleIds) {

    Map<BlockDescriptor, FeedEntity> vehiclePositionsByBlockDescriptor = new HashMap<BlockDescriptor, FeedEntity>();

    for (FeedEntity entity : vehiclePositions.getEntityList()) {
      VehiclePosition vehiclePosition = entity.getVehicle();
      if (vehiclePosition == null) {
        _log.warn("expected a FeedEntity with a VehiclePosition");
        continue;
      }
      if (!(vehiclePosition.hasTrip() || vehiclePosition.hasPosition())) {
        continue;
      }
      TripDescriptor trip = vehiclePosition.getTrip();
      BlockDescriptor blockDescriptor = getTripDescriptorAsBlockDescriptor(result,
          trip, includeVehicleIds);
      if (blockDescriptor != null) {
        FeedEntity existing = vehiclePositionsByBlockDescriptor.put(
            blockDescriptor, entity);
View Full Code Here

    assertEquals(2, feed.getEntityCount());

    {
      FeedEntity entity = feed.getEntity(0);
      assertEquals("1", entity.getId());
      VehiclePosition vehiclePosition = entity.getVehicle();
      assertEquals("t0", vehiclePosition.getTrip().getTripId());
      assertEquals("r1", vehiclePosition.getTrip().getRouteId());
      assertEquals("v1", vehiclePosition.getVehicle().getId());
      assertEquals(1234, vehiclePosition.getTimestamp());
      assertEquals(47.0, vehiclePosition.getPosition().getLatitude(), 0.01);
      assertEquals(-122.0, vehiclePosition.getPosition().getLongitude(), 0.01);
    }

    {
      FeedEntity entity = feed.getEntity(1);
      assertEquals("2", entity.getId());
      VehiclePosition vehiclePosition = entity.getVehicle();
      assertEquals("t1", vehiclePosition.getTrip().getTripId());
      assertEquals("r1", vehiclePosition.getTrip().getRouteId());
      assertEquals("v2", vehiclePosition.getVehicle().getId());
      assertEquals(5678, vehiclePosition.getTimestamp());
      assertEquals(47.1, vehiclePosition.getPosition().getLatitude(), 0.01);
      assertEquals(-122.1, vehiclePosition.getPosition().getLongitude(), 0.01);
    }
  }
View Full Code Here

TOP

Related Classes of com.google.transit.realtime.GtfsRealtime.VehiclePosition

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.