WSJT-X/logbook/countrydat.cpp

146 lines
3.5 KiB
C++
Raw Normal View History

/*
#Sov Mil Order of Malta: 15: 28: EU: 41.90: -12.43: -1.0: 1A:
#1A;
#Spratly Islands: 26: 50: AS: 9.88: -114.23: -8.0: 1S:
#1S,9M0,BV9S;
#Monaco: 14: 27: EU: 43.73: -7.40: -1.0: 3A:
#3A;
#Heard Island: 39: 68: AF: -53.08: -73.50: -5.0: VK0H:
#=VK0IR;
#Macquarie Island: 30: 60: OC: -54.60: -158.88: -10.0: VK0M:
#=VK0KEV;
#Cocos-Keeling: 29: 54: OC: -12.15: -96.82: -6.5: VK9C:
#AX9C,AX9Y,VH9C,VH9Y,VI9C,VI9Y,VJ9C,VJ9Y,VK9C,VK9Y,VL9C,VL9Y,VM9C,VM9Y,
#VN9C,VN9Y,VZ9C,VZ9Y,=VK9AA;
*/
#include "countrydat.h"
#include <QFile>
#include <QTextStream>
void CountryDat::init(const QString filename)
{
_filename = filename;
_data.clear();
}
Merged from trunk: ------------------------------------------------------------------------ r8016 | k9an | 2017-08-09 16:22:54 +0100 (Wed, 09 Aug 2017) | 1 line Remove call to jtmsg. ------------------------------------------------------------------------ r8017 | k9an | 2017-08-09 16:52:52 +0100 (Wed, 09 Aug 2017) | 1 line Bring a simulation tool up to date. ------------------------------------------------------------------------ r8022 | k9an | 2017-08-13 02:35:13 +0100 (Sun, 13 Aug 2017) | 1 line Improve efficiency of OSD by a factor of 5 to 10 for norder=2 and 3. Use norder=2 for wideband multi-decoding, norder=3 near nfqso and nftx. ------------------------------------------------------------------------ r8026 | k9an | 2017-08-14 16:00:48 +0100 (Mon, 14 Aug 2017) | 1 line Make default MSK144 amplitude polynomial flat. ------------------------------------------------------------------------ r8029 | k1jt | 2017-08-19 14:07:27 +0100 (Sat, 19 Aug 2017) | 1 line Edit the advice displayed by F5. ------------------------------------------------------------------------ r8030 | k1jt | 2017-08-19 23:34:26 +0100 (Sat, 19 Aug 2017) | 1 line Fix a typo. ------------------------------------------------------------------------ r8031 | k9an | 2017-08-22 01:14:51 +0100 (Tue, 22 Aug 2017) | 1 line 1. Improvements to the OSD to allow deeper wideband decoding. 2. Add a third decoding pass. 3. Change symbol metric from max-log to max-amplitude. ------------------------------------------------------------------------ r8032 | k9an | 2017-08-22 01:17:23 +0100 (Tue, 22 Aug 2017) | 1 line Delete unused array. ------------------------------------------------------------------------ r8033 | k9an | 2017-08-22 01:21:59 +0100 (Tue, 22 Aug 2017) | 1 line More cleanup. ------------------------------------------------------------------------ r8034 | k1jt | 2017-08-24 14:38:47 +0100 (Thu, 24 Aug 2017) | 1 line Possible pseudo-code for DXpedition auto-sequencing. ------------------------------------------------------------------------ r8035 | k1jt | 2017-08-25 17:59:58 +0100 (Fri, 25 Aug 2017) | 4 lines Use the most recently edited "CQ xx: message in Tx6 as a template for subsequent regenerations. This means that "CQ DX", "CQ VT", etc., will be presistent until changed back. ------------------------------------------------------------------------ r8036 | k1jt | 2017-08-26 17:30:47 +0100 (Sat, 26 Aug 2017) | 1 line Use a baseline-fitting procedure to improve S/N estimates for FT8. ------------------------------------------------------------------------ r8037 | k1jt | 2017-08-27 13:26:37 +0100 (Sun, 27 Aug 2017) | 1 line Fix the 'Start=0 ==> S/N = -24 dB' problem. ------------------------------------------------------------------------ r8038 | k1jt | 2017-08-27 14:11:56 +0100 (Sun, 27 Aug 2017) | 1 line Change magic 36 back to 37; does this break something else? ------------------------------------------------------------------------ r8039 | k1jt | 2017-08-28 15:32:14 +0100 (Mon, 28 Aug 2017) | 2 lines Correct the behavior of FT8 in "NA VHF Contest mode". ------------------------------------------------------------------------ r8040 | k9an | 2017-08-28 22:09:44 +0100 (Mon, 28 Aug 2017) | 1 line Fix a potential array bounds issue in osd174.f90. ------------------------------------------------------------------------ r8043 | bsomervi | 2017-08-29 04:20:37 +0100 (Tue, 29 Aug 2017) | 1 line Update AD1C cty.dat database to 14th Aug 2017 big CTY.DAT ------------------------------------------------------------------------ r8044 | bsomervi | 2017-08-29 04:20:51 +0100 (Tue, 29 Aug 2017) | 1 line Basic fix of auto sequencing with free text 73 messages, more to come ------------------------------------------------------------------------ r8045 | bsomervi | 2017-08-29 04:46:32 +0100 (Tue, 29 Aug 2017) | 1 line Ensure that auto Tx is disabled when stop Tx on 73 isn't enabled and DX call is cleared ------------------------------------------------------------------------ r8046 | k1jt | 2017-08-29 15:01:55 +0100 (Tue, 29 Aug 2017) | 2 lines Update text in User Guide related to *NA VHF Contest Mode*. ------------------------------------------------------------------------ r8047 | bsomervi | 2017-08-30 03:27:57 +0100 (Wed, 30 Aug 2017) | 7 lines Fix some signoff issues with auto-sequencing 73 messages from other QSOs on frequency should now be ignored rather than being processed. Also some long overdue refactoring and tidying of non-idiomatic C++ code in the logbook directory. ------------------------------------------------------------------------ r8048 | bsomervi | 2017-08-30 14:20:39 +0100 (Wed, 30 Aug 2017) | 1 line Make 73 and RR73 matching of incoming messages for exact while words ------------------------------------------------------------------------ r8049 | k1jt | 2017-08-30 18:06:49 +0100 (Wed, 30 Aug 2017) | 1 line Updates to User Guide. ------------------------------------------------------------------------ git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx-1.8@8050 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
2017-08-31 00:41:52 +00:00
QString CountryDat::_extractName(const QString line) const
{
int s1 = line.indexOf(':');
if (s1>=0)
{
QString name = line.mid(0,s1);
return name;
}
return "";
}
Merged from trunk: ------------------------------------------------------------------------ r8016 | k9an | 2017-08-09 16:22:54 +0100 (Wed, 09 Aug 2017) | 1 line Remove call to jtmsg. ------------------------------------------------------------------------ r8017 | k9an | 2017-08-09 16:52:52 +0100 (Wed, 09 Aug 2017) | 1 line Bring a simulation tool up to date. ------------------------------------------------------------------------ r8022 | k9an | 2017-08-13 02:35:13 +0100 (Sun, 13 Aug 2017) | 1 line Improve efficiency of OSD by a factor of 5 to 10 for norder=2 and 3. Use norder=2 for wideband multi-decoding, norder=3 near nfqso and nftx. ------------------------------------------------------------------------ r8026 | k9an | 2017-08-14 16:00:48 +0100 (Mon, 14 Aug 2017) | 1 line Make default MSK144 amplitude polynomial flat. ------------------------------------------------------------------------ r8029 | k1jt | 2017-08-19 14:07:27 +0100 (Sat, 19 Aug 2017) | 1 line Edit the advice displayed by F5. ------------------------------------------------------------------------ r8030 | k1jt | 2017-08-19 23:34:26 +0100 (Sat, 19 Aug 2017) | 1 line Fix a typo. ------------------------------------------------------------------------ r8031 | k9an | 2017-08-22 01:14:51 +0100 (Tue, 22 Aug 2017) | 1 line 1. Improvements to the OSD to allow deeper wideband decoding. 2. Add a third decoding pass. 3. Change symbol metric from max-log to max-amplitude. ------------------------------------------------------------------------ r8032 | k9an | 2017-08-22 01:17:23 +0100 (Tue, 22 Aug 2017) | 1 line Delete unused array. ------------------------------------------------------------------------ r8033 | k9an | 2017-08-22 01:21:59 +0100 (Tue, 22 Aug 2017) | 1 line More cleanup. ------------------------------------------------------------------------ r8034 | k1jt | 2017-08-24 14:38:47 +0100 (Thu, 24 Aug 2017) | 1 line Possible pseudo-code for DXpedition auto-sequencing. ------------------------------------------------------------------------ r8035 | k1jt | 2017-08-25 17:59:58 +0100 (Fri, 25 Aug 2017) | 4 lines Use the most recently edited "CQ xx: message in Tx6 as a template for subsequent regenerations. This means that "CQ DX", "CQ VT", etc., will be presistent until changed back. ------------------------------------------------------------------------ r8036 | k1jt | 2017-08-26 17:30:47 +0100 (Sat, 26 Aug 2017) | 1 line Use a baseline-fitting procedure to improve S/N estimates for FT8. ------------------------------------------------------------------------ r8037 | k1jt | 2017-08-27 13:26:37 +0100 (Sun, 27 Aug 2017) | 1 line Fix the 'Start=0 ==> S/N = -24 dB' problem. ------------------------------------------------------------------------ r8038 | k1jt | 2017-08-27 14:11:56 +0100 (Sun, 27 Aug 2017) | 1 line Change magic 36 back to 37; does this break something else? ------------------------------------------------------------------------ r8039 | k1jt | 2017-08-28 15:32:14 +0100 (Mon, 28 Aug 2017) | 2 lines Correct the behavior of FT8 in "NA VHF Contest mode". ------------------------------------------------------------------------ r8040 | k9an | 2017-08-28 22:09:44 +0100 (Mon, 28 Aug 2017) | 1 line Fix a potential array bounds issue in osd174.f90. ------------------------------------------------------------------------ r8043 | bsomervi | 2017-08-29 04:20:37 +0100 (Tue, 29 Aug 2017) | 1 line Update AD1C cty.dat database to 14th Aug 2017 big CTY.DAT ------------------------------------------------------------------------ r8044 | bsomervi | 2017-08-29 04:20:51 +0100 (Tue, 29 Aug 2017) | 1 line Basic fix of auto sequencing with free text 73 messages, more to come ------------------------------------------------------------------------ r8045 | bsomervi | 2017-08-29 04:46:32 +0100 (Tue, 29 Aug 2017) | 1 line Ensure that auto Tx is disabled when stop Tx on 73 isn't enabled and DX call is cleared ------------------------------------------------------------------------ r8046 | k1jt | 2017-08-29 15:01:55 +0100 (Tue, 29 Aug 2017) | 2 lines Update text in User Guide related to *NA VHF Contest Mode*. ------------------------------------------------------------------------ r8047 | bsomervi | 2017-08-30 03:27:57 +0100 (Wed, 30 Aug 2017) | 7 lines Fix some signoff issues with auto-sequencing 73 messages from other QSOs on frequency should now be ignored rather than being processed. Also some long overdue refactoring and tidying of non-idiomatic C++ code in the logbook directory. ------------------------------------------------------------------------ r8048 | bsomervi | 2017-08-30 14:20:39 +0100 (Wed, 30 Aug 2017) | 1 line Make 73 and RR73 matching of incoming messages for exact while words ------------------------------------------------------------------------ r8049 | k1jt | 2017-08-30 18:06:49 +0100 (Wed, 30 Aug 2017) | 1 line Updates to User Guide. ------------------------------------------------------------------------ git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx-1.8@8050 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
2017-08-31 00:41:52 +00:00
void CountryDat::_removeBrackets(QString &line, const QString a, const QString b) const
{
int s1 = line.indexOf(a);
while (s1 >= 0)
{
int s2 = line.indexOf(b);
line = line.mid(0,s1) + line.mid(s2+1,-1);
s1 = line.indexOf(a);
}
}
Merged from trunk: ------------------------------------------------------------------------ r8016 | k9an | 2017-08-09 16:22:54 +0100 (Wed, 09 Aug 2017) | 1 line Remove call to jtmsg. ------------------------------------------------------------------------ r8017 | k9an | 2017-08-09 16:52:52 +0100 (Wed, 09 Aug 2017) | 1 line Bring a simulation tool up to date. ------------------------------------------------------------------------ r8022 | k9an | 2017-08-13 02:35:13 +0100 (Sun, 13 Aug 2017) | 1 line Improve efficiency of OSD by a factor of 5 to 10 for norder=2 and 3. Use norder=2 for wideband multi-decoding, norder=3 near nfqso and nftx. ------------------------------------------------------------------------ r8026 | k9an | 2017-08-14 16:00:48 +0100 (Mon, 14 Aug 2017) | 1 line Make default MSK144 amplitude polynomial flat. ------------------------------------------------------------------------ r8029 | k1jt | 2017-08-19 14:07:27 +0100 (Sat, 19 Aug 2017) | 1 line Edit the advice displayed by F5. ------------------------------------------------------------------------ r8030 | k1jt | 2017-08-19 23:34:26 +0100 (Sat, 19 Aug 2017) | 1 line Fix a typo. ------------------------------------------------------------------------ r8031 | k9an | 2017-08-22 01:14:51 +0100 (Tue, 22 Aug 2017) | 1 line 1. Improvements to the OSD to allow deeper wideband decoding. 2. Add a third decoding pass. 3. Change symbol metric from max-log to max-amplitude. ------------------------------------------------------------------------ r8032 | k9an | 2017-08-22 01:17:23 +0100 (Tue, 22 Aug 2017) | 1 line Delete unused array. ------------------------------------------------------------------------ r8033 | k9an | 2017-08-22 01:21:59 +0100 (Tue, 22 Aug 2017) | 1 line More cleanup. ------------------------------------------------------------------------ r8034 | k1jt | 2017-08-24 14:38:47 +0100 (Thu, 24 Aug 2017) | 1 line Possible pseudo-code for DXpedition auto-sequencing. ------------------------------------------------------------------------ r8035 | k1jt | 2017-08-25 17:59:58 +0100 (Fri, 25 Aug 2017) | 4 lines Use the most recently edited "CQ xx: message in Tx6 as a template for subsequent regenerations. This means that "CQ DX", "CQ VT", etc., will be presistent until changed back. ------------------------------------------------------------------------ r8036 | k1jt | 2017-08-26 17:30:47 +0100 (Sat, 26 Aug 2017) | 1 line Use a baseline-fitting procedure to improve S/N estimates for FT8. ------------------------------------------------------------------------ r8037 | k1jt | 2017-08-27 13:26:37 +0100 (Sun, 27 Aug 2017) | 1 line Fix the 'Start=0 ==> S/N = -24 dB' problem. ------------------------------------------------------------------------ r8038 | k1jt | 2017-08-27 14:11:56 +0100 (Sun, 27 Aug 2017) | 1 line Change magic 36 back to 37; does this break something else? ------------------------------------------------------------------------ r8039 | k1jt | 2017-08-28 15:32:14 +0100 (Mon, 28 Aug 2017) | 2 lines Correct the behavior of FT8 in "NA VHF Contest mode". ------------------------------------------------------------------------ r8040 | k9an | 2017-08-28 22:09:44 +0100 (Mon, 28 Aug 2017) | 1 line Fix a potential array bounds issue in osd174.f90. ------------------------------------------------------------------------ r8043 | bsomervi | 2017-08-29 04:20:37 +0100 (Tue, 29 Aug 2017) | 1 line Update AD1C cty.dat database to 14th Aug 2017 big CTY.DAT ------------------------------------------------------------------------ r8044 | bsomervi | 2017-08-29 04:20:51 +0100 (Tue, 29 Aug 2017) | 1 line Basic fix of auto sequencing with free text 73 messages, more to come ------------------------------------------------------------------------ r8045 | bsomervi | 2017-08-29 04:46:32 +0100 (Tue, 29 Aug 2017) | 1 line Ensure that auto Tx is disabled when stop Tx on 73 isn't enabled and DX call is cleared ------------------------------------------------------------------------ r8046 | k1jt | 2017-08-29 15:01:55 +0100 (Tue, 29 Aug 2017) | 2 lines Update text in User Guide related to *NA VHF Contest Mode*. ------------------------------------------------------------------------ r8047 | bsomervi | 2017-08-30 03:27:57 +0100 (Wed, 30 Aug 2017) | 7 lines Fix some signoff issues with auto-sequencing 73 messages from other QSOs on frequency should now be ignored rather than being processed. Also some long overdue refactoring and tidying of non-idiomatic C++ code in the logbook directory. ------------------------------------------------------------------------ r8048 | bsomervi | 2017-08-30 14:20:39 +0100 (Wed, 30 Aug 2017) | 1 line Make 73 and RR73 matching of incoming messages for exact while words ------------------------------------------------------------------------ r8049 | k1jt | 2017-08-30 18:06:49 +0100 (Wed, 30 Aug 2017) | 1 line Updates to User Guide. ------------------------------------------------------------------------ git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx-1.8@8050 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
2017-08-31 00:41:52 +00:00
QStringList CountryDat::_extractPrefix(QString &line, bool &more) const
{
line = line.remove(" \n");
line = line.replace("=","");
line = line.replace(" ","");
_removeBrackets(line,"(",")");
_removeBrackets(line,"[","]");
_removeBrackets(line,"<",">");
_removeBrackets(line,"~","~");
int s1 = line.indexOf(';');
more = true;
if (s1 >= 0)
{
line = line.mid(0,s1);
more = false;
}
QStringList r = line.split(',');
return r;
}
void CountryDat::load()
{
_data.clear();
_countryNames.clear(); //used by countriesWorked
QFile inputFile(_filename);
if (inputFile.open(QIODevice::ReadOnly))
{
QTextStream in(&inputFile);
while ( !in.atEnd() )
{
QString line1 = in.readLine();
if ( !in.atEnd() )
{
QString line2 = in.readLine();
QString name = _extractName(line1);
if (name.length()>0)
{
_countryNames << name;
bool more = true;
QStringList prefixs;
while (more)
{
QStringList p = _extractPrefix(line2,more);
prefixs += p;
if (more)
line2 = in.readLine();
}
QString p;
foreach(p,prefixs)
{
if (p.length() > 0)
_data.insert(p,name);
}
}
}
}
inputFile.close();
}
}
// return country name else ""
Merged from trunk: ------------------------------------------------------------------------ r8016 | k9an | 2017-08-09 16:22:54 +0100 (Wed, 09 Aug 2017) | 1 line Remove call to jtmsg. ------------------------------------------------------------------------ r8017 | k9an | 2017-08-09 16:52:52 +0100 (Wed, 09 Aug 2017) | 1 line Bring a simulation tool up to date. ------------------------------------------------------------------------ r8022 | k9an | 2017-08-13 02:35:13 +0100 (Sun, 13 Aug 2017) | 1 line Improve efficiency of OSD by a factor of 5 to 10 for norder=2 and 3. Use norder=2 for wideband multi-decoding, norder=3 near nfqso and nftx. ------------------------------------------------------------------------ r8026 | k9an | 2017-08-14 16:00:48 +0100 (Mon, 14 Aug 2017) | 1 line Make default MSK144 amplitude polynomial flat. ------------------------------------------------------------------------ r8029 | k1jt | 2017-08-19 14:07:27 +0100 (Sat, 19 Aug 2017) | 1 line Edit the advice displayed by F5. ------------------------------------------------------------------------ r8030 | k1jt | 2017-08-19 23:34:26 +0100 (Sat, 19 Aug 2017) | 1 line Fix a typo. ------------------------------------------------------------------------ r8031 | k9an | 2017-08-22 01:14:51 +0100 (Tue, 22 Aug 2017) | 1 line 1. Improvements to the OSD to allow deeper wideband decoding. 2. Add a third decoding pass. 3. Change symbol metric from max-log to max-amplitude. ------------------------------------------------------------------------ r8032 | k9an | 2017-08-22 01:17:23 +0100 (Tue, 22 Aug 2017) | 1 line Delete unused array. ------------------------------------------------------------------------ r8033 | k9an | 2017-08-22 01:21:59 +0100 (Tue, 22 Aug 2017) | 1 line More cleanup. ------------------------------------------------------------------------ r8034 | k1jt | 2017-08-24 14:38:47 +0100 (Thu, 24 Aug 2017) | 1 line Possible pseudo-code for DXpedition auto-sequencing. ------------------------------------------------------------------------ r8035 | k1jt | 2017-08-25 17:59:58 +0100 (Fri, 25 Aug 2017) | 4 lines Use the most recently edited "CQ xx: message in Tx6 as a template for subsequent regenerations. This means that "CQ DX", "CQ VT", etc., will be presistent until changed back. ------------------------------------------------------------------------ r8036 | k1jt | 2017-08-26 17:30:47 +0100 (Sat, 26 Aug 2017) | 1 line Use a baseline-fitting procedure to improve S/N estimates for FT8. ------------------------------------------------------------------------ r8037 | k1jt | 2017-08-27 13:26:37 +0100 (Sun, 27 Aug 2017) | 1 line Fix the 'Start=0 ==> S/N = -24 dB' problem. ------------------------------------------------------------------------ r8038 | k1jt | 2017-08-27 14:11:56 +0100 (Sun, 27 Aug 2017) | 1 line Change magic 36 back to 37; does this break something else? ------------------------------------------------------------------------ r8039 | k1jt | 2017-08-28 15:32:14 +0100 (Mon, 28 Aug 2017) | 2 lines Correct the behavior of FT8 in "NA VHF Contest mode". ------------------------------------------------------------------------ r8040 | k9an | 2017-08-28 22:09:44 +0100 (Mon, 28 Aug 2017) | 1 line Fix a potential array bounds issue in osd174.f90. ------------------------------------------------------------------------ r8043 | bsomervi | 2017-08-29 04:20:37 +0100 (Tue, 29 Aug 2017) | 1 line Update AD1C cty.dat database to 14th Aug 2017 big CTY.DAT ------------------------------------------------------------------------ r8044 | bsomervi | 2017-08-29 04:20:51 +0100 (Tue, 29 Aug 2017) | 1 line Basic fix of auto sequencing with free text 73 messages, more to come ------------------------------------------------------------------------ r8045 | bsomervi | 2017-08-29 04:46:32 +0100 (Tue, 29 Aug 2017) | 1 line Ensure that auto Tx is disabled when stop Tx on 73 isn't enabled and DX call is cleared ------------------------------------------------------------------------ r8046 | k1jt | 2017-08-29 15:01:55 +0100 (Tue, 29 Aug 2017) | 2 lines Update text in User Guide related to *NA VHF Contest Mode*. ------------------------------------------------------------------------ r8047 | bsomervi | 2017-08-30 03:27:57 +0100 (Wed, 30 Aug 2017) | 7 lines Fix some signoff issues with auto-sequencing 73 messages from other QSOs on frequency should now be ignored rather than being processed. Also some long overdue refactoring and tidying of non-idiomatic C++ code in the logbook directory. ------------------------------------------------------------------------ r8048 | bsomervi | 2017-08-30 14:20:39 +0100 (Wed, 30 Aug 2017) | 1 line Make 73 and RR73 matching of incoming messages for exact while words ------------------------------------------------------------------------ r8049 | k1jt | 2017-08-30 18:06:49 +0100 (Wed, 30 Aug 2017) | 1 line Updates to User Guide. ------------------------------------------------------------------------ git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx-1.8@8050 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
2017-08-31 00:41:52 +00:00
QString CountryDat::find(QString prefix) const
{
prefix = prefix.toUpper ();
auto pf = prefix;
while (pf.size () >= 1)
{
if (_data.contains (pf))
{
QString country {_data.value (pf)};
//
// deal with special rules that cty.dat does not cope with
//
// KG4 2x1 and 2x3 calls that map to Gitmo are mainland US not Gitmo
if (prefix.startsWith ("KG4") && prefix.size () != 5)
{
country.replace ("Guantanamo Bay", "United States");
}
return country;
}
pf = pf.left (pf.size () - 1);
}
return QString {};
}