|
| 1 | +package common |
| 2 | + |
| 3 | +import ( |
| 4 | + "maps" |
| 5 | +) |
| 6 | + |
| 7 | +type FlightScheduleData struct { |
| 8 | + DepartureTime OffsetTime `json:"departureTime"` |
| 9 | + DepartureAirport string `json:"departureAirport"` |
| 10 | + ArrivalTime OffsetTime `json:"arrivalTime"` |
| 11 | + ArrivalAirport string `json:"arrivalAirport"` |
| 12 | + ServiceType string `json:"serviceType"` |
| 13 | + AircraftOwner AirlineIdentifier `json:"aircraftOwner"` |
| 14 | + AircraftType string `json:"aircraftType"` |
| 15 | + AircraftConfigurationVersion string `json:"aircraftConfigurationVersion"` |
| 16 | + Registration string `json:"registration"` |
| 17 | + DataElements map[int]string `json:"dataElements"` |
| 18 | + CodeShares []FlightNumber `json:"codeShares"` |
| 19 | +} |
| 20 | + |
| 21 | +func (fsd FlightScheduleData) Equal(other FlightScheduleData) bool { |
| 22 | + return fsd.DepartureTime == other.DepartureTime && |
| 23 | + fsd.DepartureAirport == other.DepartureAirport && |
| 24 | + fsd.ArrivalTime == other.ArrivalTime && |
| 25 | + fsd.ArrivalAirport == other.ArrivalAirport && |
| 26 | + fsd.ServiceType == other.ServiceType && |
| 27 | + fsd.AircraftOwner == other.AircraftOwner && |
| 28 | + fsd.AircraftType == other.AircraftType && |
| 29 | + fsd.AircraftConfigurationVersion == other.AircraftConfigurationVersion && |
| 30 | + fsd.Registration == other.Registration && |
| 31 | + maps.Equal(fsd.DataElements, other.DataElements) && |
| 32 | + SliceEqualContent(fsd.CodeShares, other.CodeShares) |
| 33 | +} |
| 34 | + |
| 35 | +type FlightScheduleVariant struct { |
| 36 | + Ranges []LocalDateRange `json:"ranges"` |
| 37 | + Data FlightScheduleData `json:"data"` |
| 38 | +} |
| 39 | + |
| 40 | +func (fsv *FlightScheduleVariant) Expand(d LocalDate) { |
| 41 | + |
| 42 | +} |
| 43 | + |
| 44 | +type FlightSchedule struct { |
| 45 | + Airline AirlineIdentifier `json:"airline"` |
| 46 | + FlightNumber int `json:"flightNumber"` |
| 47 | + Suffix string `json:"suffix"` |
| 48 | + Variants []*FlightScheduleVariant `json:"variants"` |
| 49 | +} |
| 50 | + |
| 51 | +func (fs *FlightSchedule) DataVariant(fsd FlightScheduleData) *FlightScheduleVariant { |
| 52 | + for _, variant := range fs.Variants { |
| 53 | + if variant.Data.Equal(fsd) { |
| 54 | + return variant |
| 55 | + } |
| 56 | + } |
| 57 | + |
| 58 | + return nil |
| 59 | +} |
0 commit comments