Merge pull request #452 from ArjanOnwezen/add-operator-to-icao-24

Added operator to ICAO24 file
This commit is contained in:
Erwin Ried 2022-01-10 11:04:15 +01:00 committed by GitHub
commit fc08d0ba2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 10616 additions and 9507 deletions

View File

@ -123,6 +123,7 @@ ADSBRxAircraftDetailsView::ADSBRxAircraftDetailsView(
&text_number_of_engines,
&text_engine_type,
&text_owner,
&text_operator,
&button_close
});
@ -135,7 +136,8 @@ ADSBRxAircraftDetailsView::ADSBRxAircraftDetailsView(
// Try getting the aircraft information from icao24.db
auto result = db_file.open("ADSB/icao24.db");
if (!result.is_valid()) {
number_of_icao_codes = (db_file.size() / 115); // determine number of ICAO24 codes in file
// determine number of ICAO24 codes in file, total size / (single index + record size)
number_of_icao_codes = (db_file.size() / 153);
icao_code = to_string_hex(entry_copy.ICAO_address, 6);
// binary search
@ -158,17 +160,14 @@ ADSBRxAircraftDetailsView::ADSBRxAircraftDetailsView(
}
if (position > -1) {
db_file.seek((number_of_icao_codes * 7) + (position * 108)); // seek starting after index
db_file.read(file_buffer, 8);
db_file.seek((number_of_icao_codes * 7) + (position * 146)); // seek starting after index
db_file.read(file_buffer, 9);
text_registration.set(file_buffer);
db_file.read(file_buffer, 32);
db_file.read(file_buffer, 33);
text_manufacturer.set(file_buffer);
db_file.read(file_buffer, 32);
db_file.read(file_buffer, 33);
text_model.set(file_buffer);
db_file.read(file_buffer, 4); // ICAO type decripton
db_file.read(file_buffer, 5); // ICAO type decripton
if(strlen(file_buffer) == 3) {
switch(file_buffer[0]) {
case 'L':
@ -209,32 +208,19 @@ ADSBRxAircraftDetailsView::ADSBRxAircraftDetailsView(
}
// check for ICAO type designator
else if(strlen(file_buffer) == 4) {
switch(file_buffer[0]) {
case 'SHIP':
text_type.set("Airship");
break;
case 'BALL':
text_type.set("Balloon");
break;
case 'GLID':
text_type.set("Glider / sailplane");
break;
case 'ULAC':
text_type.set("Micro/ultralight aircraft");
break;
case 'GYRO':
text_type.set("Micro/ultralight autogyro");
break;
case 'UHEL':
text_type.set("Micro/ultralight helicopter");
break;
case 'PARA':
text_type.set("Powered parachute/paraplane");
break;
}
if(strcmp(file_buffer,"SHIP") == 0) text_type.set("Airship");
else if(strcmp(file_buffer,"BALL") == 0) text_type.set("Balloon");
else if(strcmp(file_buffer,"GLID") == 0) text_type.set("Glider / sailplane");
else if(strcmp(file_buffer,"ULAC") == 0) text_type.set("Micro/ultralight aircraft");
else if(strcmp(file_buffer,"GYRO") == 0) text_type.set("Micro/ultralight autogyro");
else if(strcmp(file_buffer,"UHEL") == 0) text_type.set("Micro/ultralight helicopter");
else if(strcmp(file_buffer,"SHIP") == 0) text_type.set("Airship");
else if(strcmp(file_buffer,"PARA") == 0) text_type.set("Powered parachute/paraplane");
}
db_file.read(file_buffer, 32);
db_file.read(file_buffer, 33);
text_owner.set(file_buffer);
db_file.read(file_buffer, 33);
text_operator.set(file_buffer);
} else {
text_registration.set("Unknown");
text_manufacturer.set("Unknown");

View File

@ -191,7 +191,8 @@ private:
{ { 0 * 8, 7 * 16 }, "Type:", Color::light_grey() },
{ { 0 * 8, 8 * 16 }, "Number of engines:", Color::light_grey() },
{ { 0 * 8, 9 * 16 }, "Engine type:", Color::light_grey() },
{ { 0 * 8, 10 * 16 }, "Owner:", Color::light_grey() }
{ { 0 * 8, 11 * 16 }, "Owner:", Color::light_grey() },
{ { 0 * 8, 13 * 16 }, "Operator:", Color::light_grey() }
};
Text text_icao_address {
@ -225,12 +226,17 @@ private:
};
Text text_engine_type {
{ 12 * 8, 9 * 16, 30 * 8, 16},
{ 0 * 8, 10 * 16, 30 * 8, 16},
"-"
};
Text text_owner {
{ 0 * 8, 11 * 16, 30 * 8, 16 },
{ 0 * 8, 12 * 16, 30 * 8, 16 },
"-"
};
Text text_operator {
{ 0 * 8, 14 * 16, 30 * 8, 16 },
"-"
};

1260
firmware/tools/make_airlines_db/airlinecodes.txt Executable file → Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -44,23 +44,18 @@ with open('aircraftDatabase.csv', 'rt') as csv_file:
if len(row[8]) == 3:
actype=row[8][:3].encode('ascii', 'ignore')
else:
actype=row[5][:4].encode('ascii', 'ignore')
actype=row[5][:4].encode('ascii', 'ignore')
owner=row[13][:32].encode('ascii', 'ignore')
operator=row[9][:32].encode('ascii', 'ignore')
#padding
registration_padding=bytearray()
manufacturer_padding=bytearray()
model_padding=bytearray()
actype_padding=bytearray()
owner_padding=bytearray()
# debug print(icao24_code,' - ', registration,' - ', manufacturer, '-', model, '-', actype, '-', owner)
icao24_codes=icao24_codes+bytearray(icao24_code+'\0', encoding='ascii')
registration_padding=bytearray('\0' * (8 - len(registration)), encoding='ascii')
manufacturer_padding=bytearray('\0' * (32 - len(manufacturer)), encoding='ascii')
model_padding=bytearray('\0' * (32 - len(model)), encoding='ascii')
actype_padding=bytearray('\0' * (4 - len(actype)), encoding='ascii')
owner_padding=bytearray('\0' * (32 - len(owner)), encoding='ascii')
data=data+bytearray(registration+registration_padding+manufacturer+manufacturer_padding+model+model_padding+actype+actype_padding+owner+owner_padding)
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=data+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)

BIN
sdcard/ADSB/airlines.db Executable file → Normal file

Binary file not shown.

Binary file not shown.