add fpl dla

This commit is contained in:
zhiqiang feng
2021-01-04 18:07:48 +08:00
parent 576216f712
commit 263f38633f
5 changed files with 155 additions and 43 deletions
+8 -4
View File
@@ -16,6 +16,7 @@ type Telegram struct {
Type string
FlopValue []string
FlightNumber string
Plane string
RegisterNumber string
Departure string
DepartureTime time.Time
@@ -42,12 +43,15 @@ func Parse(text string) (*Telegram, error) {
if isPln(*telegram) {
telegram.Type = TypePLN
} else if flopValues := getFields(FlopRegex, telegram.Text); len(flopValues) > 0 {
telegram.Type = flopValues["flop"]
r := regexp.MustCompile(FlopRegex)
data := r.FindString(telegram.Text)
telegram.Type = flopValues["type"]
data := flopRegex.FindString(telegram.Text)
switch telegram.Type {
case TypeArrival, TypeDeparture:
parseArrOrDep(telegram, data)
case TypeFlightPlan:
parseFlightPlan(telegram, data)
case TypeDelay:
parseDelay(telegram, data)
}
}
return telegram, nil
@@ -80,7 +84,7 @@ func getFields(regEx string, field string) (fields map[string]string) {
return
}
func getFlopValues(s string) []string {
func getSplitValues(s string) []string {
// get rid of ()
s = strings.TrimSpace(s)
s = s[1 : len(s)-1]