hamcty 0.5.0

Load and search country data for ham radio callsigns in the CTY database
Documentation

HamCTY

NO AI Latest version Coverage

This crate is targeted to read CTY databases in CSV format and make them searchable.

CTY files are databases to get country information and other Ham Radio relevant zone infos for contests, etc.

The database contains a mapping for all country prefixes to the country data and provides overrides for CQ and ITU zones for various callsigns or prefixes.

A CTY database is already included, but it is certainly out of date.

So you can also load a more recent version from the website above. The crate can either use the regular CTY or the Big CTY. Just unpack the newest offered ZIP archive from the website above and point to the cty.csv.

API usage

use hamcty::{CountryDatabase, CtyType, load_recent_cty};

fn main() {
    // Use crate internal data (maybe not up to date)...
    let cdb = CountryDatabase::new();
    
    // ...or load recent CTY and load data from path (you decide about the version)
    load_recent_cty("cty.csv", CtyType::Cty).expect("Could not load recent CTY");
    let cdb = CountryDatabase::from_path("cty.csv").expect("Could not load cty data");
    
    assert_eq!(cdb.country(call).unwrap().code, "DL");
    assert_eq!(cdb.prefix(call), Ok("DF".to_string()));
}

Example: search_cty

search_cty is a little overengineered shell to search the database from the commandline.

You also can download the most recent CTY or Big CTY with --load.

Precompiled binaries of this tool can be found in the releases.

Usage (per default, search_cty uses the internal CTY database)

./search_cty

Then enter a callsign at the prompt and the country data should be provided.

callsign> df1asc
  => Country {
     code: "DL",
     name: "Fed. Rep. of Germany",
     dxcc: 230,
     continent: Europe,
     ...

To get the prefix of a callsign switch to prefix mode (switch back with country)

callsign> prefix
 => set result to 'prefix'
callsign> df1asc
 => DF 

You can leave the shell with exit or quit.

See ./search_cty --help for more options.

Origin

This is just another port from some own Python code. This code was ported from a DragonLog module.

To see the differences in performance I have written a similar benchmark for both. The benchmarks are searching 100 times for 20 different callsigns which also utilize different zone overwrites.

The first value is for CTY, the second for BigCTY.

pyhamcty hamcty_rs
Loading 39.132 / 117.4 ms 8 / 28 ms
Searching 311.125 / 501.82 ms 1.6 ms

The ~ 200 times performance increase in searching may lead me to create a python binding to substitute the existing pure Python module.