1
1
//! Antex - special RINEX type specific structures
2
- use crate :: channel;
2
+ use crate :: channel:: Channel ;
3
3
4
4
#[ derive( Debug , Clone , PartialEq , PartialOrd ) ]
5
5
#[ cfg_attr( feature = "serde" , derive( Serialize ) ) ]
@@ -48,7 +48,7 @@ impl Pattern {
48
48
#[ cfg_attr( feature = "serde" , derive( Serialize ) ) ]
49
49
pub struct Frequency {
50
50
/// Channel, example: L1, L2 for GPS, E1, E5 for GAL...
51
- pub channel : channel :: Channel ,
51
+ pub channel : Channel ,
52
52
/// Northern component of the mean antenna phase center
53
53
/// relative to the antenna reference point (ARP),
54
54
/// in [mm]
@@ -70,7 +70,7 @@ pub struct Frequency {
70
70
impl Default for Frequency {
71
71
fn default ( ) -> Self {
72
72
Self {
73
- channel : channel :: Channel :: default ( ) ,
73
+ channel : Channel :: default ( ) ,
74
74
north : 0.0_f64 ,
75
75
east : 0.0_f64 ,
76
76
up : 0.0_f64 ,
@@ -80,7 +80,53 @@ impl Default for Frequency {
80
80
}
81
81
82
82
impl Frequency {
83
- pub fn with_channel ( & self , channel : channel:: Channel ) -> Self {
83
+ /// Returns ARP coordinates in Geodetic system.
84
+ /// Ref. position must be given in (lat, lon, altitude) [m]
85
+ pub fn arp_geodetic ( & self , ref_pos : ( f64 , f64 , f64 ) ) -> ( f64 , f64 , f64 ) {
86
+ map_3d:: enu2geodetic (
87
+ self . east * 10.0E-3 ,
88
+ self . north * 10.0E-3 ,
89
+ self . up * 10.0E-3 ,
90
+ ref_pos. 0 ,
91
+ ref_pos. 1 ,
92
+ ref_pos. 2 ,
93
+ map_3d:: Ellipsoid :: WGS84 ,
94
+ )
95
+ }
96
+ /// Returns ARP coordinates in ECEF system.
97
+ pub fn arp_ecef ( & self , ref_pos : ( f64 , f64 , f64 ) ) -> ( f64 , f64 , f64 ) {
98
+ map_3d:: enu2ecef (
99
+ self . east * 10.0E-3 ,
100
+ self . north * 10.0E-3 ,
101
+ self . up * 10.0E-3 ,
102
+ ref_pos. 0 ,
103
+ ref_pos. 1 ,
104
+ ref_pos. 2 ,
105
+ map_3d:: Ellipsoid :: WGS84 ,
106
+ )
107
+ }
108
+ /// Returns ARP coordinates as North Earth Down coordinates
109
+ pub fn arp_ned ( & self , ref_pos : ( f64 , f64 , f64 ) ) -> ( f64 , f64 , f64 ) {
110
+ let ecef = map_3d:: enu2ecef (
111
+ self . east * 10.0E-3 ,
112
+ self . north * 10.0E-3 ,
113
+ self . up * 10.0E-3 ,
114
+ ref_pos. 0 ,
115
+ ref_pos. 1 ,
116
+ ref_pos. 2 ,
117
+ map_3d:: Ellipsoid :: WGS84 ,
118
+ ) ;
119
+ map_3d:: ecef2ned (
120
+ ecef. 0 ,
121
+ ecef. 1 ,
122
+ ecef. 2 ,
123
+ ref_pos. 0 ,
124
+ ref_pos. 1 ,
125
+ ref_pos. 2 ,
126
+ map_3d:: Ellipsoid :: WGS84 ,
127
+ )
128
+ }
129
+ pub fn with_channel ( & self , channel : Channel ) -> Self {
84
130
let mut f = self . clone ( ) ;
85
131
f. channel = channel. clone ( ) ;
86
132
f
@@ -106,3 +152,22 @@ impl Frequency {
106
152
f
107
153
}
108
154
}
155
+
156
+ #[ cfg( test) ]
157
+ mod test {
158
+ use super :: * ;
159
+ #[ test]
160
+ fn test_pattern ( ) {
161
+ let default = Pattern :: default ( ) ;
162
+ assert_eq ! ( default , Pattern :: NonAzimuthDependent ( Vec :: new( ) ) ) ;
163
+ assert_eq ! ( default . is_azimuth_dependent( ) , false ) ;
164
+ }
165
+ #[ test]
166
+ fn test_frequency ( ) {
167
+ let default = Frequency :: default ( ) ;
168
+ assert_eq ! ( default . channel, Channel :: default ( ) ) ;
169
+ assert_eq ! ( default . north, 0.0_f64 ) ;
170
+ assert_eq ! ( default . east, 0.0_f64 ) ;
171
+ assert_eq ! ( default . up, 0.0_f64 ) ;
172
+ }
173
+ }
0 commit comments