refactor: Add CNL message parsing logic to BodyParser

The code changes in `aviation_parser.go` and `aviation_parser_test.go` add CNL message parsing logic to the `BodyParser` module. This allows for the correct extraction and parsing of CNL messages, including the category, aircraft ID, departure airport, and destination airport. This enhancement improves the overall functionality and accuracy of the code.
This commit is contained in:
windyboy
2024-07-24 17:15:35 +08:00
parent 1715591ef5
commit e58fa3bb36
4 changed files with 62 additions and 0 deletions
+11
View File
@@ -98,6 +98,8 @@ const (
// - other: any other relevant information, starting with three uppercase letters followed by a forward slash and zero or more characters (including newline)
fplPatternString = `\((?P<category>[A-Z]{3})-(?P<number>[A-Z]+\d+)-(?P<indicator>[A-Z]{2})\n-(?P<aircraft>[A-Z]+\d+\/?[A-Z]?)\n?-(?P<surve>.*)\n?-(?P<departure>[A-Z]{4})(?P<departure_time>\d{4})\n?-(?P<speed>[A-Z]+\d+)(?P<level>[A-Z0-9]+)\s+(?P<route>(.|\n)+)\n-(?P<destination>[A-Z]{4})(?P<estt>\d{4})\s?(?P<alter>(\s[A-Z]{4})+)\n?-([A-Z]{3}\/(?:[A-Z]{4}\d{4}\s?)+)?(?P<other>(?m)[A-Z]{3}\/(.|\n)*)\)$`
cnlPatternString = `^\((?P<category>[A-Z]{3})-(?P<number>\w+\d+)-?(?P<departure>[A-Z]{4})?-?(?<destination>[A-Z]{4})\)$`
)
// Initialize the bodyPatterns map
@@ -129,6 +131,15 @@ var bodyPatterns = map[string]BodyConfig{
},
},
},
"CNL": {
Patterns: []PatternConfig{
{
Pattern: cnlPatternString,
Comments: "Pattern for CNL message",
Expression: regexp.MustCompile(cnlPatternString),
},
},
},
}
func GetBodyPatterns() map[string]BodyConfig {