mod diff;
mod filegen;
mod merge;
mod split;
mod tbin;
#[cfg(feature = "csv")]
pub mod csv;
pub use diff::diff;
pub use filegen::filegen;
pub use merge::merge;
pub use split::split;
pub use tbin::time_binning;
use clap::ArgMatches;
use rinex::{
prelude::Rinex,
prod::{DataSource, DetailedProductionAttributes, ProductionAttributes, FFU, PPU},
};
fn custom_prod_attributes(rinex: &Rinex, matches: &ArgMatches) -> ProductionAttributes {
let mut opts = rinex.guess_production_attributes();
if let Some(agency) = matches.get_one::<String>("agency") {
opts.name = agency.to_string();
}
if let Some(country) = matches.get_one::<String>("country") {
if let Some(ref mut details) = opts.details {
details.country = country[..3].to_string();
} else {
let mut default = DetailedProductionAttributes::default();
default.country = country[..3].to_string();
opts.details = Some(default);
}
}
if let Some(batch) = matches.get_one::<u8>("batch") {
if let Some(ref mut details) = opts.details {
details.batch = *batch;
} else {
let mut default = DetailedProductionAttributes::default();
default.batch = *batch;
opts.details = Some(default);
}
}
if let Some(src) = matches.get_one::<DataSource>("source") {
if let Some(ref mut details) = opts.details {
details.data_src = *src;
} else {
let mut default = DetailedProductionAttributes::default();
default.data_src = *src;
opts.details = Some(default);
}
}
if let Some(ppu) = matches.get_one::<PPU>("ppu") {
if let Some(ref mut details) = opts.details {
details.ppu = *ppu;
} else {
let mut default = DetailedProductionAttributes::default();
default.ppu = *ppu;
opts.details = Some(default);
}
}
if let Some(ffu) = matches.get_one::<FFU>("ffu") {
if let Some(ref mut details) = opts.details {
details.ffu = Some(*ffu);
} else {
let mut default = DetailedProductionAttributes::default();
default.ffu = Some(*ffu);
opts.details = Some(default);
}
}
opts
}
fn output_filename(
rinex: &Rinex,
matches: &ArgMatches,
submatches: &ArgMatches,
prod: ProductionAttributes,
) -> String {
let short = submatches.get_flag("short");
let gzip = if submatches.get_flag("gzip") {
Some(".gz")
} else {
None
};
let csv = submatches.get_flag("csv");
if let Some(custom) = matches.get_one::<String>("output-name") {
if gzip.is_some() {
if csv {
format!("{}.csv.gz", custom)
} else {
format!("{}.gz", custom)
}
} else {
if csv {
format!("{}.csv", custom)
} else {
custom.to_string()
}
}
} else {
debug!("{:?}", prod);
rinex.standard_filename(short, gzip, Some(prod))
}
}