-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* sv and rnxcontext * add more processing tests * improve identification opmode * add more processing tests * introduce gnss-rs * run cargo clippy --------- Signed-off-by: Guillaume W. Bres <[email protected]>
- Loading branch information
Showing
94 changed files
with
1,760 additions
and
1,294 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
[workspace] | ||
resolver = "2" | ||
|
||
members = [ | ||
"gnss-rs", | ||
"gnss-rtk", | ||
"crx2rnx", | ||
"qc-traits", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
[package] | ||
name = "gnss-rs" | ||
version = "2.0.0" | ||
license = "MIT OR Apache-2.0" | ||
authors = ["Guillaume W. Bres <[email protected]>"] | ||
description = "GNSS constellations and space vehicles support" | ||
homepage = "https://github.com/georust/rinex" | ||
repository = "https://github.com/georust/rinex" | ||
keywords = ["gnss", "gps", "glonass", "galileo"] | ||
categories = ["science", "science::geo"] | ||
edition = "2021" | ||
readme = "README.md" | ||
|
||
[features] | ||
default = [] # no features by default | ||
sbas = ["geo", "wkt"] | ||
|
||
[package.metadata.docs.rs] | ||
all-features = true | ||
rustdoc-args = ["--cfg", "docrs", "--generate-link-to-definition"] | ||
|
||
[build-dependencies] | ||
serde_json = { version = "1.0", features = ["preserve_order"] } | ||
serde = { version = "1.0", default-features = false, features = ["derive"] } | ||
|
||
[dependencies] | ||
thiserror = "1" | ||
lazy_static = "1.4" | ||
hifitime = { version = "3.8.4" } | ||
geo = { version = "0.26", optional = true } | ||
wkt = { version = "0.10.0", default-features = false, optional = true } | ||
serde = { version = "1.0", optional = true, default-features = false, features = ["derive"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# GNSS | ||
|
||
[![crates.io](https://img.shields.io/crates/v/gnss-rs.svg)](https://crates.io/crates/gnss-rs) | ||
[![crates.io](https://docs.rs/gnss-rs/badge.svg)](https://docs.rs/gnss-rs/badge.svg) | ||
|
||
GNSS Constellations and Space Vehicles (SV) support in Rust | ||
|
||
## Getting started | ||
|
||
Add "gnss" to your Cargo.toml | ||
|
||
```toml | ||
gnss-rs = "2" | ||
``` | ||
|
||
Import "gnss-rs": | ||
|
||
```rust | ||
extern crate gnss_rs as gnss; | ||
``` | ||
|
||
## Space Vehicles | ||
|
||
```rust | ||
extern crate gnss_rs as gnss; | ||
|
||
use hifitime::TimeScale; | ||
use gnss::sv; | ||
use gnss::prelude::*; | ||
use std::str::FromStr; | ||
|
||
let sv = SV::new(Constellation::GPS, 1); | ||
assert_eq!(sv.constellation, Constellation::GPS); | ||
assert_eq!(sv.prn, 1); | ||
assert_eq!(sv.timescale(), Some(TimeScale::GPST)); | ||
assert_eq!(sv, sv!("G01")); | ||
assert_eq!(sv.launched_date(), None); | ||
``` | ||
|
||
## SBAS support | ||
|
||
We support SBAS (geostationary augmentations) systems. | ||
|
||
```rust | ||
extern crate gnss_rs as gnss; | ||
|
||
use gnss::sv; | ||
use gnss::prelude::*; | ||
use std::str::FromStr; | ||
use hifitime::{Epoch, TimeScale}; | ||
|
||
let sv = sv!("S23"); | ||
assert_eq!(sv.constellation, Constellation::EGNOS); | ||
let launched_date = Epoch::from_str("2021-11-01T00:00:00 UTC") | ||
.unwrap(); | ||
assert_eq!(sv.launched_date(), Some(launched_date)); | ||
``` | ||
|
||
## License | ||
|
||
Licensed under either of: | ||
|
||
* Apache Version 2.0 ([LICENSE-APACHE](http://www.apache.org/licenses/LICENSE-2.0)) | ||
* MIT ([LICENSE-MIT](http://opensource.org/licenses/MIT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
use std::env; | ||
use std::io::Write; | ||
use std::path::Path; | ||
|
||
use serde::Deserialize; | ||
|
||
fn default_launch_month() -> u8 { | ||
1 // Jan | ||
} | ||
|
||
fn default_launch_day() -> u8 { | ||
1 // 1st day of month | ||
} | ||
|
||
/* | ||
* We use an intermediate struct | ||
* and "serde" to allow not to describe the launched | ||
* day or month for example | ||
*/ | ||
#[derive(Deserialize)] | ||
struct SBASDBEntry<'a> { | ||
pub constellation: &'a str, | ||
pub prn: u16, | ||
pub id: &'a str, | ||
#[serde(default = "default_launch_month")] | ||
pub launched_month: u8, | ||
#[serde(default = "default_launch_day")] | ||
pub launched_day: u8, | ||
pub launched_year: i32, | ||
} | ||
|
||
fn build_sbas_helper() { | ||
let outdir = env::var("OUT_DIR").unwrap(); | ||
let path = Path::new(&outdir).join("sbas.rs"); | ||
let mut fd = std::fs::File::create(path).unwrap(); | ||
|
||
// read descriptor: parse and dump into a static array | ||
let db_content = std::fs::read_to_string("data/sbas.json").unwrap(); | ||
|
||
let sbas_db: Vec<SBASDBEntry> = serde_json::from_str(&db_content).unwrap(); | ||
|
||
let content = "use lazy_static::lazy_static; | ||
#[derive(Debug)] | ||
pub struct SBASHelper<'a> { | ||
constellation: &'a str, | ||
prn: u16, | ||
id: &'a str, | ||
launched_day: u8, | ||
launched_month: u8, | ||
launched_year: i32, | ||
} | ||
lazy_static! { | ||
static ref SBAS_VEHICLES: Vec<SBASHelper<'static>> = vec![ | ||
\n"; | ||
|
||
fd.write_all(content.as_bytes()).unwrap(); | ||
|
||
for e in sbas_db { | ||
fd.write_all( | ||
format!( | ||
"SBASHelper {{ | ||
constellation: \"{}\", | ||
prn: {}, | ||
id: \"{}\", | ||
launched_year: {}, | ||
launched_month: {}, | ||
launched_day: {} | ||
}},", | ||
e.constellation, e.prn, e.id, e.launched_year, e.launched_month, e.launched_day, | ||
) | ||
.as_bytes(), | ||
) | ||
.unwrap() | ||
} | ||
|
||
fd.write_all(" ];".as_bytes()).unwrap(); | ||
fd.write_all("}\n".as_bytes()).unwrap(); | ||
} | ||
|
||
fn main() { | ||
build_sbas_helper(); | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#![doc(html_logo_url = "https://raw.githubusercontent.com/georust/meta/master/logo/logo.png")] | ||
#![doc = include_str!("../README.md")] | ||
|
||
#[macro_use] | ||
mod macros; | ||
|
||
pub mod sv; | ||
|
||
pub mod constellation; | ||
use constellation::Constellation; | ||
|
||
pub mod prelude { | ||
pub use crate::constellation::Constellation; | ||
pub use crate::sv::SV; | ||
} | ||
|
||
mod sbas; | ||
|
||
#[cfg(feature = "sbas")] | ||
pub use sbas::sbas_selection; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/// Creates a [SV] from given string description. | ||
#[macro_export] | ||
macro_rules! sv { | ||
($desc: expr) => { | ||
SV::from_str($desc).unwrap() | ||
}; | ||
} | ||
|
||
/// Crates a [Constellation] from given string description. | ||
#[macro_export] | ||
macro_rules! gnss { | ||
($desc: expr) => { | ||
Constellation::from_str($desc).unwrap() | ||
}; | ||
} |
Oops, something went wrong.