/rust/registry/src/index.crates.io-1949cf8c6b5b557f/sofars-0.6.1/src/vm/af2a.rs
Line | Count | Source |
1 | | use crate::consts::DAS2R; |
2 | | |
3 | | /// Convert degrees, arcminutes, arcseconds to radians. |
4 | | #[inline] |
5 | 0 | pub fn af2a(s: char, ideg: i32, iamin: i32, asec: f64) -> Result<f64, i32> { |
6 | | let rad: f64; |
7 | 0 | rad = match s { |
8 | 0 | '-' => -1.0, |
9 | 0 | _ => 1.0, |
10 | 0 | } * (60.0 * (60.0 * ideg as f64 + iamin as f64) + asec as f64) |
11 | | * DAS2R; |
12 | | |
13 | | /* Validate arguments and return status. */ |
14 | 0 | if ideg < 0 || ideg > 359 { |
15 | 0 | return Err(1); |
16 | 0 | } |
17 | 0 | if iamin < 0 || iamin > 59 { |
18 | 0 | return Err(2); |
19 | 0 | } |
20 | 0 | if asec < 0.0 || asec >= 60.0 { |
21 | 0 | return Err(3); |
22 | 0 | } |
23 | | |
24 | 0 | Ok(rad) |
25 | 0 | } |