private boolean isCodeshareFlight(DgOagLine line) { if (line.isCodeshareFlight()) { this.ignoredCodeshareFlights++; return true; } return false; }
private boolean isBusOrTrainFlight(DgOagLine line) { String aircraftType = line.getAircraftType(); if (aircraftType.equalsIgnoreCase("BUS") // filter busses || aircraftType.equalsIgnoreCase("RFS") // filter bus/train || aircraftType.equalsIgnoreCase("TRN")) { // filter trains this.ignoredBusOrTrainFlights++; return true; } return false; }
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; }
private DgOagFlight createFlight( String flightDesignator, double departureInSec, double duration, String route, DgOagLine l) { DgOagFlight dgf = new DgOagFlight(flightDesignator); dgf.setAircraftType(l.getAircraftType()); dgf.setCarrier(l.getCarrier()); dgf.setDepartureTime(departureInSec); dgf.setDuration(duration); dgf.setSeatsAvailable(l.getSeatsAvailable()); dgf.setRoute(route); dgf.setDistanceKm(l.getFlightDistanceKm()); dgf.setOriginCode(l.getOriginAirport()); dgf.setDestinationCode(l.getDestinationAirport()); return dgf; }
private boolean hasOtherBadData(DgOagLine line) { // && seatsAvail > 0 // filter for flights with 1 PAX or more only // && !originAirport.equalsIgnoreCase(destinationAirport) // && (stops < 1) && (duration > 0.) && (fullRouting.length() <= 6)) { if (line.getSeatsAvailable() <= 0 || line.getOriginAirport().equalsIgnoreCase(line.getDestinationAirport()) || line.getStops() > 1 || line.getFlightDurationSeconds() <= 0.0 || line.getFullRouting().length() > 6) { this.ignoredDueToBadData++; return true; } return false; }
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; }