delay
This commit is contained in:
+32
-24
@@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
FlopRegex = `(?m)\((?P<type>\w{3}).*(.|\n|\r).*\)`
|
||||
FlopRegex = `(?m)\((?P<type>[A-Z]{3}).*(.|\n|\r)*\)`
|
||||
DestinationRegex = `(?P<dest>[A-Z]+)(?P<time>\d{0,4})`
|
||||
DofValueRex = `(?m)DOF\/(?P<time>\d{6})`
|
||||
TypeArrival = "ARR"
|
||||
@@ -15,13 +15,22 @@ const (
|
||||
TypeFlightPlan = "FPL"
|
||||
TypeDelay = "DLA"
|
||||
|
||||
DepRegex = `(?P<dep>\w+\d{0,4})`
|
||||
ArrRegex = `(?P<arr>\w+\d{0,4})`
|
||||
PlaneRegex = `(?P<plane>\w+\d+\/?\w\d+)`
|
||||
DofRegex = `(?P<dof>DOF\/\d{6})`
|
||||
DepRegex = `-?(?P<dep>\w+\d{0,4})`
|
||||
ArrRegex = `-?(?P<arr>\w+\d{0,4})`
|
||||
PlaneRegex = `-?(?P<plane>\w+\d+\/?\w\d+)`
|
||||
DofRegex = `-?(?P<dof>DOF\/\d{6})?`
|
||||
KeyPlane = "plane"
|
||||
|
||||
CompositeDepArr = `(?m)\(` + `\w{3}` + "-" + PlaneRegex + "-" + DepRegex + "-" + ArrRegex + "-?" + DofRegex + `?\)`
|
||||
/**
|
||||
* example:
|
||||
* (ARR-CSN3126/A5040-ZSPD-ZBTJ1601)
|
||||
* (DEP-CSN3125/A4553-ZGHA0554-ZBTJ-DOF/120820)
|
||||
*/
|
||||
CompositeDepArr = `(?m)\(` + `\[A-Z]{3}` + PlaneRegex + DepRegex + ArrRegex + DofRegex + `\)`
|
||||
/**
|
||||
* sample:
|
||||
* (DLA‐ABC123‐NZAA0145‐VTBS‐DOF/091120)
|
||||
*/
|
||||
CompositeDelay = `(?m)\(DLA` + PlaneRegex + DepRegex + ArrRegex + DofRegex + `\)`
|
||||
|
||||
KeyDeparture = "dep"
|
||||
KeyArrival = "arr"
|
||||
@@ -31,11 +40,6 @@ const (
|
||||
var flopRegex = regexp.MustCompile(FlopRegex)
|
||||
|
||||
func parseArrOrDep(telegram *Telegram, data string) {
|
||||
/**
|
||||
* example:
|
||||
* (ARR-CSN3126/A5040-ZSPD-ZBTJ1601)
|
||||
* (DEP-CSN3125/A4553-ZGHA0554-ZBTJ-DOF/120820)
|
||||
*/
|
||||
fields := getFields(CompositeDepArr, data)
|
||||
if len(fields) < 1 {
|
||||
telegram.ParseErrors = append(telegram.ParseErrors, errors.New("data less than 4 "))
|
||||
@@ -73,20 +77,24 @@ func parseFlightPlan(telegram *Telegram, data string) {
|
||||
telegram.Departure, telegram.DepartureTime = parseAirportAndTime(values[5])
|
||||
destString := strings.Split(values[7], " ")
|
||||
telegram.Destination, telegram.DestinationTime = parseAirportAndTime(destString[0])
|
||||
//parseDof(telegram, values[8])
|
||||
telegram.DateOfFlight = parseDof(values[8])
|
||||
|
||||
}
|
||||
|
||||
func parseDelay(telegram *Telegram, data string) {
|
||||
/**
|
||||
* sample:
|
||||
* (DLA‐ABC123‐NZAA0145‐VTBS‐DOF/091120)
|
||||
*/
|
||||
values := getSplitValues(data)
|
||||
telegram.FlightNumber = values[1]
|
||||
telegram.Departure, telegram.DepartureTime = parseAirportAndTime(values[2])
|
||||
telegram.Destination, telegram.DestinationTime = parseAirportAndTime(values[3])
|
||||
//if len(values) == 5 {
|
||||
// parseDof(telegram, values[4])
|
||||
//}
|
||||
fields := getFields(CompositeDelay, data)
|
||||
if len(fields) < 1 {
|
||||
telegram.ParseErrors = append(telegram.ParseErrors, errors.New("data less than 4 "))
|
||||
telegram.Parsed = false
|
||||
return
|
||||
}
|
||||
|
||||
telegram.FlightNumber, telegram.RegisterNumber = parseFlight(fields[KeyPlane])
|
||||
telegram.Departure, telegram.DepartureTime = parseAirportAndTime(fields[KeyDeparture])
|
||||
telegram.Destination, telegram.DestinationTime = parseAirportAndTime(fields[KeyArrival])
|
||||
dofValue := fields[KeyDof]
|
||||
if len(dofValue) > 0 {
|
||||
telegram.DateOfFlight = parseDof(dofValue)
|
||||
}
|
||||
telegram.Parsed = true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user