Exemple #1
0
 /**
  * Returns the average co2 emission for the track.
  *
  * @return
  */
 public double getCO2Average() {
   double co2Average = 0.0;
   try {
     for (Measurement measurement : measurements) {
       if (measurement.getProperty(CONSUMPTION) != null) {
         co2Average =
             co2Average
                 + consumptionAlgorithm.calculateCO2FromConsumption(
                     measurement.getProperty(CONSUMPTION));
       }
     }
     co2Average = co2Average / measurements.size();
   } catch (FuelConsumptionException e) {
     logger.warn(e.getMessage(), e);
   }
   return co2Average;
 }
Exemple #2
0
  public double getFuelConsumptionPerHour() throws UnsupportedFuelTypeException {
    if (consumptionPerHour == null) {
      consumptionPerHour = 0.0;

      int consideredCount = 0;
      for (int i = 0; i < measurements.size(); i++) {
        try {
          consumptionPerHour =
              consumptionPerHour + consumptionAlgorithm.calculateConsumption(measurements.get(i));
          consideredCount++;
        } catch (FuelConsumptionException e) {
          logger.warn(e.getMessage());
        }
      }
      consumptionPerHour = consumptionPerHour / consideredCount;
    }
    return consumptionPerHour;
  }