Added min and max values to json.

[?]
CrEcTsRjb1hHQjHuumqRfqdbVV4X58iLEubi4noaDPFa
Jul 25, 2021, 5:14 AM
R2OU7BE4I4QC5IRZU7BJGHJQNTBNF3265LOHZB3QQDQD7OL46G5AC

Dependencies

  • [2] YAE43L6A Completed first try at UIData.
  • [3] XI5ALEH6 Take advantage of keytree FromStr functionality.
  • [4] TTR5IFSG Working on building generic TSSpec.
  • [5] GQVS55HI Finished generate_ts_spec() function.
  • [6] 4QOTH75I Fixed UI specification code.

Change contents

  • edit in src/ui.rs at line 31
    [3.54]
    [2.252]
    #[derive(Debug)]
  • replacement in src/ui.rs at line 35
    [2.341][2.341:465]()
    pub struct FixedScale {
    x_max: f32,
    x_min: f32,
    y_max: f32,
    y_min: f32,
    [2.341]
    [2.465]
    pub enum Scale {
    Group {
    x_min: f32,
    x_max: f32,
    y_min: f32,
    y_max: f32,
    },
    Single {
    x_min: f32,
    x_max: f32,
    y_min: f32,
    y_max: f32,
    },
  • replacement in src/ui.rs at line 53
    [2.539][2.539:597]()
    pub fn into_ui_data(&self) -> Result<UIData, Error> {
    [2.539]
    [2.597]
    pub fn into_data(&self) -> Result<UIData, Error> {
  • replacement in src/ui.rs at line 75
    [2.1176][2.1176:1212]()
    sized: Option<FixedScale>,
    [2.1176]
    [3.988]
    scale: Scale,
  • edit in src/ui.rs at line 85
    [2.1437]
    [3.1112]
    }
    pub struct GraphicBuilder {
    lines: Vec<LineJson>,
    x_min: Option<f32>,
    x_max: Option<f32>,
    y_min: Option<f32>,
    y_max: Option<f32>,
  • edit in src/ui.rs at line 94
    [3.1114]
    [3.235]
    impl GraphicBuilder {
    // Update if required
    fn x_min(&mut self, x: f32) {
    match self.x_min {
    None => self.x_min = Some(x),
    Some(old) => if x < old { self.x_min = Some(x) },
    }
    }
    // Update if required
    fn x_max(&mut self, x: f32) {
    match self.x_max {
    None => self.x_min = Some(x),
    Some(old) => if x > old { self.x_max = Some(x) },
    }
    }
  • edit in src/ui.rs at line 112
    [3.236]
    [2.1438]
    // Update if required
    fn y_min(&mut self, y: f32) {
    match self.y_min {
    None => self.y_min = Some(y),
    Some(old) => if y < old { self.y_min = Some(y) },
    }
    }
    // Update if required
    fn y_max(&mut self, y: f32) {
    match self.y_max {
    None => self.y_min = Some(y),
    Some(old) => if y > old { self.y_max = Some(y) },
    }
    }
    fn scale(&self) -> Scale {
    Scale::Single {
    x_min: self.x_min.unwrap(),
    x_max: self.x_max.unwrap(),
    y_min: self.y_min.unwrap(),
    y_max: self.y_max.unwrap(),
    }
    }
    }
    #[derive(Debug)]
  • edit in src/ui.rs at line 140
    [2.1473]
    [3.474]
  • replacement in src/ui.rs at line 161
    [2.2031][2.2031:2101]()
    kt.to_ref().try_into().map_err(|err: keytree::error::Error| {
    [2.2031]
    [2.2101]
    dbg!(&kt);
    let out = kt.to_ref().try_into().map_err(|err: keytree::error::Error| {
  • replacement in src/ui.rs at line 164
    [2.2163][2.2163:2175]()
    })
    [2.2163]
    [2.2175]
    });
    out
  • replacement in src/ui.rs at line 179
    [3.1071][2.2424:2656]()
    // GraphicJson builder
    let mut graphic_json = GraphicJson {
    country: *country,
    index: *index,
    lines: Vec::new(),
    sized: None,
    [3.1071]
    [2.2656]
    dbg!((country, index));
    let mut graphic_json_builder = GraphicBuilder {
    lines: Vec::new(),
    x_min: None,
    x_max: None,
    y_min: None,
    y_max: None,
  • edit in src/ui.rs at line 203
    [2.3176]
    [3.1303]
    let x_min = x_rts.min(0);
    let x_max = x_rts.max(0);
  • edit in src/ui.rs at line 216
    [2.3610]
    [3.1897]
    let y_min = y_rts.min(0);
    let y_max = y_rts.max(0);
  • replacement in src/ui.rs at line 229
    [2.4034][2.4034:4086]()
    graphic_json.lines.push(line_json);
    [2.4034]
    [3.2661]
    graphic_json_builder.lines.push(line_json);
    graphic_json_builder.x_min(x_min);
    graphic_json_builder.x_max(x_max);
    graphic_json_builder.y_min(y_min);
    graphic_json_builder.y_max(y_max);
  • edit in src/ui.rs at line 235
    [3.2675]
    [2.4087]
    let graphic_json = GraphicJson {
    country: *country,
    index: *index,
    scale: graphic_json_builder.scale(),
    lines: graphic_json_builder.lines,
    };
  • replacement in src/ui.rs at line 254
    [3.1573][2.4285:4339]()
    Spec(self.vec_at("ui_spec::ui_graphic")?)
    [3.1573]
    [3.1694]
    Spec(self.vec_at("ui_spec::graphic")?)
  • edit in src/ui.rs at line 259
    [3.1756]
    [2.4340]
    #[derive(Debug)]
  • edit in src/ui.rs at line 289
    [3.4134]
    [2.5099]
    #[derive(Debug)]