Skip to content

Commit 1a49630

Browse files
authored
Merge pull request #30 from nav-solutions/sv_builder
SBAS/GEO SV builder
2 parents a36d964 + 1312621 commit 1a49630

File tree

6 files changed

+154
-106
lines changed

6 files changed

+154
-106
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ Cargo.lock
1212

1313
# MSVC Windows builds of rustc generate these, which store debugging information
1414
*.pdb
15+
16+
*.pyc

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "gnss-rs"
3-
version = "2.4.1"
3+
version = "2.5.0"
44
license = "MPL-2.0"
55
authors = ["Guillaume W. Bres <guillaume.bressaix@gmail.com>"]
66
description = "GNSS constellations"

README.md

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,39 +29,51 @@ extern crate gnss_rs as gnss;
2929

3030
## Space Vehicles
3131

32+
A small library to define and handle satellite vehicles and constellation.
33+
3234
```rust
33-
extern crate gnss_rs as gnss;
35+
use gnss_rs::sv;
36+
use gnss_rs::prelude::*;
3437

35-
use gnss::sv;
36-
use gnss::prelude::*;
3738
use std::str::FromStr;
38-
use hifitime::TimeScale;
39+
use hifitime::{TimeScale, Epoch};
3940

41+
// This method lets you construct satellites that may not exist
4042
let sv = SV::new(Constellation::GPS, 1);
43+
4144
assert_eq!(sv.constellation, Constellation::GPS);
4245
assert_eq!(sv.prn, 1);
43-
assert_eq!(sv.timescale(), Some(TimeScale::GPST));
44-
assert_eq!(sv, sv!("G01"));
45-
assert_eq!(sv.launched_date(), None);
46+
assert_eq!(sv.launch_date(), None); // only for SBAS vehicles
4647
```
4748

48-
## SBAS support
49-
50-
We support SBAS (geostationary augmentations) systems.
49+
## SBAS (Geostationary) vehicles
5150

51+
The library integrates a smart SBAS constellation identifier. We use the RINEX
52+
convention (PRN ranging from 0..100), therefore the true satellite number
53+
of SBAS vehicles is the PRN we use +100.
54+
5255
```rust
53-
extern crate gnss_rs as gnss;
56+
use gnss_rs::sv;
57+
use gnss_rs::prelude::*;
5458

55-
use gnss::sv;
56-
use gnss::prelude::*;
5759
use std::str::FromStr;
58-
use hifitime::{Epoch, TimeScale};
60+
use hifitime::{TimeScale, Epoch, MonthName};
61+
62+
// This only works if satellite do exist in our database
63+
assert!(SV::new_sbas(1).is_none());
64+
65+
let egnos_geo23 = SV::new_sbas(23)
66+
.unwrap(); // GEO #123
67+
68+
assert_eq!(egnos_geo23.prn, 23);
69+
assert!(egnos_geo23.constellation.is_sbas()); // obviously
70+
assert_eq!(egnos_geo23.constellation, Constellation::EGNOS); // smart builder
71+
72+
let launch_date = egnos_geo23.launch_date()
73+
.unwrap(); // only for detailed SBAS
5974

60-
let sv = sv!("S23");
61-
assert_eq!(sv.constellation, Constellation::EGNOS);
62-
let launched_date = Epoch::from_str("2021-11-01T00:00:00 UTC")
63-
.unwrap();
64-
assert_eq!(sv.launched_date(), Some(launched_date));
75+
assert_eq!(launch_date.year(), 2021);
76+
assert_eq!(launch_date.month_name(), MonthName::November);
6577
```
6678

6779
## Other definitions and features
@@ -98,4 +110,4 @@ Amongst them, be sure to checkout:
98110
## License
99111

100112
This library is part of the [NAV-Solutions framework](https://github.com/nav-solutions) which
101-
is delivered under the [Mozilla V2 Public](https://www.mozilla.org/en-US/MPL/2.0) license.
113+
is licensed under [Mozilla V2 Public](https://www.mozilla.org/en-US/MPL/2.0) license.

build.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn default_launch_day() -> u8 {
1414

1515
/*
1616
* We use an intermediate struct
17-
* and "serde" to allow not to describe the launched
17+
* and "serde" to allow not to describe the launch
1818
* day or month for example
1919
*/
2020
#[derive(Deserialize)]
@@ -23,10 +23,10 @@ struct SBASDBEntry<'a> {
2323
pub prn: u16,
2424
pub id: &'a str,
2525
#[serde(default = "default_launch_month")]
26-
pub launched_month: u8,
26+
pub launch_month: u8,
2727
#[serde(default = "default_launch_day")]
28-
pub launched_day: u8,
29-
pub launched_year: i32,
28+
pub launch_day: u8,
29+
pub launch_year: i32,
3030
}
3131

3232
fn build_sbas_helper() {
@@ -46,9 +46,9 @@ pub struct SBASHelper<'a> {
4646
constellation: &'a str,
4747
prn: u16,
4848
id: &'a str,
49-
launched_day: u8,
50-
launched_month: u8,
51-
launched_year: i32,
49+
launch_day: u8,
50+
launch_month: u8,
51+
launch_year: i32,
5252
}
5353
5454
lazy_static! {
@@ -64,11 +64,11 @@ lazy_static! {
6464
constellation: \"{}\",
6565
prn: {},
6666
id: \"{}\",
67-
launched_year: {},
68-
launched_month: {},
69-
launched_day: {}
67+
launch_year: {},
68+
launch_month: {},
69+
launch_day: {}
7070
}},",
71-
e.constellation, e.prn, e.id, e.launched_year, e.launched_month, e.launched_day,
71+
e.constellation, e.prn, e.id, e.launch_year, e.launch_month, e.launch_day,
7272
)
7373
.as_bytes(),
7474
)

data/sbas.json

Lines changed: 32 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,119 +3,112 @@
33
"constellation": "AusNZ",
44
"prn": 122,
55
"id": "INMARSAT-4F1",
6-
"launched_year": 2020,
7-
"launched_month": 1
6+
"launch_year": 2020,
7+
"launch_month": 1
88
},
99
{
1010
"constellation": "EGNOS",
1111
"prn": 123,
1212
"id": "ASTRA-5B",
13-
"launched_year": 2021,
14-
"launched_month": 11
13+
"launch_year": 2021,
14+
"launch_month": 11
1515
},
1616
{
1717
"constellation": "SDCM",
1818
"prn": 125,
1919
"id": "Luch-5A",
20-
"launched_year": 2021,
21-
"launched_month": 12
20+
"launch_year": 2021,
21+
"launch_month": 12
2222
},
2323
{
2424
"constellation": "EGNOS",
2525
"prn": 126,
2626
"id": "INMARSAT-4F2",
27-
"launched_year": 2023,
28-
"launched_month": 4
27+
"launch_year": 2023,
28+
"launch_month": 4
2929
},
3030
{
3131
"constellation": "GAGAN",
3232
"prn": 127,
3333
"id": "GSAT-8",
34-
"launched_year": 2020,
35-
"launched_month": 9
34+
"launch_year": 2020,
35+
"launch_month": 9
3636
},
3737
{
3838
"constellation": "GAGAN",
3939
"prn": 128,
4040
"id": "GSAT-10",
41-
"launched_year": 2020,
42-
"launched_month": 9
41+
"launch_year": 2020,
42+
"launch_month": 9
4343
},
4444
{
4545
"constellation": "BDSBAS",
4646
"prn": 130,
4747
"id": "G6",
48-
"launched_year": 2020,
49-
"launched_month": 10
50-
},
51-
{
52-
"constellation": "BDSBAS",
53-
"prn": 130,
54-
"id": "G6",
55-
"launched_year": 2020,
56-
"launched_month": 10
48+
"launch_year": 2020,
49+
"launch_month": 10
5750
},
5851
{
5952
"constellation": "KASS",
6053
"prn": 134,
6154
"id": "MEASAT-3D",
62-
"launched_year": 2021,
63-
"launched_month": 6
55+
"launch_year": 2021,
56+
"launch_month": 6
6457
},
6558
{
6659
"constellation": "EGNOS",
6760
"prn": 136,
6861
"id": "SES-5",
69-
"launched_year": 2021,
70-
"launched_month": 11
62+
"launch_year": 2021,
63+
"launch_month": 11
7164
},
7265
{
7366
"constellation": "WAAS",
7467
"prn": 138,
7568
"id": "ANIK-F1R",
76-
"launched_year": 2022,
77-
"launched_month": 7
69+
"launch_year": 2022,
70+
"launch_month": 7
7871
},
7972
{
8073
"constellation": "SDCM",
8174
"prn": 140,
8275
"id": "Luch-5B",
83-
"launched_year": 2021,
84-
"launched_month": 12
76+
"launch_year": 2021,
77+
"launch_month": 12
8578
},
8679
{
8780
"constellation": "SDCM",
8881
"prn": 141,
8982
"id": "Luch-4",
90-
"launched_year": 2021,
91-
"launched_month": 12
83+
"launch_year": 2021,
84+
"launch_month": 12
9285
},
9386
{
9487
"constellation": "BDSBAS",
9588
"prn": 143,
9689
"id": "G3",
97-
"launched_year": 2020,
98-
"launched_month": 10
90+
"launch_year": 2020,
91+
"launch_month": 10
9992
},
10093
{
10194
"constellation": "BDSBAS",
10295
"prn": 144,
10396
"id": "G1",
104-
"launched_year": 2020,
105-
"launched_month": 10
97+
"launch_year": 2020,
98+
"launch_month": 10
10699
},
107100
{
108101
"constellation": "NSAS",
109102
"prn": 147,
110103
"id": "NIGCOMSAT-1R",
111-
"launched_year": 2021,
112-
"launched_month": 1
104+
"launch_year": 2021,
105+
"launch_month": 1
113106
},
114107
{
115108
"constellation": "ASAL",
116109
"prn": 148,
117110
"id": "ALCOMSAT-1",
118-
"launched_year": 2020,
119-
"launched_month": 1
111+
"launch_year": 2020,
112+
"launch_month": 1
120113
}
121114
]

0 commit comments

Comments
 (0)