use rinex::*;
use super::{
Plot2d,
build_chart, build_plot,
};
use plotters::{
prelude::*,
coord::Shift,
chart::ChartState,
};
use std::collections::HashMap;
mod meteo;
mod navigation;
mod observation;
pub struct Context<'a> {
pub plots: HashMap<String, DrawingArea<BitMapBackend<'a>, Shift>>,
pub charts: HashMap<String, ChartState<Plot2d>>,
pub t_axis: Vec<f64>,
}
impl Default for Context<'_> {
fn default() -> Self {
Self {
t_axis: Vec::new(),
charts: HashMap::new(),
plots: HashMap::new(),
}
}
}
impl<'a> Context<'a> {
pub fn new (dim: (u32,u32), rnx: &Rinex) -> Self {
if let Some(record) = rnx.record.as_obs() {
observation::build_context(dim, record)
} else if let Some(record) = rnx.record.as_nav() {
navigation::build_context(dim, record)
} else if let Some(record) = rnx.record.as_meteo() {
meteo::build_context(dim, record)
} else {
panic!("this type of record cannot be plotted yet");
}
}
}
pub fn plot(ctx: &mut Context, rnx: &Rinex, nav: Option<Rinex>) {
if let Some(record) = rnx.record.as_obs() {
observation::plot(ctx, record, nav)
} else if let Some(record) = rnx.record.as_nav() {
navigation::plot(ctx, record)
} else if let Some(record) = rnx.record.as_meteo() {
meteo::plot(ctx, record)
} else {
panic!("this type of RINEX record cannot be plotted yet");
}
}