Welcome to Radarspotting. Please login or sign up.

May 05, 2024, 06:14:46 PM

Login with username, password and session length

New Members

New Members

You should get an activation email when you join.  If not, please use the Contact option.

Which OperatorFlags do i need in \OperatorFlags ?

Started by Klaus, March 08, 2017, 07:08:08 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Klaus

I am writing this kind of tutorial because i was running into BaseStation's 'too many files in the OperatorFlags folder' problem.

In my \OperatorFlags where 9000+ files and BaseStation was running fine, until i replaced BaseStation's own and old Countries.DAT (2006 and ~9kB) file with a newer detailed one (2015 and ~45kB) from here http://woodair.net/SBS/Utilities/Kinetic_Utilities4_Bitmaps.htm. I figured out very quickly that running BaseStation with the new Countries.DAT file and 9000+ files in \OperatorFlags will bring BaseStation to a halt by simply starting BaseStation with the new CountriesDAT and an empty \OperatorFlags.

Now i have the problem that i need to know which OperatorFlags.bmp do i really need in \OperatorFlags, which are not in use and which are still missing. Checking all this by hand isn't that funny at all. I will show you now what i have done so far, to keep my \OperatorFlags as lean and clean as possible. First it's time for a closer look at the BaseStation.sqb file now and do some sqlite.

The following is read only to the BaseStation.sqb file, but make a back up of it anyway and close BaseStation!

My BaseStation is running under Windows 7x64 ultimate and is located in C:\Kinetic\BaseStation. No Virtual Store!


*** this article is not static and can be changed ***

Open BaseStation.sqb with your favourite SQLite-Browser. If you don't have one installed, you can use i.e. DB Browser for SQLite http://sqlitebrowser.org/ but it will work with yours as well. Yours might just look a little different.

Click on the [Execute SQL] Tab and execute the following query:

SELECT OperatorFlagCode FROM Aircraft;

In the result window you can browse the whole OperatorFlagCode column with all its rows, 162015 in my case.

I executed the following to remove all the NULL from the list:

SELECT OperatorFlagCode FROM Aircraft WHERE OperatorFlagCode IS NOT NULL;

Better (29228 rows), but still way too large because of too many ...Doppelganger, as ORDER BY shows:

SELECT OperatorFlagCode FROM Aircraft WHERE OperatorFlagCode IS NOT NULL ORDER BY OperatorFlagCode;

DISTINCT will remove the Doppelganger:

SELECT DISTINCT OperatorFlagCode FROM Aircraft WHERE OperatorFlagCode IS NOT NULL ORDER BY OperatorFlagCode;

2910 rows shown minus one blank are resulting in 2909 needed BMPs. Comparing this to the 9000+ files i have had. Save your list (the encircled button will do this) to a file. Your browser might have this funktion too.


Semi manual copy

You can use this list to generate a batchfile to copy the needed BMPs from a sourcefolder (the sourcefolder is just my old OFC folder with it's 9000+ files) into /OperatorFlags with your favorite editor. A line might look like this:

copy "C:\Kinetic\BaseStation\OperatorFlagsSRC\100ARW.BMP" "C:\Kinetic\BaseStation\OperatorFlags\"

Change the above line to your needs and save this file as copyofc.bat in C:\Kinetic\BaseStation\ when you are done.

Now open the Windows Command Line (cmd.exe) and type in the path to copyofc.bat. By the way this is not that difficult, cause you can use the [TAB]-Key completion. I.E. type in C:\Ki and then press [TAB] and so on.

This will copy only the needed files from your sourcefolder if they are in there to C:\Kinetic\BaseStation\OperatorFlags\, but you need to know what files are missing, aren't you? Type in this:

C:\Kinetic\BaseStation\copyofc.bat>copyofc.log

In the above line the > will redirect the output to the file copyofc.log. Your missing Files are the ones with an error in this logfile. The logfile is located in the path your console is showing.


Searching your archives

If you have multiple folders with operatorlogos on your harddrive and you need to search a few hundred files, you can search multiple files at once by separating the filenames with an OR . Yes, OR in CAPS. I.E.
DHL OR UPS OR TNT
The above line will find DHL, UPS and TNT in one run. You can give your local languge a try, if OR doesn't work. Germans can try ODER instead or OR.

I hope you find it useful.

Disclaimer
Use it at your own risc. Backup your BaseStation.sqb beforehand!
Or even better: Copy your complete BS folder to drive d: and carefully test it there!


[Attachment deleted by Admin to save file space]

Klaus

#1
This is the next step to maintain your \OperatorFlags the easy way.

The following is read only to the BaseStation.sqb file, but make a back up of it anyway and close BaseStation!

My BaseStation is running under Windows 7x64 ultimate and is located in C:\Kinetic\BaseStation. No Virtual Store!


*** this article is not static and can be changed ***

Semi automatic copy

Now you are going to extract the OperatorFlagCode out of BaseStation.sqb and generate a filelist with a few clicks.
Ready? Download https://www.sqlite.org/2017/sqlite-tools-win32-x86-3170000.zip and extract sqlite3.exe into your \BaseStation folder now. Create also a new empty file ofc.sql in this folder and paste the following in:.open BaseStation.sqb
.separator | \r\n
.once COPYOFC.DAT
SELECT DISTINCT OperatorFlagCode FROM Aircraft WHERE OperatorFlagCode != ICAOTypeCode ORDER BY OperatorFlagCode;


This batch file will start sqlite3.exe and pass ofc.sql to it. Save it as ofc.bat.sqlite3.exe < ofc.sqlYou can simply doubleclick the above batch file to execute it.

The COPYOFC.DAT will be used by the next batch file to do the copy job and write the missing files into COPYOFC.LOG. Save it as copyofc.bat in your \BaseStation as allways.@ECHO OFF

REM CHANGE FILENAMES AND PATHS TO FIT YOUR SYSTEM

CLS

set src_folder=C:\Kinetic\BaseStation\OperatorFlagsSRC
set dst_folder=C:\Kinetic\BaseStation\OperatorFlags
set file_list=C:\Kinetic\BaseStation\COPYOFC.DAT
set logfile=C:\Kinetic\BaseStation\COPYOFC.LOG


ECHO ### Missing OperatorFlags ### > %logfile%

for /f %%a in (%file_list%) DO (
  if exist "%src_folder%\%%a.BMP" (
    copy "%src_folder%\%%a.BMP" "%dst_folder%"
  ) else (
    ECHO %%a >> %logfile%
  )
)

PAUSE

EXIT
You can simply doubleclick the above batch file to execute it.

Plase check COPYOFC.LOG for missing files.



I hope you find it useful.

Disclaimer
Use it at your own risc. Backup your BaseStation.sqb beforehand!
Or even better: Copy your complete BS folder to drive d: and carefully test it there!

Klaus

#2
This is the next step to maintain your \OperatorFlags the easy way.

I didn't cover silhouettes yet. Now i will show you what to do to make BaseStation show silhouettes where no operatorlogos are set.

The following will alter BaseStation.sqb. Switch on your brains! Close BaseStation and back up BaseStation.sqb!
My BaseStation is running under Windows 7x64 ultimate and is located in C:\Kinetic\BaseStation. No Virtual Store!
Adjust filepathspaths and filenames to your needs and save them in \BaseStation as always.


*** this article is not static and can be changed ***

UPDATE: Beware of overlapping OperatorFlagCode and ICAOTypeCode.


Back up your existing OperatorFlagCode
If you are using a customised OperatorFlagCode.BMP (i.e. based on registration, cargoplane, military unit or a combination of company and aircraft etc.) you should back up the existing OperatorFlagCode in the BaseStation.sqb first. As far as i know BaseStation.sqb's UserStrings are not in use by BaseStation itself, but i.e. UserString1 is used by VRS and PBLink uses Userstring4 and UserString5. I do recommend that you first check your BaseStation.sqb that UserString5 is not in use or search for an other empty field cause otherwise data corruption or errors may occur.

In my case UserString5 is empty. For that reason i copy the OperatorFlagCode into UserString5. Change the script to an other field if your UserString5 is occupied. This is your insurance if anything unexpected happens to your customized operatorflags. If OperatorFlagCode is empty nothing will be copied. Save this code as backupofc.sql
.open BaseStation.sqb
UPDATE Aircraft SET UserString5 = OperatorFlagCode WHERE OperatorFlagCode IS NOT NULL;


This batch file will start sqlite3.exe and pass backupofc.sql to it. Save it as backupofc.bat.sqlite3.exe < backupofc.sql
You can simply doubleclick the above batch file to execute it.


How to turn silhouettes ON
The following will copy the contents of BaseStation.sqb's ICAOTypeCode field to the empty OperatorFlagCode field. If ICAOTypeCode is empty nothing will be copied. Save it as silon.sql

.open BaseStation.sqb
UPDATE Aircraft SET OperatorFlagCode = ICAOTypeCode WHERE OperatorFlagCode IS NULL;


This batch file will start sqlite3.exe and pass silon.sql to it. Save it as silon.bat.sqlite3.exe < silon.sql
You can simply doubleclick the above batch file to execute it.


How to turn silhouettes OFF
This file will revert the above change. Save it as siloff.sql.open BaseStation.sqb
UPDATE Aircraft SET OperatorFlagCode = NULL WHERE OperatorFlagCode = ICAOTypeCode;


This batch file will start sqlite3.exe and pass siloff.sql to it. Save it as siloff.bat.sqlite3.exe < siloff.sql
You can simply doubleclick the above batch file to execute it.


How to copy silhouettes
We still need to copy only the needed silhouettes into C:\Kinetic\BaseStation\OperatorFlags to keep BaseStation's memoryconsumption as low as possible.

This sql file will write the needed silhouettes in COPYSIL.DAT. Save it as sil.sql
.open BaseStation.sqb
.separator | \r\n
.once COPYSIL.DAT
SELECT DISTINCT ICAOTypeCode FROM Aircraft WHERE ICAOTypeCode = OperatorFlagCode ORDER BY ICAOTypeCode;


This batch file will start sqlite3.exe and pass sil.sql to it. Save it as sil.bat.sqlite3.exe < sil.sqlYou can simply doubleclick the above batch file to execute it.

This batch file will copy the silhouettes and write the missing files to COPYSIL.LOG. Save it as copysil.bat
@ECHO OFF

REM CHANGE FILE PATHS TO FIT YOUR SYSTEM

CLS

set src_folder=C:\Kinetic\BaseStation\Silhouettes
set dst_folder=C:\Kinetic\BaseStation\OperatorFlags
set file_list=C:\Kinetic\BaseStation\COPYSIL.DAT
set logfile=C:\Kinetic\BaseStation\COPYSIL.LOG

ECHO ### Missing Silhouettes ### > %logfile%

for /f %%a in (%file_list%) DO (
  if exist "%src_folder%\%%a.BMP" (
    copy "%src_folder%\%%a.BMP" "%dst_folder%"
  ) else (
    ECHO %%a >> %logfile%
  )
)

PAUSE

EXIT

You can simply doubleclick the above batch file to execute it.


To copy the silhuettes you need to...

  • back up your BaseStation.sqb file now. Make a copy of it. I mean it.
  • doubleclick silon.bat (ICAOTypeCode will be copied into OperatorFlagCode within BaseStation.sqb)
  • doubleclick sil.bat (The needed ICAOTypeCode files will be written into COPYSIL.DAT)
  • doubleclick copysil.bat (The needed ICAOTypeCode will be copied into \OperatorFlags based on COPYSIL.DAT)
...in this order! Plase check COPYSIL.LOG for missing files.


I do stress that everytime you update existing records of your BaseStation.sqb you need to execute the siloff.sql file beforehand to switch silhuettes off. Because a provided update.sql is in general a black box and can alter the ICAOTypeCode. If this happens siloff.sql will fail to NULL the OperatorFlagCode if it doesn't match the ICAOTypeCode because of an update. In example ADLite is updating a new and empty record, while dbpop also updates existing records. Keep this in mind and always back up your BaseStation.sqb.

I hope you find it useful.

Disclaimer
Use it at your own risc. Backup your BaseStation.sqb beforehand!
Or even better: Copy your complete BS folder to drive d: and carefully test it there!


[Attachment deleted by Admin to save file space]