mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-08-10 15:40:29 -04:00
new airlines_db
This commit is contained in:
parent
e985efd78b
commit
bbd9a865de
8 changed files with 5598 additions and 6281 deletions
File diff suppressed because it is too large
Load diff
|
@ -1,4 +0,0 @@
|
|||
[ZoneTransfer]
|
||||
ZoneId=3
|
||||
ReferrerUrl=https://www.bountysource.com/
|
||||
HostUrl=https://github-repository-files.githubusercontent.com/251043704/4747359?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20211011%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20211011T232519Z&X-Amz-Expires=300&X-Amz-Signature=25180babeea757c128d1a995735486006e018abe6941ab5493597d194dc7b994&X-Amz-SignedHeaders=host&actor_id=21973866&key_id=0&repo_id=251043704&response-content-disposition=attachment%3Bfilename%3Dairlines.csv.txt&response-content-type=text%2Fplain
|
|
@ -1,42 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# Copyright (C) 2017 Furrtek
|
||||
#
|
||||
# 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
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; see the file COPYING. If not, write to
|
||||
# the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
|
||||
import sys
|
||||
import struct
|
||||
|
||||
outfile = open("airlines.db", "w")
|
||||
|
||||
# Download airlines.txt from http://xdeco.org/?page_id=30
|
||||
lines = [line.rstrip('\n') for line in open('../../sdcard/ADSB/airlines.csv.txt', 'r')]
|
||||
n = 0
|
||||
|
||||
for line in lines:
|
||||
if line:
|
||||
nd = line.find('(')
|
||||
if (nd == -1):
|
||||
nd = None
|
||||
else:
|
||||
nd -= 1
|
||||
nline = line[4:7] + '\0' + line[10:nd] + '\0'
|
||||
print nline
|
||||
b = bytearray(nline)
|
||||
pad_len = 32 - len(b)
|
||||
b += "\0" * pad_len
|
||||
outfile.write(b)
|
7
firmware/tools/make_airlines_db/README.md
Normal file
7
firmware/tools/make_airlines_db/README.md
Normal file
|
@ -0,0 +1,7 @@
|
|||
# Make airlines.db
|
||||
|
||||
Licensed under GNU GPL v3 (license)[../../../LICENSE]
|
||||
|
||||
USAGE:
|
||||
- Copy file from: https://raw.githubusercontent.com/kx1t/planefence-airlinecodes/main/airlinecodes.txt
|
||||
- Run Python 3 script: `./make_airlines_db.py`
|
5531
firmware/tools/make_airlines_db/airlinecodes.txt
Executable file
5531
firmware/tools/make_airlines_db/airlinecodes.txt
Executable file
File diff suppressed because it is too large
Load diff
54
firmware/tools/make_airlines_db/make_airlines_db.py
Executable file
54
firmware/tools/make_airlines_db/make_airlines_db.py
Executable file
|
@ -0,0 +1,54 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
# Copyright (C) 2021 ArjanOnwezen
|
||||
#
|
||||
# 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
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; see the file COPYING. If not, write to
|
||||
# the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
|
||||
# -------------------------------------------------------------------------------------
|
||||
# Create airline.db, used for ADS-B receiver application, using
|
||||
# https://raw.githubusercontent.com/kx1t/planefence-airlinecodes/main/airlinecodes.txt
|
||||
# as a source.
|
||||
# -------------------------------------------------------------------------------------
|
||||
import csv
|
||||
import unicodedata
|
||||
icao_codes=bytearray()
|
||||
airlines_countries=bytearray()
|
||||
row_count=0
|
||||
|
||||
database=open("airlines.db", "wb")
|
||||
|
||||
with open('airlinecodes.txt', 'rt') as csv_file:
|
||||
sorted_lines=sorted(csv_file.readlines())
|
||||
|
||||
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()
|
||||
print(icao_code,' - ', airline,' - ', country)
|
||||
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")
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue