mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2026-09-12 09:39:30 +00:00
ADSB database update (tools, db) (#2701)
* enhance make_airlines_db tool * enhance make_icao24_db tool * update airlinescode (.txt, .db), aircraftdatabase/icao24 (.csv, .db)
This commit is contained in:
committed by
GitHub
parent
e26f77ee77
commit
c0aa4a1738
@@ -3,6 +3,5 @@
|
|||||||
Licensed under [GNU GPL v3](../../../LICENSE)
|
Licensed under [GNU GPL v3](../../../LICENSE)
|
||||||
|
|
||||||
USAGE:
|
USAGE:
|
||||||
- Copy file from: https://raw.githubusercontent.com/kx1t/planefence-airlinecodes/main/airlinecodes.txt
|
|
||||||
- Run Python 3 script: `./make_airlines_db.py`
|
- Run Python 3 script: `./make_airlines_db.py`
|
||||||
- Copy file to /ADSB folder on SDCARD
|
- Move file "airlines.db" to /ADSB folder on SDCARD
|
||||||
|
|||||||
@@ -325,7 +325,7 @@ AMT,ATA Airlines,,United States
|
|||||||
AMU,Air Macau,AIR MACAO,Macao
|
AMU,Air Macau,AIR MACAO,Macao
|
||||||
AMV,AMC Airlines,,Egypt
|
AMV,AMC Airlines,,Egypt
|
||||||
AMW,Air Midwest,,United States
|
AMW,Air Midwest,,United States
|
||||||
AMX,Aeroméxico,AEROMEXICO,Mexico
|
AMX,Aeromexico,AEROMEXICO,Mexico
|
||||||
AMY,Air Ambar,AIR AMBAR,Dominican Republic
|
AMY,Air Ambar,AIR AMBAR,Dominican Republic
|
||||||
AMZ,Amiya Airline,AMIYA AIR,Nigeria
|
AMZ,Amiya Airline,AMIYA AIR,Nigeria
|
||||||
ANA,All Nippon Airways,ALL NIPPON,Japan
|
ANA,All Nippon Airways,ALL NIPPON,Japan
|
||||||
@@ -408,7 +408,7 @@ ARC,Air Routing International Corp.,,United States
|
|||||||
ARD,Aerocondor,,Portugal
|
ARD,Aerocondor,,Portugal
|
||||||
ARE,Aires Aerovías de Integración Regional S.A.,AIRES,Colombia
|
ARE,Aires Aerovías de Integración Regional S.A.,AIRES,Colombia
|
||||||
ARF,Aero Flight,,Germany
|
ARF,Aero Flight,,Germany
|
||||||
ARG,Aerolíneas Argentinas,ARGENTINA,Argentina
|
ARG,Aerolineas Argentinas,ARGENTINA,Argentina
|
||||||
ARH,Aerohelicopteros,AEROHELCA,Venezuela
|
ARH,Aerohelicopteros,AEROHELCA,Venezuela
|
||||||
ARI,Aero Vics,AEROVICS,Mexico
|
ARI,Aero Vics,AEROVICS,Mexico
|
||||||
ARJ,Aerojet de Costa Rica S.A.,,Costa Rica
|
ARJ,Aerojet de Costa Rica S.A.,,Costa Rica
|
||||||
@@ -820,7 +820,7 @@ BNT,Bentiu Air Transport,BENTIU AIR,Sudan
|
|||||||
BNV,Benane Aviation Corporation,BENANE,Mauritania
|
BNV,Benane Aviation Corporation,BENANE,Mauritania
|
||||||
BNW,British North West Airlines,BRITISH NORTH,United Kingdom
|
BNW,British North West Airlines,BRITISH NORTH,United Kingdom
|
||||||
BNX,LAI - Línea Aérea IAACA,AIR BARINAS,Venezuela
|
BNX,LAI - Línea Aérea IAACA,AIR BARINAS,Venezuela
|
||||||
BNZ,Aerolíneas Bonanza,AERO BONANZA,Mexico
|
BNZ,Bonza,BONZA,Australia
|
||||||
BOA,Boniair,KUMANOVO,Macedonia
|
BOA,Boniair,KUMANOVO,Macedonia
|
||||||
BOB,Backbone A/S,BACKBONE,Denmark
|
BOB,Backbone A/S,BACKBONE,Denmark
|
||||||
BOC,Aerobona,AEROBONA,Mexico
|
BOC,Aerobona,AEROBONA,Mexico
|
||||||
@@ -1465,6 +1465,7 @@ DET,DETA Air,SAMAL,Kazakhstan
|
|||||||
DEV,Red Devils Parachute Display Team,RED DEVILS,United Kingdom
|
DEV,Red Devils Parachute Display Team,RED DEVILS,United Kingdom
|
||||||
DFA,Aero Coach Aviation,AERO COACH,United States
|
DFA,Aero Coach Aviation,AERO COACH,United States
|
||||||
DFC,Aeropartner,DARK BLUE,Czech Republic
|
DFC,Aeropartner,DARK BLUE,Czech Republic
|
||||||
|
DFL,Babcock AirAmbulance,MEDIFLIGHT,Sweden
|
||||||
DFS,Dwyer Aircraft Services,DWYAIR,United States
|
DFS,Dwyer Aircraft Services,DWYAIR,United States
|
||||||
DGA,Yellow River Delta General Aviation,YELLOW RIVER,China
|
DGA,Yellow River Delta General Aviation,YELLOW RIVER,China
|
||||||
DGO,DGO Jet,DGO JET,Mexico
|
DGO,DGO Jet,DGO JET,Mexico
|
||||||
@@ -1592,8 +1593,10 @@ DVA,Discovery Airways,DISCOVERY AIRWAYS,United States
|
|||||||
DVB,Don Avia,DONSEBAI,Kazakhstan
|
DVB,Don Avia,DONSEBAI,Kazakhstan
|
||||||
DVI,Aero Davinci International,AERO DAVINCI,Mexico
|
DVI,Aero Davinci International,AERO DAVINCI,Mexico
|
||||||
DVN,Adventia,,Spain
|
DVN,Adventia,,Spain
|
||||||
|
DVY,Legends Airways,DEVIL RAY,United States
|
||||||
DWA,Dense Airways,,United States
|
DWA,Dense Airways,,United States
|
||||||
DWD,Deutsche Luftverkehrsgesellschaft (DLT),,Germany
|
DWD,Deutsche Luftverkehrsgesellschaft (DLT),,Germany
|
||||||
|
DWI,Arajet,DOMINICAN,Dominican Republic
|
||||||
DWN,Dawn Air,DAWN AIR,United States
|
DWN,Dawn Air,DAWN AIR,United States
|
||||||
DWR,Delaware Skyways,DELAWARE,United States
|
DWR,Delaware Skyways,DELAWARE,United States
|
||||||
DWT,Darwin Airline,DARWIN,Switzerland
|
DWT,Darwin Airline,DARWIN,Switzerland
|
||||||
@@ -1905,6 +1908,7 @@ EZJ,Ezjet GT,GUYANA JET,Guyana
|
|||||||
EZS,easyJet Switzerland,TOPSWISS,Switzerland
|
EZS,easyJet Switzerland,TOPSWISS,Switzerland
|
||||||
EZX,Eagle Express Air Charter,EAGLEXPRESS,Malaysia
|
EZX,Eagle Express Air Charter,EAGLEXPRESS,Malaysia
|
||||||
EZY,easyJet UK,EASY,United Kingdom
|
EZY,easyJet UK,EASY,United Kingdom
|
||||||
|
EZZ,ETF Airways,ENTERPRIZE,Croatia
|
||||||
FAB,First Air,FIRST AIR,Canada
|
FAB,First Air,FIRST AIR,Canada
|
||||||
FAC,Atlantic Helicopters,FAROECOPTER,Denmark
|
FAC,Atlantic Helicopters,FAROECOPTER,Denmark
|
||||||
FAD,Rog-Air,AIR FRONTIER,Canada
|
FAD,Rog-Air,AIR FRONTIER,Canada
|
||||||
@@ -2034,7 +2038,7 @@ FJI,Fiji Airways,PACIFIC,Fiji
|
|||||||
FJK,Fly Jet Kz,,Kazakhstan
|
FJK,Fly Jet Kz,,Kazakhstan
|
||||||
FJM,Fly Jamaica Airways,GREENHEART,Jamaica
|
FJM,Fly Jamaica Airways,GREENHEART,Jamaica
|
||||||
FJO,Flexjet Operations Malta Limited,FLEX MALTA,Malta
|
FJO,Flexjet Operations Malta Limited,FLEX MALTA,Malta
|
||||||
FRJ,Fly Jordan,SOLITAIRE AIR,Jordan
|
FJR,Fly Jordan,SOLITAIRE AIR,Jordan
|
||||||
FJS,Florida Jet Service,FLORIDAJET,United States
|
FJS,Florida Jet Service,FLORIDAJET,United States
|
||||||
FKA,Flying kangaroo Airline,,Australia
|
FKA,Flying kangaroo Airline,,Australia
|
||||||
FKI,FLM Aviation Mohrdieck,KIEL AIR,Germany
|
FKI,FLM Aviation Mohrdieck,KIEL AIR,Germany
|
||||||
@@ -2397,7 +2401,7 @@ GPL,DLR,GERMAN POLAR,Germany
|
|||||||
GPM,Grup Air-Med,GRUPOMED,Spain
|
GPM,Grup Air-Med,GRUPOMED,Spain
|
||||||
GPR,GPM Aeroservicio,GPM AEROSERVICIO,Mexico
|
GPR,GPM Aeroservicio,GPM AEROSERVICIO,Mexico
|
||||||
GPX,GP Aviation,,Bulgaria
|
GPX,GP Aviation,,Bulgaria
|
||||||
GRA,Guardian Air Asset Management,FLEX,South Africa
|
GRA,Costa Rica Green Airways,,,Costa Rica
|
||||||
GRB,Phoenix Air Group,GREY BIRD,United States
|
GRB,Phoenix Air Group,GREY BIRD,United States
|
||||||
GRD,National Grid plc,GRID,United Kingdom
|
GRD,National Grid plc,GRID,United Kingdom
|
||||||
GRE,Air Scotland,GREECE AIRWAYS,Greece
|
GRE,Air Scotland,GREECE AIRWAYS,Greece
|
||||||
@@ -2459,7 +2463,7 @@ GWN,Gwyn Aviation,GWYN,United Kingdom
|
|||||||
GWR,Aura Airlines,LEMON,Spain
|
GWR,Aura Airlines,LEMON,Spain
|
||||||
GWS,General Airways,GENAIR,South Africa
|
GWS,General Airways,GENAIR,South Africa
|
||||||
GWY,USA3000 Airlines,GETAWAY,United States
|
GWY,USA3000 Airlines,GETAWAY,United States
|
||||||
GXA,Grixona,GRIXONA,Moldova
|
GXA,GlobalX Airlines,GEMINI,United States
|
||||||
GXG,GermanXL,,Germany
|
GXG,GermanXL,,Germany
|
||||||
GXL,Star XL German Airlines,STARDUST,Germany
|
GXL,Star XL German Airlines,STARDUST,Germany
|
||||||
GXY,Galaxy Airlines,GALAX,Japan
|
GXY,Galaxy Airlines,GALAX,Japan
|
||||||
@@ -2608,6 +2612,7 @@ HMC,Heliamerica De Mexico,HELIAMERICA,Mexico
|
|||||||
HMD,Charlie Hammonds Flying Service,HAMMOND,United States
|
HMD,Charlie Hammonds Flying Service,HAMMOND,United States
|
||||||
HME,Babcock MCS,HELIMED,United Kingdom
|
HME,Babcock MCS,HELIMED,United Kingdom
|
||||||
HMF,Norrlandsflyg,LIFEGUARD SWEDEN,Sweden
|
HMF,Norrlandsflyg,LIFEGUARD SWEDEN,Sweden
|
||||||
|
HMJ,Harmony Jets,HARMONG JETS,Malta
|
||||||
HMM,Hamra Air,HAMRA,United Arab Emirates
|
HMM,Hamra Air,HAMRA,United Arab Emirates
|
||||||
HMP,Papair Terminal,PAPAIR TERMINAL,Haiti
|
HMP,Papair Terminal,PAPAIR TERMINAL,Haiti
|
||||||
HMR,North American Charters,HAMMER,Canada
|
HMR,North American Charters,HAMMER,Canada
|
||||||
@@ -2623,6 +2628,7 @@ HNR,Haiti National Airlines (HANA),HANAIR,Haiti
|
|||||||
HNT,Helicopteros Internacionales,HELICOP INTER,Mexico
|
HNT,Helicopteros Internacionales,HELICOP INTER,Mexico
|
||||||
HNX,Hankook Airline,,South Korea
|
HNX,Hankook Airline,,South Korea
|
||||||
HOA,Hola Airlines,HOLA,Spain
|
HOA,Hola Airlines,HOLA,Spain
|
||||||
|
HOB,HL Aircraft LLC,HOBBY JET,United States
|
||||||
HOG,Mahogany Air Charters,HOGAN AIR,Zambia
|
HOG,Mahogany Air Charters,HOGAN AIR,Zambia
|
||||||
HOL,Holiday Airlines (US Airline),HOLIDAY,United States
|
HOL,Holiday Airlines (US Airline),HOLIDAY,United States
|
||||||
HOM,Aero Homex,AERO HOMEX,Mexico
|
HOM,Aero Homex,AERO HOMEX,Mexico
|
||||||
@@ -3077,7 +3083,7 @@ JSM,Jet Stream,,Moldova
|
|||||||
JSN,Suncor Energy Inc,JETSUN,Canada
|
JSN,Suncor Energy Inc,JETSUN,Canada
|
||||||
JSP,Palmer Aviation,PALMER,United Kingdom
|
JSP,Palmer Aviation,PALMER,United Kingdom
|
||||||
JSR,Jusur airways,,Egypt
|
JSR,Jusur airways,,Egypt
|
||||||
JST,Eastern Australia Airlines,,Australia
|
JST,Jetstar Airways,,Australia
|
||||||
JSV,Japan Aircraft Service,,Japan
|
JSV,Japan Aircraft Service,,Japan
|
||||||
JSW,Jigsaw Project,,United Kingdom
|
JSW,Jigsaw Project,,United Kingdom
|
||||||
JSX,JetSuiteX Air,BIGSTRIPE,United States
|
JSX,JetSuiteX Air,BIGSTRIPE,United States
|
||||||
@@ -3617,6 +3623,7 @@ MAK,MAT Macedonian Airlines,MAKAVIO,Macedonia
|
|||||||
MAL,Morningstar Air Express,MORNINGSTAR,Canada
|
MAL,Morningstar Air Express,MORNINGSTAR,Canada
|
||||||
MAM,Aeródromo De La Mancha,AEROMAN,Spain
|
MAM,Aeródromo De La Mancha,AEROMAN,Spain
|
||||||
MAN,Mannion Air Charter,MANNION,United States
|
MAN,Mannion Air Charter,MANNION,United States
|
||||||
|
MAO,Mayo Clinic,MAYO,United States
|
||||||
MAQ,Mac Aviation,MAC AVIATION,Spain
|
MAQ,Mac Aviation,MAC AVIATION,Spain
|
||||||
MAR,March Helicopters,MARCH,United Kingdom
|
MAR,March Helicopters,MARCH,United Kingdom
|
||||||
MAS,Malaysia Airlines,MALAYSIAN,Malaysia
|
MAS,Malaysia Airlines,MALAYSIAN,Malaysia
|
||||||
@@ -3633,6 +3640,7 @@ MBC,Airjet Exploracao Aerea de Carga,MABECO,Angola
|
|||||||
MBE,Martin-Baker,MARTIN,United Kingdom
|
MBE,Martin-Baker,MARTIN,United Kingdom
|
||||||
MBG,Zephyr Aviation,CHALGROVE,United Kingdom
|
MBG,Zephyr Aviation,CHALGROVE,United Kingdom
|
||||||
MBI,Mountain Bird,MOUNTAIN BIRD,United States
|
MBI,Mountain Bird,MOUNTAIN BIRD,United States
|
||||||
|
MBK,Chrono Jet,MATBLACK,Canada
|
||||||
MBL,First City Air,FIRST CITY,United Kingdom
|
MBL,First City Air,FIRST CITY,United Kingdom
|
||||||
MBN,Zambian Airways,ZAMBIANA,Zambia
|
MBN,Zambian Airways,ZAMBIANA,Zambia
|
||||||
MBO,Mobil Oil,MOBIL,Canada
|
MBO,Mobil Oil,MOBIL,Canada
|
||||||
@@ -4441,6 +4449,7 @@ PDI,Paradise Island Airways,PARADISE ISLAND,United States
|
|||||||
PDQ,PDQ Air Charter,DISPATCH,United States
|
PDQ,PDQ Air Charter,DISPATCH,United States
|
||||||
PDR,COMAV,SPEEDSTER,Namibia
|
PDR,COMAV,SPEEDSTER,Namibia
|
||||||
PDT,Piedmont Airlines,PIEDMONT,United States
|
PDT,Piedmont Airlines,PIEDMONT,United States
|
||||||
|
PDU,Purdue University,PURDUE,United States
|
||||||
PDV,Elicar,ELICAR,Italy
|
PDV,Elicar,ELICAR,Italy
|
||||||
PDY,Pen-Avia,PENDLEY,United Kingdom
|
PDY,Pen-Avia,PENDLEY,United Kingdom
|
||||||
PEA,Pan Europeenne Air Service,,France
|
PEA,Pan Europeenne Air Service,,France
|
||||||
@@ -4564,6 +4573,7 @@ PNH,Panh,KUBAN LIK,Russia
|
|||||||
PNK,Air Pink,AIRPINK,Serbia
|
PNK,Air Pink,AIRPINK,Serbia
|
||||||
PNL,Aero Personal,AEROPERSONAL,Mexico
|
PNL,Aero Personal,AEROPERSONAL,Mexico
|
||||||
PNM,Panorama,PANORAMA,Spain
|
PNM,Panorama,PANORAMA,Spain
|
||||||
|
PNO,Panorama Aviation,PANO,Canada
|
||||||
PNP,Pineapple Air,PINEAPPLE AIR,Bahamas
|
PNP,Pineapple Air,PINEAPPLE AIR,Bahamas
|
||||||
PNR,PAN Air,SKYJET,Spain
|
PNR,PAN Air,SKYJET,Spain
|
||||||
PNS,Survey Udara (Penas),PENAS,Indonesia
|
PNS,Survey Udara (Penas),PENAS,Indonesia
|
||||||
@@ -4931,6 +4941,7 @@ RNB,Rosneft-Baltika,ROSBALT,Russia
|
|||||||
RND,Rutland Aviation,RUTLAND,United Kingdom
|
RND,Rutland Aviation,RUTLAND,United Kingdom
|
||||||
RNE,Air Salone,AIR SALONE,Sierra Leone
|
RNE,Air Salone,AIR SALONE,Sierra Leone
|
||||||
RNG,Orange Aircraft Leasing,ORANGE,Netherlands
|
RNG,Orange Aircraft Leasing,ORANGE,Netherlands
|
||||||
|
RNI,Rennia Aviation,RENNIA,United States
|
||||||
RNM,Aeronem Air Cargo,AEROMNEM,Ecuador
|
RNM,Aeronem Air Cargo,AEROMNEM,Ecuador
|
||||||
RNR,Air Cargo Masters,RUNNER,United States
|
RNR,Air Cargo Masters,RUNNER,United States
|
||||||
RNS,Ronso,RONSO,Mexico
|
RNS,Ronso,RONSO,Mexico
|
||||||
@@ -5216,6 +5227,7 @@ SFU,Solent Flight,SAINTS,United Kingdom
|
|||||||
SFW,Safi Airways,SAFI,AF
|
SFW,Safi Airways,SAFI,AF
|
||||||
SFX,S.K. Logistics,SWAMP FOX,United States
|
SFX,S.K. Logistics,SWAMP FOX,United States
|
||||||
SFY,Gulf Flite Center,SKY FLITE,United States
|
SFY,Gulf Flite Center,SKY FLITE,United States
|
||||||
|
SFZ,Pionair,SKYFORCE,Australia
|
||||||
SGA,Air Saigon,AIR SAIGON,Vietnam
|
SGA,Air Saigon,AIR SAIGON,Vietnam
|
||||||
SGB,Sky King Inc.,SONGBIRD,United States
|
SGB,Sky King Inc.,SONGBIRD,United States
|
||||||
SGC,SGC Aviation,SAINT GEORGE,Austria
|
SGC,SGC Aviation,SAINT GEORGE,Austria
|
||||||
@@ -5270,7 +5282,7 @@ SIE,Sierra Express,SEREX,United States
|
|||||||
SIH,Skynet Airlines,BLUEJET,Ireland
|
SIH,Skynet Airlines,BLUEJET,Ireland
|
||||||
SII,Aero Servicios Ejecutivos Internacionales,ASEISA,Mexico
|
SII,Aero Servicios Ejecutivos Internacionales,ASEISA,Mexico
|
||||||
SIJ,Seco International,,Japan
|
SIJ,Seco International,,Japan
|
||||||
SIL,Servicios Aeronáuticos Integrales,SERVICIOS INTEGRALES,Mexico
|
SIL,Silver Airways,SILVER WINGS,United States
|
||||||
SIM,Star Air,,Sierra Leone
|
SIM,Star Air,,Sierra Leone
|
||||||
SIO,Sirio,SIRIO,Italy
|
SIO,Sirio,SIRIO,Italy
|
||||||
SIP,Air Spirit,AIR SPIRIT,United States
|
SIP,Air Spirit,AIR SPIRIT,United States
|
||||||
@@ -5802,6 +5814,7 @@ TKC,Tikal Jets Airlines,TIKAL,Guatemala
|
|||||||
TKE,Take Air Line,ISLAND BIRD,France
|
TKE,Take Air Line,ISLAND BIRD,France
|
||||||
TKJ,Tarkim Aviation,TARKIM AVIATION,Turkey
|
TKJ,Tarkim Aviation,TARKIM AVIATION,Turkey
|
||||||
TKK,FlyADVANCED,,United States
|
TKK,FlyADVANCED,,United States
|
||||||
|
TKM,JM Family Aviation,TACOMA,United States
|
||||||
TKR,Canadian Interagency Forest Fire Centre,TANKER,Canada
|
TKR,Canadian Interagency Forest Fire Centre,TANKER,Canada
|
||||||
TKS,Tomsk-Avia,,Russia
|
TKS,Tomsk-Avia,,Russia
|
||||||
TKX,Tropical International Airways,TROPEXPRESS,Saint Kitts and Nevis
|
TKX,Tropical International Airways,TROPEXPRESS,Saint Kitts and Nevis
|
||||||
@@ -5827,6 +5840,7 @@ TLW,Teamline Air,Teamline,Austria
|
|||||||
TLX,Telesis Transair,TELESIS,United States
|
TLX,Telesis Transair,TELESIS,United States
|
||||||
TLY,Top Fly,TOPFLY,Spain
|
TLY,Top Fly,TOPFLY,Spain
|
||||||
TMA,Trans Mediterranean Airlines,TANGO LIMA,Lebanon
|
TMA,Trans Mediterranean Airlines,TANGO LIMA,Lebanon
|
||||||
|
TMB,Volato,TOMBO,United States
|
||||||
TMC,Travel Management Company,TRAIL BLAZER,United States
|
TMC,Travel Management Company,TRAIL BLAZER,United States
|
||||||
TMD,Transmandu,TRANSMANDU,Venezuela
|
TMD,Transmandu,TRANSMANDU,Venezuela
|
||||||
TME,Aero Taxi del Centro de Mexico,TAXICENTRO,Mexico
|
TME,Aero Taxi del Centro de Mexico,TAXICENTRO,Mexico
|
||||||
@@ -6086,6 +6100,7 @@ UDC,DonbassAero,DONBASS AERO,Ukraine
|
|||||||
UDN,Dniproavia,DNIEPRO,Ukraine
|
UDN,Dniproavia,DNIEPRO,Ukraine
|
||||||
UEA,United Eagle Airlines,UNITED EAGLE,China
|
UEA,United Eagle Airlines,UNITED EAGLE,China
|
||||||
UED,Air LA,AIR L-A,United States
|
UED,Air LA,AIR L-A,United States
|
||||||
|
UEE,United Eagle,EAGLE SLOVENIA,Slovenia
|
||||||
UEJ,Jetcorp,,United States
|
UEJ,Jetcorp,,United States
|
||||||
UES,Ues-Avia Aircompany,AVIASYSTEM,Ukraine
|
UES,Ues-Avia Aircompany,AVIASYSTEM,Ukraine
|
||||||
UEU,United European Airlines,UNITED EUROPEAN,Romania
|
UEU,United European Airlines,UNITED EUROPEAN,Romania
|
||||||
@@ -6200,7 +6215,7 @@ VAL,Voyageur Airways,VOYAGEUR,Canada
|
|||||||
VAM,Ameravia,AMERAVIA,Uruguay
|
VAM,Ameravia,AMERAVIA,Uruguay
|
||||||
VAN,Caravan Air,CAMEL,Mauritania
|
VAN,Caravan Air,CAMEL,Mauritania
|
||||||
VAP,Phuket Air,PHUKET AIR,Thailand
|
VAP,Phuket Air,PHUKET AIR,Thailand
|
||||||
VAR,Veca Airlines,VECA,El Salvador
|
VAR,United Aviate Academy,VARNEY,United States
|
||||||
VAS,ATRAN Cargo Airlines,ATRAN,Russian Federation
|
VAS,ATRAN Cargo Airlines,ATRAN,Russian Federation
|
||||||
VAT,Visionair,VISIONAIR,Ireland
|
VAT,Visionair,VISIONAIR,Ireland
|
||||||
VAU,V Australia Airlines,,Australia
|
VAU,V Australia Airlines,,Australia
|
||||||
@@ -6278,7 +6293,7 @@ VIS,Vision Air International,,Pakistan
|
|||||||
VIT,Aviastar Mandiri,AVIASTAR,Indonesia
|
VIT,Aviastar Mandiri,AVIASTAR,Indonesia
|
||||||
VIV,Aeroenlaces Nacionales,AEROENLACES,Mexico
|
VIV,Aeroenlaces Nacionales,AEROENLACES,Mexico
|
||||||
VIZ,Aerovis Airlines,AEROVIZ,Ukraine
|
VIZ,Aerovis Airlines,AEROVIZ,Ukraine
|
||||||
VJA,ValuJet Airlines,CRITTER,United States
|
VJA,Vista America,ICONIC,United States
|
||||||
VJC,Vietjet Air,VIETJET,Vietnam
|
VJC,Vietjet Air,VIETJET,Vietnam
|
||||||
VJE,AvJet Routing,,United Arab Emirates
|
VJE,AvJet Routing,,United Arab Emirates
|
||||||
VJM,Viajes Ejecutivos Mexicanos,VIAJES MEXICANOS,Mexico
|
VJM,Viajes Ejecutivos Mexicanos,VIAJES MEXICANOS,Mexico
|
||||||
@@ -6320,7 +6335,7 @@ VNG,Aero Servicios Vanguardia,VANGUARDIA,Mexico
|
|||||||
VNK,Vipport Joint Stock Company,,Russia
|
VNK,Vipport Joint Stock Company,,Russia
|
||||||
VNL,Vanilla Air,VANILLA,Japan
|
VNL,Vanilla Air,VANILLA,Japan
|
||||||
VNP,Virgin Pacific,,Fiji
|
VNP,Virgin Pacific,,Fiji
|
||||||
VNT,Avient Air Zambia,AVIENT,Zambia
|
VNT,Ventura,VENTURA,United States
|
||||||
VNX,Fly Advance,VANCE,United States
|
VNX,Fly Advance,VANCE,United States
|
||||||
VNZ,Tbilaviamsheni,TBILAVIA,Georgia
|
VNZ,Tbilaviamsheni,TBILAVIA,Georgia
|
||||||
VOA,Viaggio Air,VIAGGIO,Bulgaria
|
VOA,Viaggio Air,VIAGGIO,Bulgaria
|
||||||
@@ -6331,7 +6346,7 @@ VOI,Volaris,VOLARIS,Mexico
|
|||||||
VOL,Blue Chip Jet,BLUE SPEED,Sweden
|
VOL,Blue Chip Jet,BLUE SPEED,Sweden
|
||||||
VOO,Volotea,,Spain
|
VOO,Volotea,,Spain
|
||||||
VOR,Flight Calibration Services Ltd.,FLIGHT CAL,United Kingdom
|
VOR,Flight Calibration Services Ltd.,FLIGHT CAL,United Kingdom
|
||||||
VOS,Rovos Air,ROVOS,South Africa
|
VOS,Volaris El Salvador,JETSAL,South Africa
|
||||||
VOZ,Virgin Australia,VELOCITY,Australia
|
VOZ,Virgin Australia,VELOCITY,Australia
|
||||||
VPA,DanubeWings,VIP TAXI,Slovakia
|
VPA,DanubeWings,VIP TAXI,Slovakia
|
||||||
VPB,Veteran Air,VETERAN,Ukraine
|
VPB,Veteran Air,VETERAN,Ukraine
|
||||||
@@ -6422,7 +6437,7 @@ WAU,Wizz Air Ukraine,,Ukraine
|
|||||||
WAV,Warbelow's Air Ventures,WARBELOW,United States
|
WAV,Warbelow's Air Ventures,WARBELOW,United States
|
||||||
WAW,Wings Airways,WING SHUTTLE,United States
|
WAW,Wings Airways,WING SHUTTLE,United States
|
||||||
WAY,Airways,GARONNE,France
|
WAY,Airways,GARONNE,France
|
||||||
WAZ,Wizz Air,WIZZ SKY,United Arab Emirates
|
WAZ,Wizz Air Abu Dabi,WIZZ SKY,United Arab Emirates
|
||||||
WBA,Finncomm Airlines,WESTBIRD,Finland
|
WBA,Finncomm Airlines,WESTBIRD,Finland
|
||||||
WBR,Multi-Aero,WEBER,United States
|
WBR,Multi-Aero,WEBER,United States
|
||||||
WCA,West Coast Airways,WEST-LEONE,Sierra Leone
|
WCA,West Coast Airways,WEST-LEONE,Sierra Leone
|
||||||
@@ -6499,6 +6514,8 @@ WLX,West Air Luxembourg,WEST LUX,Luxembourg
|
|||||||
WMA,Watermakers Air,WATERMAKERS,United States
|
WMA,Watermakers Air,WATERMAKERS,United States
|
||||||
WML,Chantilly Air,MARLIN,United States
|
WML,Chantilly Air,MARLIN,United States
|
||||||
WMN,Trident Aircraft,WATERMAN,United States
|
WMN,Trident Aircraft,WATERMAN,United States
|
||||||
|
WMT,Wizz Air Malta,WIZZAIR MALTA,Malta
|
||||||
|
WMU,W.M. Uni. College of Aviation,SKYBRONCO,United States
|
||||||
WNA,Winair,WINAIR,United States
|
WNA,Winair,WINAIR,United States
|
||||||
WNR,Wondair on Demand Aviation,WONDAIR,Spain
|
WNR,Wondair on Demand Aviation,WONDAIR,Spain
|
||||||
WOA,World Airways,WORLD,United States
|
WOA,World Airways,WORLD,United States
|
||||||
@@ -6535,6 +6552,7 @@ WTP,Westpoint Air,WESTPOINT,Canada
|
|||||||
WTV,Western Aviators,WESTAVIA,United States
|
WTV,Western Aviators,WESTAVIA,United States
|
||||||
WUE,Adolf Wurth GmbH,FASTY,Germany
|
WUE,Adolf Wurth GmbH,FASTY,Germany
|
||||||
WUK,Wizz Air UK,WIZZ GO,United Kingdom
|
WUK,Wizz Air UK,WIZZ GO,United Kingdom
|
||||||
|
WUP,Wheels Up,UPJET,United States
|
||||||
WVA,Hand D Aviation,WABASH VALLEY,United States
|
WVA,Hand D Aviation,WABASH VALLEY,United States
|
||||||
WVL,Wizz Air Bulgaria,WIZZBUL,Bulgaria
|
WVL,Wizz Air Bulgaria,WIZZBUL,Bulgaria
|
||||||
WVZ,Winair,,HR
|
WVZ,Winair,,HR
|
||||||
@@ -6548,7 +6566,7 @@ WYC,Wycombe Air Centre,WYCOMBE,United Kingdom
|
|||||||
WYG,Wyoming Airlines,WYOMING,United States
|
WYG,Wyoming Airlines,WYOMING,United States
|
||||||
WYT,2 Sqn No 1 Elementary Flying Training School,WYTON,United Kingdom
|
WYT,2 Sqn No 1 Elementary Flying Training School,WYTON,United Kingdom
|
||||||
WZP,Zip,ZIPPER,Canada
|
WZP,Zip,ZIPPER,Canada
|
||||||
WZZ,Wizz Air,WIZZAIR,Hungary
|
WZZ,Wizz Air Hungary,WIZZAIR,Hungary
|
||||||
X9F,FRA Air,,Germany
|
X9F,FRA Air,,Germany
|
||||||
XAA,Aeronautical Radio Inc,,United States
|
XAA,Aeronautical Radio Inc,,United States
|
||||||
XAB,Xabre Aerolineas,AERO XABRE,Mexico
|
XAB,Xabre Aerolineas,AERO XABRE,Mexico
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# Copyright (C) 2021 ArjanOnwezen
|
# Copyright (C) 2021 ArjanOnwezen
|
||||||
|
# Copyright (C) 2025 Tommaso Ventafridda
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -22,26 +23,251 @@
|
|||||||
# as a source.
|
# as a source.
|
||||||
# -------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------
|
||||||
import csv
|
import csv
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
import unicodedata
|
import unicodedata
|
||||||
icao_codes=bytearray()
|
import urllib.request
|
||||||
airlines_countries=bytearray()
|
from dataclasses import dataclass
|
||||||
row_count=0
|
from typing import Dict, Set, Tuple
|
||||||
database=open("airlines.db", "wb")
|
|
||||||
with open('airlinecodes.txt', 'rt', encoding="utf-8") as csv_file:
|
|
||||||
sorted_lines=sorted(csv_file.readlines()[1:])
|
|
||||||
for row in csv.reader(sorted_lines, quotechar='"', delimiter=',', quoting=csv.QUOTE_ALL, skipinitialspace=True):
|
|
||||||
icao_code=row[0]
|
|
||||||
# Normalize some unicode characters
|
|
||||||
airline=unicodedata.normalize('NFKD', row[1][:32]).encode('ascii', 'ignore')
|
|
||||||
country=unicodedata.normalize('NFKD', row[3][:32]).encode('ascii', 'ignore')
|
|
||||||
if len(icao_code) == 3 :
|
|
||||||
airline_padding=bytearray()
|
|
||||||
country_padding=bytearray()
|
|
||||||
icao_codes=icao_codes+bytearray(icao_code+'\0', encoding='ascii')
|
|
||||||
airline_padding=bytearray('\0' * (32 - len(airline)), encoding='ascii')
|
|
||||||
country_padding=bytearray('\0' * (32 - len(country)), encoding='ascii')
|
|
||||||
airlines_countries=airlines_countries+bytearray(airline+airline_padding+country+country_padding)
|
|
||||||
row_count+=1
|
|
||||||
database.write(icao_codes+airlines_countries)
|
|
||||||
print("Total of", row_count, "ICAO codes stored in database")
|
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class AirlineRecord:
|
||||||
|
"""Represents an airline record with all relevant fields"""
|
||||||
|
|
||||||
|
icao_code: str
|
||||||
|
airline: str
|
||||||
|
country: str
|
||||||
|
|
||||||
|
def __hash__(self):
|
||||||
|
return hash(self.icao_code)
|
||||||
|
|
||||||
|
def __eq__(self, other):
|
||||||
|
if not isinstance(other, AirlineRecord):
|
||||||
|
return False
|
||||||
|
return self.icao_code == other.icao_code
|
||||||
|
|
||||||
|
def data_equals(self, other):
|
||||||
|
"""Check if all data fields are equal (excluding ICAO code which is the key)"""
|
||||||
|
if not isinstance(other, AirlineRecord):
|
||||||
|
return False
|
||||||
|
return self.airline == other.airline and self.country == other.country
|
||||||
|
|
||||||
|
|
||||||
|
def backup_previous_file() -> bool:
|
||||||
|
"""Backup the existing airlinecodes.txt file if it exists. Returns True if backup was made."""
|
||||||
|
if os.path.exists("airlinecodes.txt"):
|
||||||
|
shutil.copy2("airlinecodes.txt", "airlinecodes_previous.txt")
|
||||||
|
print("Backed up previous airline codes file")
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def download_airline_codes() -> None:
|
||||||
|
"""Download the airline codes file from GitHub"""
|
||||||
|
url = "https://raw.githubusercontent.com/kx1t/planefence-airlinecodes/main/airlinecodes.txt"
|
||||||
|
print(f"Downloading airline codes database from {url}...")
|
||||||
|
try:
|
||||||
|
urllib.request.urlretrieve(url, "airlinecodes.txt")
|
||||||
|
print("Download completed successfully.")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error downloading airline codes file: {e}")
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
def parse_airline_file(filename: str) -> Dict[str, AirlineRecord]:
|
||||||
|
"""Parse airline codes file and return a dictionary of records"""
|
||||||
|
records = {}
|
||||||
|
|
||||||
|
if not os.path.exists(filename):
|
||||||
|
return records
|
||||||
|
|
||||||
|
try:
|
||||||
|
with open(filename, "rt", encoding="utf-8") as csv_file:
|
||||||
|
sorted_lines = sorted(csv_file.readlines()[1:])
|
||||||
|
for row in csv.reader(
|
||||||
|
sorted_lines,
|
||||||
|
quotechar='"',
|
||||||
|
delimiter=",",
|
||||||
|
quoting=csv.QUOTE_ALL,
|
||||||
|
skipinitialspace=True,
|
||||||
|
):
|
||||||
|
if len(row) >= 4: # Ensure we have enough columns
|
||||||
|
icao_code = row[0]
|
||||||
|
# Normalize some unicode characters
|
||||||
|
airline = (
|
||||||
|
unicodedata.normalize("NFKD", row[1][:32])
|
||||||
|
.encode("ascii", "ignore")
|
||||||
|
.decode("ascii")
|
||||||
|
)
|
||||||
|
country = (
|
||||||
|
unicodedata.normalize("NFKD", row[3][:32])
|
||||||
|
.encode("ascii", "ignore")
|
||||||
|
.decode("ascii")
|
||||||
|
)
|
||||||
|
|
||||||
|
if len(icao_code) == 3:
|
||||||
|
records[icao_code] = AirlineRecord(
|
||||||
|
icao_code=icao_code, airline=airline, country=country
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Warning: Could not parse airline file {filename}: {e}")
|
||||||
|
return {}
|
||||||
|
|
||||||
|
return records
|
||||||
|
|
||||||
|
|
||||||
|
def compare_records(
|
||||||
|
old_records: Dict[str, AirlineRecord], new_records: Dict[str, AirlineRecord]
|
||||||
|
) -> Tuple[Set[str], Set[str], Set[str]]:
|
||||||
|
"""Compare old and new records, return sets of new, deleted, and changed ICAO codes"""
|
||||||
|
old_keys = set(old_records.keys())
|
||||||
|
new_keys = set(new_records.keys())
|
||||||
|
|
||||||
|
new_icao_codes = new_keys - old_keys
|
||||||
|
deleted_icao_codes = old_keys - new_keys
|
||||||
|
|
||||||
|
# Check for changes in existing records
|
||||||
|
changed_icao_codes = set()
|
||||||
|
for icao in old_keys & new_keys:
|
||||||
|
if not old_records[icao].data_equals(new_records[icao]):
|
||||||
|
changed_icao_codes.add(icao)
|
||||||
|
|
||||||
|
return new_icao_codes, deleted_icao_codes, changed_icao_codes
|
||||||
|
|
||||||
|
|
||||||
|
def write_database(records: Dict[str, AirlineRecord]) -> int:
|
||||||
|
"""Write records to database file using original format"""
|
||||||
|
icao_codes = bytearray()
|
||||||
|
airlines_countries = bytearray()
|
||||||
|
row_count = 0
|
||||||
|
|
||||||
|
# Sort by ICAO code for consistency
|
||||||
|
sorted_records = sorted(records.values(), key=lambda r: r.icao_code)
|
||||||
|
|
||||||
|
for record in sorted_records:
|
||||||
|
# Normalize and encode data (same as original)
|
||||||
|
airline = unicodedata.normalize("NFKD", record.airline[:32]).encode(
|
||||||
|
"ascii", "ignore"
|
||||||
|
)
|
||||||
|
country = unicodedata.normalize("NFKD", record.country[:32]).encode(
|
||||||
|
"ascii", "ignore"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Add ICAO code with null terminator (original format)
|
||||||
|
icao_codes = icao_codes + bytearray(record.icao_code + "\0", encoding="ascii")
|
||||||
|
|
||||||
|
# Add padded data fields (original format)
|
||||||
|
airline_padding = bytearray("\0" * (32 - len(airline)), encoding="ascii")
|
||||||
|
country_padding = bytearray("\0" * (32 - len(country)), encoding="ascii")
|
||||||
|
|
||||||
|
airlines_countries = airlines_countries + bytearray(
|
||||||
|
airline + airline_padding + country + country_padding
|
||||||
|
)
|
||||||
|
row_count += 1
|
||||||
|
|
||||||
|
with open("airlines.db", "wb") as database:
|
||||||
|
database.write(icao_codes + airlines_countries)
|
||||||
|
|
||||||
|
return row_count
|
||||||
|
|
||||||
|
|
||||||
|
def create_database() -> None:
|
||||||
|
"""Create the airline database from the downloaded file"""
|
||||||
|
# Backup existing file before downloading new one
|
||||||
|
has_previous = backup_previous_file()
|
||||||
|
|
||||||
|
# Download new file
|
||||||
|
download_airline_codes()
|
||||||
|
|
||||||
|
# Parse both files for comparison
|
||||||
|
old_records = {}
|
||||||
|
if has_previous:
|
||||||
|
print("Parsing previous airline codes file...")
|
||||||
|
old_records = parse_airline_file("airlinecodes_previous.txt")
|
||||||
|
print(f"Found {len(old_records)} records in previous file")
|
||||||
|
|
||||||
|
print("Parsing new airline codes file...")
|
||||||
|
new_records = parse_airline_file("airlinecodes.txt")
|
||||||
|
print(f"Found {len(new_records)} records in new file")
|
||||||
|
|
||||||
|
# Compare records if we have a previous version
|
||||||
|
if old_records:
|
||||||
|
new_icao_codes, deleted_icao_codes, changed_icao_codes = compare_records(
|
||||||
|
old_records, new_records
|
||||||
|
)
|
||||||
|
|
||||||
|
# Print change statistics
|
||||||
|
print("\n" + "=" * 50)
|
||||||
|
print("AIRLINE CODES CHANGE SUMMARY")
|
||||||
|
print("=" * 50)
|
||||||
|
print(f"New records: {len(new_icao_codes):>8}")
|
||||||
|
print(f"Deleted records: {len(deleted_icao_codes):>8}")
|
||||||
|
print(f"Changed records: {len(changed_icao_codes):>8}")
|
||||||
|
print(f"Total records: {len(new_records):>8}")
|
||||||
|
print("=" * 50)
|
||||||
|
|
||||||
|
# Show examples of changes (limited to avoid spam)
|
||||||
|
if new_icao_codes and len(new_icao_codes) <= 15:
|
||||||
|
print(f"\nNew ICAO codes: {', '.join(sorted(new_icao_codes))}")
|
||||||
|
elif new_icao_codes:
|
||||||
|
sample_new = sorted(list(new_icao_codes))[:10]
|
||||||
|
print(
|
||||||
|
f"\nSample new ICAO codes: {', '.join(sample_new)} (and {len(new_icao_codes)-10} more)"
|
||||||
|
)
|
||||||
|
|
||||||
|
if deleted_icao_codes and len(deleted_icao_codes) <= 15:
|
||||||
|
print(f"Deleted ICAO codes: {', '.join(sorted(deleted_icao_codes))}")
|
||||||
|
elif deleted_icao_codes:
|
||||||
|
sample_deleted = sorted(list(deleted_icao_codes))[:10]
|
||||||
|
print(
|
||||||
|
f"Sample deleted ICAO codes: {', '.join(sample_deleted)} (and {len(deleted_icao_codes)-10} more)"
|
||||||
|
)
|
||||||
|
|
||||||
|
if changed_icao_codes and len(changed_icao_codes) <= 15:
|
||||||
|
print(f"Changed ICAO codes: {', '.join(sorted(changed_icao_codes))}")
|
||||||
|
elif changed_icao_codes:
|
||||||
|
sample_changed = sorted(list(changed_icao_codes))[:10]
|
||||||
|
print(
|
||||||
|
f"Sample changed ICAO codes: {', '.join(sample_changed)} (and {len(changed_icao_codes)-10} more)"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Show some specific examples of changes
|
||||||
|
if changed_icao_codes:
|
||||||
|
print(f"\nExample changes:")
|
||||||
|
for icao in sorted(list(changed_icao_codes))[:3]:
|
||||||
|
old_rec = old_records[icao]
|
||||||
|
new_rec = new_records[icao]
|
||||||
|
if old_rec.airline != new_rec.airline:
|
||||||
|
print(
|
||||||
|
f" {icao}: Airline '{old_rec.airline}' → '{new_rec.airline}'"
|
||||||
|
)
|
||||||
|
if old_rec.country != new_rec.country:
|
||||||
|
print(
|
||||||
|
f" {icao}: Country '{old_rec.country}' → '{new_rec.country}'"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
print(
|
||||||
|
"\nNo previous airline codes file found - this appears to be the first run"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Create database from new records
|
||||||
|
print("\nCreating airline database...")
|
||||||
|
row_count = write_database(new_records)
|
||||||
|
print("Total of", row_count, "ICAO codes stored in database")
|
||||||
|
|
||||||
|
|
||||||
|
def cleanup_temp() -> None:
|
||||||
|
"""Cleanup temporary files created during the process"""
|
||||||
|
if os.path.exists("airlinecodes_previous.txt"):
|
||||||
|
os.remove("airlinecodes_previous.txt")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
try:
|
||||||
|
create_database()
|
||||||
|
cleanup_temp()
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error creating airline database: {e}")
|
||||||
|
else:
|
||||||
|
print("Airline database created successfully.")
|
||||||
|
|||||||
@@ -3,6 +3,5 @@
|
|||||||
Licensed under [GNU GPL v3](../../../LICENSE)
|
Licensed under [GNU GPL v3](../../../LICENSE)
|
||||||
|
|
||||||
USAGE:
|
USAGE:
|
||||||
- Copy file from: https://opensky-network.org/datasets/metadata/aircraftDatabase.csv
|
|
||||||
- Run Python 3 script: `./make_icao24_db.py`
|
- Run Python 3 script: `./make_icao24_db.py`
|
||||||
- Copy file to /ADSB folder on SDCARD
|
- Move "icao24.db" file to /ADSB folder on SDCARD
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
# Copyright (C) 2021 ArjanOnwezen
|
# Copyright (C) 2021 ArjanOnwezen
|
||||||
|
# Copyright (C) 2025 Tommaso Ventafridda
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -20,43 +21,275 @@
|
|||||||
|
|
||||||
# -------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------
|
||||||
# Create icao24.db, used for ADS-B receiver application, using
|
# Create icao24.db, used for ADS-B receiver application, using
|
||||||
# https://opensky-network.org/datasets/metadata/aircraftDatabase.csv
|
# https://opensky-network.org/datasets/metadata/aircraftDatabase.csv
|
||||||
# as a source.
|
# as a source.
|
||||||
# -------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------
|
||||||
import csv
|
import csv
|
||||||
import unicodedata
|
import os
|
||||||
icao24_codes=bytearray()
|
import shutil
|
||||||
data=bytearray()
|
import urllib.request
|
||||||
row_count=0
|
from dataclasses import dataclass
|
||||||
|
from typing import Dict, Set, Tuple
|
||||||
|
|
||||||
database=open("icao24.db", "wb")
|
|
||||||
|
|
||||||
with open('aircraftDatabase.csv', 'rt') as csv_file:
|
@dataclass
|
||||||
sorted_lines=sorted(csv_file.readlines()[1:])
|
class AircraftRecord:
|
||||||
for row in csv.reader(sorted_lines, quotechar='"', delimiter=',', quoting=csv.QUOTE_ALL, skipinitialspace=True):
|
"""Represents an aircraft record with all relevant fields"""
|
||||||
# only store in case enough info is available
|
|
||||||
if len(row) == 27 and len(row[0]) == 6 and len(row[1]) > 0:
|
|
||||||
icao24_code=row[0][:6].upper()
|
|
||||||
registration=row[1][:8].encode('ascii', 'ignore')
|
|
||||||
manufacturer=row[3][:32].encode('ascii', 'ignore')
|
|
||||||
model=row[4][:32].encode('ascii', 'ignore')
|
|
||||||
# in case icao aircraft type isn't, use ac type like BALL for balloon
|
|
||||||
if len(row[8]) == 3:
|
|
||||||
actype=row[8][:3].encode('ascii', 'ignore')
|
|
||||||
else:
|
|
||||||
actype=row[5][:4].encode('ascii', 'ignore')
|
|
||||||
owner=row[13][:32].encode('ascii', 'ignore')
|
|
||||||
operator=row[9][:32].encode('ascii', 'ignore')
|
|
||||||
#padding
|
|
||||||
icao24_codes.extend(bytearray(icao24_code+'\0', encoding='ascii'))
|
|
||||||
registration_padding=bytearray('\0' * (9 - len(registration)), encoding='ascii')
|
|
||||||
manufacturer_padding=bytearray('\0' * (33 - len(manufacturer)), encoding='ascii')
|
|
||||||
model_padding=bytearray('\0' * (33 - len(model)), encoding='ascii')
|
|
||||||
actype_padding=bytearray('\0' * (5 - len(actype)), encoding='ascii')
|
|
||||||
owner_padding=bytearray('\0' * (33 - len(owner)), encoding='ascii')
|
|
||||||
operator_padding=bytearray('\0' * (33 - len(operator)), encoding='ascii')
|
|
||||||
data.extend(bytearray(registration+registration_padding+manufacturer+manufacturer_padding+model+model_padding+actype+actype_padding+owner+owner_padding+operator+operator_padding))
|
|
||||||
row_count+=1
|
|
||||||
database.write(icao24_codes+data)
|
|
||||||
print("Total of", row_count, "ICAO codes stored in database")
|
|
||||||
|
|
||||||
|
icao24: str
|
||||||
|
registration: str
|
||||||
|
manufacturer: str
|
||||||
|
model: str
|
||||||
|
actype: str
|
||||||
|
owner: str
|
||||||
|
operator: str
|
||||||
|
|
||||||
|
def __hash__(self):
|
||||||
|
return hash(self.icao24)
|
||||||
|
|
||||||
|
def __eq__(self, other):
|
||||||
|
if not isinstance(other, AircraftRecord):
|
||||||
|
return False
|
||||||
|
return self.icao24 == other.icao24
|
||||||
|
|
||||||
|
def data_equals(self, other):
|
||||||
|
"""Check if all data fields are equal (excluding ICAO24 which is the key)"""
|
||||||
|
if not isinstance(other, AircraftRecord):
|
||||||
|
return False
|
||||||
|
return (
|
||||||
|
self.registration == other.registration
|
||||||
|
and self.manufacturer == other.manufacturer
|
||||||
|
and self.model == other.model
|
||||||
|
and self.actype == other.actype
|
||||||
|
and self.owner == other.owner
|
||||||
|
and self.operator == other.operator
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def backup_previous_csv() -> bool:
|
||||||
|
"""Backup the existing CSV file if it exists. Returns True if backup was made."""
|
||||||
|
if os.path.exists("aircraftDatabase.csv"):
|
||||||
|
shutil.copy2("aircraftDatabase.csv", "aircraftDatabase_previous.csv")
|
||||||
|
print("Backed up previous CSV file")
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def download_aircraft_database() -> None:
|
||||||
|
"""Download the aircraft database file from OpenSky Network"""
|
||||||
|
url = "https://opensky-network.org/datasets/metadata/aircraftDatabase.csv"
|
||||||
|
print(f"Downloading aircraft database from {url}...")
|
||||||
|
try:
|
||||||
|
urllib.request.urlretrieve(url, "aircraftDatabase.csv")
|
||||||
|
print("Download completed successfully.")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error downloading aircraft database file: {e}")
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
def parse_csv_file(filename: str) -> Dict[str, AircraftRecord]:
|
||||||
|
"""Parse CSV file and return a dictionary of records"""
|
||||||
|
records = {}
|
||||||
|
|
||||||
|
if not os.path.exists(filename):
|
||||||
|
return records
|
||||||
|
|
||||||
|
try:
|
||||||
|
with open(filename, "rt", encoding="utf-8") as csv_file:
|
||||||
|
sorted_lines = sorted(csv_file.readlines()[1:])
|
||||||
|
for row in csv.reader(
|
||||||
|
sorted_lines,
|
||||||
|
quotechar='"',
|
||||||
|
delimiter=",",
|
||||||
|
quoting=csv.QUOTE_ALL,
|
||||||
|
skipinitialspace=True,
|
||||||
|
):
|
||||||
|
# only store in case enough info is available
|
||||||
|
if len(row) == 27 and len(row[0]) == 6 and len(row[1]) > 0:
|
||||||
|
icao24_code = row[0][:6].upper()
|
||||||
|
registration = row[1][:8]
|
||||||
|
manufacturer = row[3][:32]
|
||||||
|
model = row[4][:32]
|
||||||
|
# in case icao aircraft type isn't, use ac type like BALL for balloon
|
||||||
|
if len(row[8]) == 3:
|
||||||
|
actype = row[8][:3]
|
||||||
|
else:
|
||||||
|
actype = row[5][:4]
|
||||||
|
owner = row[13][:32]
|
||||||
|
operator = row[9][:32]
|
||||||
|
|
||||||
|
records[icao24_code] = AircraftRecord(
|
||||||
|
icao24=icao24_code,
|
||||||
|
registration=registration,
|
||||||
|
manufacturer=manufacturer,
|
||||||
|
model=model,
|
||||||
|
actype=actype,
|
||||||
|
owner=owner,
|
||||||
|
operator=operator,
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Warning: Could not parse CSV file {filename}: {e}")
|
||||||
|
return {}
|
||||||
|
|
||||||
|
return records
|
||||||
|
|
||||||
|
|
||||||
|
def compare_records(
|
||||||
|
old_records: Dict[str, AircraftRecord], new_records: Dict[str, AircraftRecord]
|
||||||
|
) -> Tuple[Set[str], Set[str], Set[str]]:
|
||||||
|
"""Compare old and new records, return sets of new, deleted, and changed ICAO codes"""
|
||||||
|
old_keys = set(old_records.keys())
|
||||||
|
new_keys = set(new_records.keys())
|
||||||
|
|
||||||
|
new_icao_codes = new_keys - old_keys
|
||||||
|
deleted_icao_codes = old_keys - new_keys
|
||||||
|
|
||||||
|
# Check for changes in existing records
|
||||||
|
changed_icao_codes = set()
|
||||||
|
for icao in old_keys & new_keys:
|
||||||
|
if not old_records[icao].data_equals(new_records[icao]):
|
||||||
|
changed_icao_codes.add(icao)
|
||||||
|
|
||||||
|
return new_icao_codes, deleted_icao_codes, changed_icao_codes
|
||||||
|
|
||||||
|
|
||||||
|
def write_database(records: Dict[str, AircraftRecord]) -> int:
|
||||||
|
"""Write records to database file using original format"""
|
||||||
|
# bytearrays to store icao24 codes and data
|
||||||
|
icao24_codes = bytearray()
|
||||||
|
data = bytearray()
|
||||||
|
row_count = 0
|
||||||
|
|
||||||
|
# Sort by ICAO code for consistency
|
||||||
|
sorted_records = sorted(records.values(), key=lambda r: r.icao24)
|
||||||
|
|
||||||
|
for record in sorted_records:
|
||||||
|
# Encode data fields
|
||||||
|
registration = record.registration.encode("ascii", "ignore")
|
||||||
|
manufacturer = record.manufacturer.encode("ascii", "ignore")
|
||||||
|
model = record.model.encode("ascii", "ignore")
|
||||||
|
actype = record.actype.encode("ascii", "ignore")
|
||||||
|
owner = record.owner.encode("ascii", "ignore")
|
||||||
|
operator = record.operator.encode("ascii", "ignore")
|
||||||
|
|
||||||
|
# Add ICAO code with null terminator (original format)
|
||||||
|
icao24_codes.extend(bytearray(record.icao24 + "\0", encoding="ascii"))
|
||||||
|
|
||||||
|
# Add padded data fields (original format)
|
||||||
|
registration_padding = bytearray(
|
||||||
|
"\0" * (9 - len(registration)), encoding="ascii"
|
||||||
|
)
|
||||||
|
manufacturer_padding = bytearray(
|
||||||
|
"\0" * (33 - len(manufacturer)), encoding="ascii"
|
||||||
|
)
|
||||||
|
model_padding = bytearray("\0" * (33 - len(model)), encoding="ascii")
|
||||||
|
actype_padding = bytearray("\0" * (5 - len(actype)), encoding="ascii")
|
||||||
|
owner_padding = bytearray("\0" * (33 - len(owner)), encoding="ascii")
|
||||||
|
operator_padding = bytearray("\0" * (33 - len(operator)), encoding="ascii")
|
||||||
|
|
||||||
|
data.extend(
|
||||||
|
bytearray(
|
||||||
|
registration
|
||||||
|
+ registration_padding
|
||||||
|
+ manufacturer
|
||||||
|
+ manufacturer_padding
|
||||||
|
+ model
|
||||||
|
+ model_padding
|
||||||
|
+ actype
|
||||||
|
+ actype_padding
|
||||||
|
+ owner
|
||||||
|
+ owner_padding
|
||||||
|
+ operator
|
||||||
|
+ operator_padding
|
||||||
|
)
|
||||||
|
)
|
||||||
|
row_count += 1
|
||||||
|
|
||||||
|
with open("icao24.db", "wb") as database:
|
||||||
|
database.write(icao24_codes + data)
|
||||||
|
|
||||||
|
return row_count
|
||||||
|
|
||||||
|
|
||||||
|
def create_database() -> None:
|
||||||
|
"""Create the ICAO24 database from the downloaded file"""
|
||||||
|
# Backup existing CSV before downloading new one
|
||||||
|
has_previous = backup_previous_csv()
|
||||||
|
|
||||||
|
# Download new CSV
|
||||||
|
download_aircraft_database()
|
||||||
|
|
||||||
|
# Parse both CSV files for comparison
|
||||||
|
old_records = {}
|
||||||
|
if has_previous:
|
||||||
|
print("Parsing previous CSV file...")
|
||||||
|
old_records = parse_csv_file("aircraftDatabase_previous.csv")
|
||||||
|
print(f"Found {len(old_records)} records in previous CSV")
|
||||||
|
|
||||||
|
print("Parsing new CSV file...")
|
||||||
|
new_records = parse_csv_file("aircraftDatabase.csv")
|
||||||
|
print(f"Found {len(new_records)} records in new CSV")
|
||||||
|
|
||||||
|
# Compare records if we have a previous version
|
||||||
|
if old_records:
|
||||||
|
new_icao_codes, deleted_icao_codes, changed_icao_codes = compare_records(
|
||||||
|
old_records, new_records
|
||||||
|
)
|
||||||
|
|
||||||
|
# Print change statistics
|
||||||
|
print("\n" + "=" * 50)
|
||||||
|
print("CSV CHANGE SUMMARY")
|
||||||
|
print("=" * 50)
|
||||||
|
print(f"New records: {len(new_icao_codes):>8}")
|
||||||
|
print(f"Deleted records: {len(deleted_icao_codes):>8}")
|
||||||
|
print(f"Changed records: {len(changed_icao_codes):>8}")
|
||||||
|
print(f"Total records: {len(new_records):>8}")
|
||||||
|
print("=" * 50)
|
||||||
|
|
||||||
|
# Show examples of changes (limited to avoid spam)
|
||||||
|
if new_icao_codes and len(new_icao_codes) <= 10:
|
||||||
|
print(f"\nNew ICAO24 codes: {', '.join(sorted(new_icao_codes))}")
|
||||||
|
elif new_icao_codes:
|
||||||
|
sample_new = sorted(list(new_icao_codes))[:5]
|
||||||
|
print(
|
||||||
|
f"\nSample new ICAO24 codes: {', '.join(sample_new)} (and {len(new_icao_codes)-5} more)"
|
||||||
|
)
|
||||||
|
|
||||||
|
if deleted_icao_codes and len(deleted_icao_codes) <= 10:
|
||||||
|
print(f"Deleted ICAO24 codes: {', '.join(sorted(deleted_icao_codes))}")
|
||||||
|
elif deleted_icao_codes:
|
||||||
|
sample_deleted = sorted(list(deleted_icao_codes))[:5]
|
||||||
|
print(
|
||||||
|
f"Sample deleted ICAO24 codes: {', '.join(sample_deleted)} (and {len(deleted_icao_codes)-5} more)"
|
||||||
|
)
|
||||||
|
|
||||||
|
if changed_icao_codes and len(changed_icao_codes) <= 10:
|
||||||
|
print(f"Changed ICAO24 codes: {', '.join(sorted(changed_icao_codes))}")
|
||||||
|
elif changed_icao_codes:
|
||||||
|
sample_changed = sorted(list(changed_icao_codes))[:5]
|
||||||
|
print(
|
||||||
|
f"Sample changed ICAO24 codes: {', '.join(sample_changed)} (and {len(changed_icao_codes)-5} more)"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
print("\nNo previous CSV found - this appears to be the first run")
|
||||||
|
|
||||||
|
# Create database from new records
|
||||||
|
print("\nCreating ICAO24 database...")
|
||||||
|
row_count = write_database(new_records)
|
||||||
|
print("Total of", row_count, "ICAO codes stored in database")
|
||||||
|
|
||||||
|
|
||||||
|
def cleanup_previous_csv() -> None:
|
||||||
|
"""Remove the previous CSV file if it exists"""
|
||||||
|
if os.path.exists("aircraftDatabase_previous.csv"):
|
||||||
|
os.remove("aircraftDatabase_previous.csv")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
try:
|
||||||
|
create_database()
|
||||||
|
cleanup_previous_csv()
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error creating ICAO24 database: {e}")
|
||||||
|
else:
|
||||||
|
print("ICAO24 database created successfully.")
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user