Skip to content

Commit

Permalink
Merge pull request #512 from mobidata-bw/issues/502_current_range_meters
Browse files Browse the repository at this point in the history
Map current_range_meters as provided instead of setting a missing value to 0.0
  • Loading branch information
testower authored Jul 29, 2024
2 parents 616685e + b09c92c commit d4d5ef1
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ public Vehicle mapVehicle(
mappedVehicle.setLon(vehicle.getLon());
mappedVehicle.setReserved(vehicle.getIsReserved());
mappedVehicle.setDisabled(vehicle.getIsDisabled());
mappedVehicle.setCurrentRangeMeters(vehicle.getCurrentRangeMeters());
mappedVehicle.setCurrentRangeMeters(
vehicle.getCurrentRangeMeters() == null ? 0.0 : vehicle.getCurrentRangeMeters()
);
mappedVehicle.setCurrentFuelPercent(vehicle.getCurrentFuelPercent());
mappedVehicle.setVehicleType(vehicleType);
mappedVehicle.setPricingPlan(pricingPlan);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ protected GBFSBike mapBike(GBFSBike bike, FeedProvider feedProvider) {
mapped.setRentalUris(bike.getRentalUris());
mapped.setVehicleTypeId(mapVehicleTypeId(bike.getVehicleTypeId(), feedProvider));
mapped.setLastReported(bike.getLastReported());
mapped.setCurrentRangeMeters(
bike.getCurrentRangeMeters() != null ? bike.getCurrentRangeMeters() : 0
);
mapped.setCurrentRangeMeters(bike.getCurrentRangeMeters());
mapped.setCurrentFuelPercent(bike.getCurrentFuelPercent());
mapped.setStationId(mapStationId(bike.getStationId(), feedProvider));
mapped.setHomeStationId(mapStationId(bike.getHomeStationId(), feedProvider));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ protected GBFSVehicle mapVehicle(GBFSVehicle vehicle, FeedProvider feedProvider)
mapped.setRentalUris(vehicle.getRentalUris());
mapped.setVehicleTypeId(mapVehicleTypeId(vehicle.getVehicleTypeId(), feedProvider));
mapped.setLastReported(vehicle.getLastReported());
mapped.setCurrentRangeMeters(
vehicle.getCurrentRangeMeters() != null ? vehicle.getCurrentRangeMeters() : 0
);
mapped.setCurrentRangeMeters(vehicle.getCurrentRangeMeters());
mapped.setCurrentFuelPercent(vehicle.getCurrentFuelPercent());
mapped.setStationId(mapStationId(vehicle.getStationId(), feedProvider));
mapped.setHomeStationId(mapStationId(vehicle.getHomeStationId(), feedProvider));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ void prepare() {
void testMissingCurrentRangeMeters() {
var feedProvider = getTestProvider();
var mapped = mapper.mapBike(new GBFSBike(), feedProvider);
Assertions.assertNotNull(mapped.getCurrentRangeMeters());
// if no current_range_meters is provided, we explicitly don't want Lamassu to fill it in
Assertions.assertNull(mapped.getCurrentRangeMeters());
}

@Test
Expand Down

0 comments on commit d4d5ef1

Please sign in to comment.