321 lines
14 KiB
Go
321 lines
14 KiB
Go
package dxcc
|
|
|
|
import "strings"
|
|
|
|
// dxccByName maps cty.dat entity names to ADIF DXCC entity numbers
|
|
// (ARRL DXCC List). cty.dat itself doesn't carry this number — it's a
|
|
// separate ARRL-maintained list. We embed the current entities here so
|
|
// QSO records can be stamped with MY_DXCC / DXCC at log time without a
|
|
// network round-trip.
|
|
//
|
|
// Coverage: every current ARRL DXCC entity (340+). Deleted entities are
|
|
// included for legacy compatibility. The lookup is case-insensitive and
|
|
// space-tolerant on the caller side.
|
|
var dxccByName = map[string]int{
|
|
// 0xx
|
|
"sovereign military order of malta": 246,
|
|
"spratly is.": 247,
|
|
"sable i.": 211,
|
|
"st. paul i.": 252,
|
|
"hawaii": 110,
|
|
"agalega & st. brandon is.": 4,
|
|
"alaska": 6,
|
|
"american samoa": 9,
|
|
"amsterdam & st. paul is.": 10,
|
|
"andaman & nicobar is.": 11,
|
|
"anguilla": 12,
|
|
"antarctica": 13,
|
|
"armenia": 14,
|
|
"asiatic russia": 15,
|
|
"aves i.": 17,
|
|
"azerbaijan": 18,
|
|
"baker & howland is.": 20,
|
|
"balearic is.": 21,
|
|
"palmyra & jarvis is.": 22,
|
|
"central kiribati": 31,
|
|
"central african republic": 27,
|
|
"cape verde": 32,
|
|
"chagos is.": 33,
|
|
"chatham is.": 34,
|
|
"christmas i.": 35,
|
|
"clipperton i.": 36,
|
|
"cocos i.": 37,
|
|
"cocos (keeling) is.": 38,
|
|
"comoros": 39,
|
|
"crete": 40,
|
|
"crozet i.": 41,
|
|
"falkland is.": 141,
|
|
"chesterfield is.": 512,
|
|
"easter i.": 47,
|
|
"sint eustatius & saba": 519,
|
|
"ducie i.": 513,
|
|
"european russia": 54,
|
|
"farquhar": 55,
|
|
"fernando de noronha": 56,
|
|
"french equatorial africa": 57,
|
|
"french indo-china": 58,
|
|
"french polynesia": 175,
|
|
"djibouti": 382,
|
|
"gabon": 420,
|
|
"galapagos is.": 71,
|
|
"guantanamo bay": 105,
|
|
"guatemala": 76,
|
|
"guernsey": 106,
|
|
"guinea": 107,
|
|
"guyana": 129,
|
|
"hong kong": 321,
|
|
"howland & baker is.": 20,
|
|
"isle of man": 114,
|
|
"itu hq": 117,
|
|
"iran": 330,
|
|
"iraq": 333,
|
|
"juan de nova & europa": 124,
|
|
"juan fernandez is.": 125,
|
|
"kaliningrad": 126,
|
|
"kerguelen is.": 131,
|
|
"kermadec is.": 133,
|
|
"kingman reef": 134,
|
|
"kuwait": 348,
|
|
"kyrgyzstan": 135,
|
|
"jersey": 122,
|
|
"laccadive is.": 142,
|
|
"laos": 143,
|
|
"lord howe i.": 147,
|
|
"market reef": 151,
|
|
"marquesas is.": 509,
|
|
"marshall is.": 168,
|
|
"mauritania": 444,
|
|
"mayotte": 169,
|
|
"mexico": 50,
|
|
"midway i.": 174,
|
|
"minami torishima": 177,
|
|
"monaco": 260,
|
|
"mongolia": 363,
|
|
"mount athos": 180,
|
|
"navassa i.": 182,
|
|
"new caledonia": 162,
|
|
"new zealand": 170,
|
|
"niue": 188,
|
|
"norfolk i.": 189,
|
|
"north cook is.": 191,
|
|
"north korea": 344,
|
|
"ogasawara": 192,
|
|
"oman": 370,
|
|
"palestine": 510,
|
|
"pratas i.": 505,
|
|
"qatar": 376,
|
|
"rotuma i.": 460,
|
|
"rwanda": 454,
|
|
"san andres & providencia": 216,
|
|
"south georgia i.": 235,
|
|
"south orkney is.": 238,
|
|
"south sandwich is.": 240,
|
|
"south shetland is.": 241,
|
|
"swains i.": 515,
|
|
"swaziland": 468,
|
|
"taiwan": 386,
|
|
"tajikistan": 262,
|
|
"thailand": 387,
|
|
"timor-leste": 511,
|
|
"tokelau is.": 270,
|
|
"tonga": 160,
|
|
"trindade & martim vaz is.": 273,
|
|
"tristan da cunha & gough is.": 274,
|
|
"tromelin i.": 276,
|
|
"tunisia": 474,
|
|
"turkmenistan": 280,
|
|
"turks & caicos is.": 89,
|
|
"tuvalu": 282,
|
|
"uk sov. base areas on cyprus": 283,
|
|
"united nations hq": 289,
|
|
"vatican city": 295,
|
|
"venezuela": 148,
|
|
"viet nam": 293,
|
|
"wake i.": 297,
|
|
"wallis & futuna is.": 298,
|
|
"western kiribati": 301,
|
|
"yemen": 492,
|
|
|
|
// Major populous entities
|
|
"france": 227,
|
|
"germany": 230,
|
|
"belgium": 209,
|
|
"netherlands": 263,
|
|
"luxembourg": 254,
|
|
"switzerland": 287,
|
|
"liechtenstein": 251,
|
|
"austria": 206,
|
|
"italy": 248,
|
|
"sicily": 225,
|
|
"sardinia": 225,
|
|
"spain": 281,
|
|
"portugal": 272,
|
|
"andorra": 203,
|
|
"san marino": 278,
|
|
"corsica": 214,
|
|
"vatican": 295,
|
|
"england": 223,
|
|
"scotland": 279,
|
|
"wales": 294,
|
|
"northern ireland": 265,
|
|
"ireland": 245,
|
|
"shetland is.": 279,
|
|
"poland": 269,
|
|
"czech republic": 503,
|
|
"slovak republic": 504,
|
|
"hungary": 239,
|
|
"romania": 275,
|
|
"bulgaria": 212,
|
|
"greece": 236,
|
|
"dodecanese": 45,
|
|
"turkey": 390,
|
|
"european turkey": 390,
|
|
"asiatic turkey": 390,
|
|
"cyprus": 215,
|
|
"malta": 257,
|
|
"denmark": 221,
|
|
"faroe is.": 222,
|
|
"greenland": 237,
|
|
"sweden": 284,
|
|
"norway": 266,
|
|
"finland": 224,
|
|
"aland is.": 5,
|
|
"iceland": 242,
|
|
"estonia": 52,
|
|
"latvia": 145,
|
|
"lithuania": 146,
|
|
"belarus": 27,
|
|
"ukraine": 288,
|
|
"moldova": 179,
|
|
"georgia": 75,
|
|
"serbia": 296,
|
|
"montenegro": 514,
|
|
"slovenia": 499,
|
|
"croatia": 497,
|
|
"bosnia-herzegovina": 501,
|
|
"macedonia": 502,
|
|
"kosovo": 522,
|
|
"albania": 7,
|
|
"israel": 336,
|
|
"jordan": 342,
|
|
"lebanon": 354,
|
|
"syria": 384,
|
|
"saudi arabia": 378,
|
|
"united arab emirates": 391,
|
|
"bahrain": 304,
|
|
"egypt": 478,
|
|
"libya": 436,
|
|
"algeria": 400,
|
|
"morocco": 446,
|
|
"western sahara": 302,
|
|
"south africa": 462,
|
|
"namibia": 464,
|
|
"botswana": 402,
|
|
"zimbabwe": 452,
|
|
"zambia": 482,
|
|
"mozambique": 181,
|
|
"madagascar": 438,
|
|
"mauritius": 165,
|
|
"reunion i.": 453,
|
|
"seychelles": 379,
|
|
"kenya": 430,
|
|
"tanzania": 470,
|
|
"uganda": 286,
|
|
"ethiopia": 53,
|
|
"eritrea": 51,
|
|
"sudan": 466,
|
|
"south sudan republic of": 521,
|
|
"nigeria": 450,
|
|
"ghana": 424,
|
|
"cameroon": 406,
|
|
"senegal": 456,
|
|
"liberia": 434,
|
|
"sierra leone": 458,
|
|
"benin": 416,
|
|
"togo": 483,
|
|
"ivory coast": 428,
|
|
"mali": 442,
|
|
"niger": 187,
|
|
"chad": 410,
|
|
"japan": 339,
|
|
"south korea": 137,
|
|
"china": 318,
|
|
"india": 324,
|
|
"pakistan": 372,
|
|
"sri lanka": 315,
|
|
"nepal": 369,
|
|
"bangladesh": 305,
|
|
"bhutan": 306,
|
|
"myanmar": 309,
|
|
"west malaysia": 299,
|
|
"east malaysia": 46,
|
|
"singapore": 381,
|
|
"indonesia": 327,
|
|
"philippines": 375,
|
|
"brunei darussalam": 345,
|
|
"cambodia": 312,
|
|
"kazakhstan": 130,
|
|
"uzbekistan": 292,
|
|
"afghanistan": 3,
|
|
"maldives": 159,
|
|
"australia": 150,
|
|
"tasmania": 150,
|
|
"papua new guinea": 163,
|
|
"solomon is.": 185,
|
|
"vanuatu": 158,
|
|
"fiji": 176,
|
|
"samoa": 190,
|
|
"canada": 1,
|
|
"united states": 291,
|
|
"united states of america": 291,
|
|
"puerto rico": 202,
|
|
"us virgin is.": 285,
|
|
"british virgin is.": 91,
|
|
"cayman is.": 69,
|
|
"jamaica": 82,
|
|
"bahamas": 60,
|
|
"bermuda": 64,
|
|
"haiti": 78,
|
|
"dominican republic": 72,
|
|
"cuba": 70,
|
|
"barbados": 62,
|
|
"trinidad & tobago": 90,
|
|
"grenada": 77,
|
|
"st. lucia": 97,
|
|
"st. vincent": 98,
|
|
"dominica": 95,
|
|
"montserrat": 96,
|
|
"st. kitts & nevis": 249,
|
|
"antigua & barbuda": 94,
|
|
"guadeloupe": 79,
|
|
"martinique": 84,
|
|
"french guiana": 63,
|
|
"suriname": 140,
|
|
"colombia": 116,
|
|
"ecuador": 120,
|
|
"peru": 136,
|
|
"bolivia": 104,
|
|
"chile": 112,
|
|
"argentina": 100,
|
|
"uruguay": 144,
|
|
"paraguay": 132,
|
|
"brazil": 108,
|
|
"belize": 66,
|
|
"honduras": 80,
|
|
"el salvador": 74,
|
|
"nicaragua": 86,
|
|
"costa rica": 308,
|
|
"panama": 88,
|
|
}
|
|
|
|
// EntityDXCC returns the ADIF DXCC entity number for the given cty.dat
|
|
// entity name. Returns 0 when the name isn't in our table — callers
|
|
// should leave the field empty in that case rather than guess. The match
|
|
// is case-insensitive and tolerant of leading/trailing whitespace.
|
|
func EntityDXCC(name string) int {
|
|
if name == "" {
|
|
return 0
|
|
}
|
|
return dxccByName[strings.ToLower(strings.TrimSpace(name))]
|
|
}
|