Exemplo n.º 1
0
  private double calculateFlightDuration(DgOagLine l, String route) {
    double duration = l.getFlightDurationSeconds();
    if (duration > 24.0 * 3600) {
      log.warn(
          "Flight "
              + l.getFlightNumber()
              + " has a duration of "
              + Time.writeTime(duration)
              + " hh:mm:ss that is considered as not realistic, substracting 24 h...");
      duration -= (24.0 * 3600.0);
    }

    if (DgCreateSfFlightScenario.doCreateStars) {
      duration = this.calculateFlightDurationWithStar(l.getDestinationAirport(), duration);
    }

    if (!this.routeDurationMap.containsKey(route)) {
      this.routeDurationMap.put(route, duration);
    }
    return duration;
  }
Exemplo n.º 2
0
  private DgOagFlightsData filter(
      List<DgOagLine> oagLines, String outputDirectory, String oagFlightsOutputFilename)
      throws Exception {
    DgOagFlightsData data = new DgOagFlightsData();

    for (DgOagLine l : oagLines) {
      boolean skipLine = false;
      if (!isCountryOfInterest(l.getOriginCountry(), l.getDestinationCountry())) {
        continue;
        //				skipLine = true;
      }
      if (isCodeshareFlight(l)) {
        //				skipLine = true;
        continue;
      }
      if (isBusOrTrainFlight(l)) {
        //				skipLine = true;
        continue;
      }
      String flightDesignator = l.getCarrier() + l.getFlightNumber();
      if (data.getFlightDesignatorFlightMap().containsKey(flightDesignator)) {
        log.warn("Flight already exists: " + flightDesignator);
        this.ignoredDueDuplicatedEntry++;
        //				skipLine = true;
        continue;
      }

      if (DgCreateSfFlightScenario.doApplyAirportFilter) {
        if (!isAiportFilterApplying(l.getOriginAirport(), l.getDestinationAirport())) {
          this.ignoredDueAirportFilter++;
          //					skipLine = true;
          continue;
        }
      }
      // the filters below are relevant for detection of data accuracy for data that is not provided
      // by oag
      // --> skipLine instead of continue
      if (!airportCoordinatesAvailable(
          l.getOriginAirport(), l.getDestinationAirport(), availableAirportCoordinates)) {
        skipLine = true;
      }
      if (!isUTCOffsetAvailable(l.getOriginAirport(), l.getDestinationAirport())) {
        skipLine = true;
      }
      if (hasOtherBadData(l)) {
        skipLine = true;
      }
      if (skipLine) {
        continue;
      }

      String route = l.getOriginAirport() + "_" + l.getDestinationAirport();
      // log.debug("route:  " + route);
      double departureInSec = l.getDepartureTimeSeconds();
      double utcOffset = this.utcOffset.get(l.getOriginAirport());
      departureInSec = departureInSec - utcOffset;
      if (departureInSec < 0) {
        departureInSec +=
            (24.0
                * 3600.0); // shifting flights with departure on previous day in UTC time +24 hours
      }

      double duration = this.calculateFlightDuration(l, route);

      this.cityPairDistance.put(route, l.getFlightDistanceKm());
      if ((l.getFlightDistanceKm() * 1000 / duration) <= 40.) {
        log.debug("too low speed :" + flightDesignator);
      }

      // used to generate Tuesday flights only, for other days change the daysOfOperation filter
      // below to desired
      // day
      DgOagFlight dgOagFlight = null;
      if (DgCreateDgFlightScenario.useSingleDayOfOperation) {
        if (this.operatesTuesdays(l.getDaysOfOperation())) {
          dgOagFlight = this.createFlight(flightDesignator, departureInSec, duration, route, l);
          data.addFlight(dgOagFlight);
          this.airportsInModel.put(
              l.getOriginAirport(), availableAirportCoordinates.get(l.getOriginAirport()));
          this.airportsInModel.put(
              l.getDestinationAirport(),
              availableAirportCoordinates.get(l.getDestinationAirport()));
        }
      }
      // used to generate air traffic of an entire week with departures being shifted 24 hours for
      // each day
      else {
        char[] opsDays = l.getDaysOfOperation();
        for (int dayCount = 0; dayCount <= opsDays.length; dayCount++) {
          flightDesignator = flightDesignator + "_" + opsDays[dayCount];
          int opsDay = Integer.parseInt(String.valueOf(opsDays[dayCount]));
          departureInSec = (departureInSec + opsDay * 24 * 3600.) - 24 * 3600.0;

          dgOagFlight = this.createFlight(flightDesignator, departureInSec, duration, route, l);
          data.addFlight(dgOagFlight);
          this.airportsInModel.put(
              l.getOriginAirport(), availableAirportCoordinates.get(l.getOriginAirport()));
          this.airportsInModel.put(
              l.getDestinationAirport(),
              availableAirportCoordinates.get(l.getDestinationAirport()));
        }
      }
    }
    return data;
  }