kopia lustrzana https://github.com/cyoung/stratux
rodzic
ec3c5a6ab9
commit
e180f79855
|
@ -1082,7 +1082,7 @@ func icao2reg(icao_addr uint32) (string, bool) {
|
||||||
b_str := "FGI"
|
b_str := "FGI"
|
||||||
|
|
||||||
//fmt.Printf("B = %d, C = %d, D = %d, E = %d\n",b,c,d,e)
|
//fmt.Printf("B = %d, C = %d, D = %d, E = %d\n",b,c,d,e)
|
||||||
tail = fmt.Sprintf("C%c%c%c%c", b_str[b], c+65, d+65, e+65)
|
tail = fmt.Sprintf("C-%c%c%c%c", b_str[b], c+65, d+65, e+65)
|
||||||
}
|
}
|
||||||
|
|
||||||
if nation == "US" { // FAA decoding
|
if nation == "US" { // FAA decoding
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
icao2reg: Converts a 24-bit numeric value to a tail number of FAA
|
icao2reg: Converts a 24-bit numeric value to a tail number of FAA
|
||||||
or Canadian registry.
|
or Canadian registry.
|
||||||
|
|
||||||
(c) 2016 AvSquirrel
|
(c) 2016 AvSquirrel
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
@ -63,8 +63,7 @@ func icao2reg(icao_addr uint32) (string, bool) {
|
||||||
nationalOffset := uint32(0xA00001) // default is US
|
nationalOffset := uint32(0xA00001) // default is US
|
||||||
tail := ""
|
tail := ""
|
||||||
nation := ""
|
nation := ""
|
||||||
|
|
||||||
|
|
||||||
// Determine nationality
|
// Determine nationality
|
||||||
if (icao_addr >= 0xA00001) && (icao_addr <= 0xAFFFFF) {
|
if (icao_addr >= 0xA00001) && (icao_addr <= 0xAFFFFF) {
|
||||||
nation = "US"
|
nation = "US"
|
||||||
|
@ -75,43 +74,42 @@ func icao2reg(icao_addr uint32) (string, bool) {
|
||||||
return "NON-NA", false
|
return "NON-NA", false
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nation =="CA") { // Canada decoding
|
if nation == "CA" { // Canada decoding
|
||||||
// First, discard addresses that are not assigned to aircraft on the civil registry
|
// First, discard addresses that are not assigned to aircraft on the civil registry
|
||||||
if icao_addr > 0xC0CDF8 {
|
if icao_addr > 0xC0CDF8 {
|
||||||
//fmt.Printf("%X is a Canada aircraft, but not a CF-, CG-, or CI- registration.\n", icao_addr)
|
//fmt.Printf("%X is a Canada aircraft, but not a CF-, CG-, or CI- registration.\n", icao_addr)
|
||||||
return "CA-MIL", false
|
return "CA-MIL", false
|
||||||
}
|
}
|
||||||
|
|
||||||
nationalOffset := uint32(0xC00001)
|
nationalOffset := uint32(0xC00001)
|
||||||
serial := int32(icao_addr - nationalOffset)
|
serial := int32(icao_addr - nationalOffset)
|
||||||
|
|
||||||
// Fifth letter
|
// Fifth letter
|
||||||
e := serial % 26
|
e := serial % 26
|
||||||
|
|
||||||
// Fourth letter
|
// Fourth letter
|
||||||
d := (serial/26) % 26
|
d := (serial / 26) % 26
|
||||||
|
|
||||||
// Third letter
|
// Third letter
|
||||||
c := (serial/676) % 26 // 676 == 26*26
|
c := (serial / 676) % 26 // 676 == 26*26
|
||||||
|
|
||||||
// Second letter
|
// Second letter
|
||||||
b := (serial/17576) % 26 // 17576 == 26*26*26
|
b := (serial / 17576) % 26 // 17576 == 26*26*26
|
||||||
|
|
||||||
b_str :="FGI"
|
b_str := "FGI"
|
||||||
|
|
||||||
fmt.Printf("B = %d, C = %d, D = %d, E = %d\n",b,c,d,e)
|
fmt.Printf("B = %d, C = %d, D = %d, E = %d\n", b, c, d, e)
|
||||||
tail = fmt.Sprintf("C%c%c%c%c",b_str[b],c+65,d+65,e+65)
|
tail = fmt.Sprintf("C-%c%c%c%c", b_str[b], c+65, d+65, e+65)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nation == "US") { // FAA decoding
|
if nation == "US" { // FAA decoding
|
||||||
// First, discard addresses that are not assigned to aircraft on the civil registry
|
// First, discard addresses that are not assigned to aircraft on the civil registry
|
||||||
if icao_addr > 0xADF7C7 {
|
if icao_addr > 0xADF7C7 {
|
||||||
//fmt.Printf("%X is a US aircraft, but not on the civil registry.\n", icao_addr)
|
//fmt.Printf("%X is a US aircraft, but not on the civil registry.\n", icao_addr)
|
||||||
return "US-MIL", false
|
return "US-MIL", false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
serial := int32(icao_addr - nationalOffset)
|
||||||
serial := int32(icao_addr - nationalOffset)
|
|
||||||
// First digit
|
// First digit
|
||||||
a := (serial / 101711) + 1
|
a := (serial / 101711) + 1
|
||||||
|
|
||||||
|
@ -167,11 +165,9 @@ func icao2reg(icao_addr uint32) (string, bool) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
tail = "N" + a_char + b_char + c_char + d_char + e_char
|
tail = "N" + a_char + b_char + c_char + d_char + e_char
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return tail, true
|
return tail, true
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue