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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
use error::Error;
use result::Result;
#[derive(Clone, Copy, Debug, Default)]
#[allow(missing_docs)]
pub struct Point {
pub time: f64,
pub range: f32,
pub theta: f32,
pub x: f32,
pub y: f32,
pub z: f32,
pub amplitude: u16,
pub width: u16,
pub target_type: TargetType,
pub target: u8,
pub num_target: u8,
pub rg_index: u16,
pub facet_number: u8,
pub high_channel: bool,
pub class_id: Option<u8>,
pub rho: Option<f32>,
pub reflectance: Option<i16>,
}
impl Point {
pub fn new() -> Point {
Default::default()
}
pub fn channel_desc_byte(&self) -> u8 {
let mut byte = self.facet_number & 0x3;
if self.high_channel {
byte |= 0b01000000;
}
byte
}
}
#[derive(Clone, Copy, Debug, PartialEq)]
#[allow(missing_docs)]
pub enum TargetType {
CenterOfGravity,
Parabola,
Gaussian,
Peak,
}
impl TargetType {
pub fn as_u8(&self) -> u8 {
match *self {
TargetType::CenterOfGravity => 0,
TargetType::Parabola => 1,
TargetType::Gaussian => 2,
TargetType::Peak => 3,
}
}
pub fn from_u8(n: u8) -> Result<TargetType> {
match n {
0 => Ok(TargetType::CenterOfGravity),
1 => Ok(TargetType::Parabola),
2 => Ok(TargetType::Gaussian),
3 => Ok(TargetType::Peak),
_ => Err(Error::InvalidTargetType(n)),
}
}
}
impl Default for TargetType {
fn default() -> TargetType {
TargetType::Peak
}
}