mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2026-09-16 19:43:01 +00:00
Updated icao24.db, improved python scripts. (#1013)
updated icao24.db improved icao24.db generation speed ( a few second, instead of an hour) small fixes
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
# Copyright (C) 2021 ArjanOnwezen
|
# Copyright (C) 2021 ArjanOnwezen
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
@@ -17,7 +16,6 @@
|
|||||||
# the Free Software Foundation, Inc., 51 Franklin Street,
|
# the Free Software Foundation, Inc., 51 Franklin Street,
|
||||||
# Boston, MA 02110-1301, USA.
|
# Boston, MA 02110-1301, USA.
|
||||||
#
|
#
|
||||||
|
|
||||||
# -------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------
|
||||||
# Create airline.db, used for ADS-B receiver application, using
|
# Create airline.db, used for ADS-B receiver application, using
|
||||||
# https://raw.githubusercontent.com/kx1t/planefence-airlinecodes/main/airlinecodes.txt
|
# https://raw.githubusercontent.com/kx1t/planefence-airlinecodes/main/airlinecodes.txt
|
||||||
@@ -28,12 +26,9 @@ import unicodedata
|
|||||||
icao_codes=bytearray()
|
icao_codes=bytearray()
|
||||||
airlines_countries=bytearray()
|
airlines_countries=bytearray()
|
||||||
row_count=0
|
row_count=0
|
||||||
|
|
||||||
database=open("airlines.db", "wb")
|
database=open("airlines.db", "wb")
|
||||||
|
with open('airlinecodes.txt', 'rt', encoding="utf-8") as csv_file:
|
||||||
with open('airlinecodes.txt', 'rt') as csv_file:
|
sorted_lines=sorted(csv_file.readlines()[1:])
|
||||||
sorted_lines=sorted(csv_file.readlines())
|
|
||||||
|
|
||||||
for row in csv.reader(sorted_lines, quotechar='"', delimiter=',', quoting=csv.QUOTE_ALL, skipinitialspace=True):
|
for row in csv.reader(sorted_lines, quotechar='"', delimiter=',', quoting=csv.QUOTE_ALL, skipinitialspace=True):
|
||||||
icao_code=row[0]
|
icao_code=row[0]
|
||||||
# Normalize some unicode characters
|
# Normalize some unicode characters
|
||||||
@@ -42,13 +37,11 @@ with open('airlinecodes.txt', 'rt') as csv_file:
|
|||||||
if len(icao_code) == 3 :
|
if len(icao_code) == 3 :
|
||||||
airline_padding=bytearray()
|
airline_padding=bytearray()
|
||||||
country_padding=bytearray()
|
country_padding=bytearray()
|
||||||
print(icao_code,' - ', airline,' - ', country)
|
|
||||||
icao_codes=icao_codes+bytearray(icao_code+'\0', encoding='ascii')
|
icao_codes=icao_codes+bytearray(icao_code+'\0', encoding='ascii')
|
||||||
airline_padding=bytearray('\0' * (32 - len(airline)), encoding='ascii')
|
airline_padding=bytearray('\0' * (32 - len(airline)), encoding='ascii')
|
||||||
country_padding=bytearray('\0' * (32 - len(country)), encoding='ascii')
|
country_padding=bytearray('\0' * (32 - len(country)), encoding='ascii')
|
||||||
airlines_countries=airlines_countries+bytearray(airline+airline_padding+country+country_padding)
|
airlines_countries=airlines_countries+bytearray(airline+airline_padding+country+country_padding)
|
||||||
row_count+=1
|
row_count+=1
|
||||||
|
|
||||||
database.write(icao_codes+airlines_countries)
|
database.write(icao_codes+airlines_countries)
|
||||||
print("Total of", row_count, "ICAO codes stored in database")
|
print("Total of", row_count, "ICAO codes stored in database")
|
||||||
|
|
||||||
|
|||||||
+469595
-409585
File diff suppressed because it is too large
Load Diff
@@ -48,16 +48,15 @@ with open('aircraftDatabase.csv', 'rt') as csv_file:
|
|||||||
owner=row[13][:32].encode('ascii', 'ignore')
|
owner=row[13][:32].encode('ascii', 'ignore')
|
||||||
operator=row[9][:32].encode('ascii', 'ignore')
|
operator=row[9][:32].encode('ascii', 'ignore')
|
||||||
#padding
|
#padding
|
||||||
icao24_codes=icao24_codes+bytearray(icao24_code+'\0', encoding='ascii')
|
icao24_codes.extend(bytearray(icao24_code+'\0', encoding='ascii'))
|
||||||
registration_padding=bytearray('\0' * (9 - len(registration)), encoding='ascii')
|
registration_padding=bytearray('\0' * (9 - len(registration)), encoding='ascii')
|
||||||
manufacturer_padding=bytearray('\0' * (33 - len(manufacturer)), encoding='ascii')
|
manufacturer_padding=bytearray('\0' * (33 - len(manufacturer)), encoding='ascii')
|
||||||
model_padding=bytearray('\0' * (33 - len(model)), encoding='ascii')
|
model_padding=bytearray('\0' * (33 - len(model)), encoding='ascii')
|
||||||
actype_padding=bytearray('\0' * (5 - len(actype)), encoding='ascii')
|
actype_padding=bytearray('\0' * (5 - len(actype)), encoding='ascii')
|
||||||
owner_padding=bytearray('\0' * (33 - len(owner)), encoding='ascii')
|
owner_padding=bytearray('\0' * (33 - len(owner)), encoding='ascii')
|
||||||
operator_padding=bytearray('\0' * (33 - len(operator)), encoding='ascii')
|
operator_padding=bytearray('\0' * (33 - len(operator)), encoding='ascii')
|
||||||
data=data+bytearray(registration+registration_padding+manufacturer+manufacturer_padding+model+model_padding+actype+actype_padding+owner+owner_padding+operator+operator_padding)
|
data.extend(bytearray(registration+registration_padding+manufacturer+manufacturer_padding+model+model_padding+actype+actype_padding+owner+owner_padding+operator+operator_padding))
|
||||||
row_count+=1
|
row_count+=1
|
||||||
|
|
||||||
database.write(icao24_codes+data)
|
database.write(icao24_codes+data)
|
||||||
print("Total of", row_count, "ICAO codes stored in database")
|
print("Total of", row_count, "ICAO codes stored in database")
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
Licensed under [GNU GPL v3](../../../LICENSE)
|
Licensed under [GNU GPL v3](../../../LICENSE)
|
||||||
|
|
||||||
Python3 script creates a MID (Marine Identification Digit) database.
|
Python3 script creates a MID (Marine Identification Digit) database.
|
||||||
MID is part of MMSI and determines (among other things) the conutry.
|
MID is part of MMSI and determines country (among other things).
|
||||||
|
|
||||||
|
|
||||||
USAGE:
|
USAGE:
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user