.setLatitude(vehicleData.getLatitude()) .setLongitude(vehicleData.getLongitude());
@Override public FeedMessage getVehiclePositions() { FeedMessage.Builder feedMessage = createFeedWithDefaultHeader(); List<VehicleStatus> statuses = _vehicleStatusService.getAllVehicleStatuses(); for (VehicleStatus status : statuses) { VehicleLocationRecord record = status.getRecord(); VehiclePosition.Builder vehiclePosition = VehiclePosition.newBuilder(); if (record.isCurrentLocationSet()) { Position.Builder position = Position.newBuilder(); position.setLatitude((float) record.getCurrentLocationLat()); position.setLongitude((float) record.getCurrentLocationLon()); vehiclePosition.setPosition(position); } VehicleDescriptor.Builder vehicleDescriptor = VehicleDescriptor.newBuilder(); vehicleDescriptor.setId(AgencyAndId.convertToString(record.getVehicleId())); vehiclePosition.setVehicle(vehicleDescriptor); if (record.getTimeOfLocationUpdate() != 0) vehiclePosition.setTimestamp(record.getTimeOfLocationUpdate() / 1000); else vehiclePosition.setTimestamp(record.getTimeOfRecord() / 1000); /** * TODO: Block? Trip? */ FeedEntity.Builder feedEntity = FeedEntity.newBuilder(); feedEntity.setVehicle(vehiclePosition); feedEntity.setId(vehicleDescriptor.getId()); feedMessage.addEntity(feedEntity); } return feedMessage.build(); }
public Builder mergeFrom(com.google.transit.realtime.GtfsRealtime.Position other) { if (other == com.google.transit.realtime.GtfsRealtime.Position.getDefaultInstance()) return this; if (other.hasLatitude()) { setLatitude(other.getLatitude()); } if (other.hasLongitude()) { setLongitude(other.getLongitude()); } if (other.hasBearing()) { setBearing(other.getBearing()); } if (other.hasOdometer()) { setOdometer(other.getOdometer()); } if (other.hasSpeed()) { setSpeed(other.getSpeed()); } this.mergeExtensionFields(other); this.mergeUnknownFields(other.getUnknownFields()); return this; }
public Builder mergeFrom(com.google.transit.realtime.GtfsRealtime.Position other) { if (other == com.google.transit.realtime.GtfsRealtime.Position.getDefaultInstance()) return this; if (other.hasLatitude()) { setLatitude(other.getLatitude()); } if (other.hasLongitude()) { setLongitude(other.getLongitude()); } if (other.hasBearing()) { setBearing(other.getBearing()); } if (other.hasOdometer()) { setOdometer(other.getOdometer()); } if (other.hasSpeed()) { setSpeed(other.getSpeed()); } this.mergeExtensionFields(other); this.mergeUnknownFields(other.getUnknownFields()); return this; }