1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// a:rot
use super::super::Int32Value;
use quick_xml::events::BytesStart;
use quick_xml::Reader;
use quick_xml::Writer;
use reader::driver::*;
use std::io::Cursor;
use writer::driver::*;

#[derive(Clone, Default, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub struct Rotation {
    latitude: Int32Value,
    longitude: Int32Value,
    revolution: Int32Value,
}

impl Rotation {
    pub fn get_latitude(&self) -> &i32 {
        self.latitude.get_value()
    }

    pub fn set_latitude(&mut self, value: i32) -> &mut Self {
        self.latitude.set_value(value);
        self
    }

    pub fn get_longitude(&self) -> &i32 {
        self.longitude.get_value()
    }

    pub fn set_longitude(&mut self, value: i32) -> &mut Self {
        self.longitude.set_value(value);
        self
    }

    pub fn get_revolution(&self) -> &i32 {
        self.revolution.get_value()
    }

    pub fn set_revolution(&mut self, value: i32) -> &mut Self {
        self.revolution.set_value(value);
        self
    }

    pub(crate) fn set_attributes<R: std::io::BufRead>(
        &mut self,
        _reader: &mut Reader<R>,
        e: &BytesStart,
    ) {
        set_string_from_xml!(self, e, latitude, "lat");
        set_string_from_xml!(self, e, longitude, "lon");
        set_string_from_xml!(self, e, revolution, "rev");
    }

    pub(crate) fn write_to(&self, writer: &mut Writer<Cursor<Vec<u8>>>) {
        let mut attributes: Vec<(&str, &str)> = Vec::new();
        let latitude = self.latitude.get_value_string();
        if self.latitude.has_value() {
            attributes.push(("lat", &latitude));
        }
        let longitude = self.longitude.get_value_string();
        if self.longitude.has_value() {
            attributes.push(("lon", &longitude));
        }
        let revolution = self.revolution.get_value_string();
        if self.latitude.has_value() {
            attributes.push(("rev", &revolution));
        }
        write_start_tag(writer, "a:rot", attributes, true);
    }
}