Adds AU tail number decoding from ICAO addr.

Contribution by @armeniki. #736.
pull/742/head
cyoung 2018-08-15 15:02:52 -04:00
rodzic 8d9fdd31f7
commit 260a14ca4c
1 zmienionych plików z 29 dodań i 2 usunięć

Wyświetl plik

@ -1164,11 +1164,13 @@ func updateDemoTraffic(icao uint32, tail string, relAlt float32, gs float64, off
but are not used for aicraft on the civil registry. These could be
military, other public aircraft, or future use.
Values between C0CDF9 - C3FFFF are allocated to Canada,
but are not used for aicraft on the civil registry. These could be
military, other public aircraft, or future use.
Values between 7C0000 - 7FFFFF are allocated to Australia.
Output:
string: String containing the decoded tail number (if decoding succeeded),
"NON-NA" (for non-US / non Canada allocation), and "US-MIL" or "CA-MIL" for non-civil US / Canada allocation.
@ -1189,9 +1191,11 @@ func icao2reg(icao_addr uint32) (string, bool) {
nation = "US"
} else if (icao_addr >= 0xC00001) && (icao_addr <= 0xC3FFFF) {
nation = "CA"
} else if (icao_addr >= 0x7C0000) && (icao_addr <= 0x7FFFFF) {
nation = "AU"
} else {
//TODO: future national decoding.
return "NON-NA", false
return "OTHER", false
}
if nation == "CA" { // Canada decoding
@ -1222,6 +1226,29 @@ func icao2reg(icao_addr uint32) (string, bool) {
tail = fmt.Sprintf("C-%c%c%c%c", b_str[b], c+65, d+65, e+65)
}
if nation == "AU" { // Australia decoding
nationalOffset := uint32(0x7C0000)
offset := (icao_addr - nationalOffset)
i1 := offset / 1296
offset2 := offset % 1296
i2 := offset2 / 36
offset3 := offset2 % 36
i3 := offset3
var a_char, b_char, c_char string
a_char = fmt.Sprintf("%c", i1+65)
b_char = fmt.Sprintf("%c", i2+65)
c_char = fmt.Sprintf("%c", i3+65)
if i1 < 0 || i1 > 25 || i2 < 0 || i2 > 25 || i3 < 0 || i3 > 25 {
return "OTHER", false
}
tail = "VH-" + a_char + b_char + c_char
}
if nation == "US" { // FAA decoding
// First, discard addresses that are not assigned to aircraft on the civil registry
if icao_addr > 0xADF7C7 {