Skip to content

Commit

Permalink
Develop (#175)
Browse files Browse the repository at this point in the history
* 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
gwbres authored Oct 11, 2023
1 parent 1be46bc commit 8c66b21
Show file tree
Hide file tree
Showing 94 changed files with 1,760 additions and 1,294 deletions.
15 changes: 8 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ depending on which type of RINEX we're talking about.
For complex RINEX formats like Navigation Data, that module will contain all possible inner types.

Other important structures :
- SV and Constellation support is provided by the GNSS lib (gnss-rs)
- `src/epoch/mod.rs`: the Epoch module basically provides
hifitime::Epoch parsing methods, because RINEX describes date in non standard formats.
Also, the `Flag` structure is used to mark Observations (valid or invalid).
- `src/constellation.rs` defines GNSS constellations
- `src/constellation/augmentation.rs` : preliminary SBAS support
- `src/sv.rs` defines a Satellite vehicle, which is associated to a constellation
- `src/observable.rs`: defines possible observations like raw phase
- `src/carrier.rs`: defines carrier signals in terms of frequency and bandwidth.
It also contains utilities to identify which GNSS signals we're dealing with,
Expand Down Expand Up @@ -67,9 +65,10 @@ Adding new SBAS vehicles
========================

To add a newly launched SBAS vehicles, simply add it to the
rinex/db/SBAS/sbas.json database.
gnss-rs/data/sbas.json database.

The only mandatory fields are :
This database is auto integrated to this library to provide
detailed SBAS supports. The only mandatory fields (in the databse) are:
- the "constellation" field
- the SBAS "prn" field (which is 100 + prn number)
- "id": the name of that vehicle, for example "ASTRA-5B"
Expand All @@ -81,8 +80,10 @@ Other optional fields are:

We don't support undeployed vehicles (in advance).

Build scripts
=============
Modify or add Navigation Frames
===============================

Navigation frames are desc

The build script is rinex/build.rs.

Expand Down
2 changes: 2 additions & 0 deletions Cargo.toml
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",
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ The application is auto-generated for a few architectures, download it from the
[release portal](https://github.com/gwbres/rinex/releases)

* [`sp3`](sp3/) High Precision Orbits (by IGS)
* [`gnss-rs`](gnss-rs/) Constellation and SV support in Rust, with detailed SBAS support.
* [`gnss-rtk`](gnss-rtk/) a position solver from raw GNSS signals.
Currently works from RINEX input data, but that is not exclusive.
* [`rnx2crx`](rnx2crx/) is a RINEX compressor (RINEX to Compact RINEX)
Expand Down
66 changes: 0 additions & 66 deletions TODO.md

This file was deleted.

32 changes: 32 additions & 0 deletions gnss-rs/Cargo.toml
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"] }
64 changes: 64 additions & 0 deletions gnss-rs/README.md
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)
84 changes: 84 additions & 0 deletions gnss-rs/build.rs
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.
35 changes: 12 additions & 23 deletions rinex/src/constellation/mod.rs → gnss-rs/src/constellation.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
//! `GNSS` constellations & associated methods
//! GNSS constellations
use hifitime::TimeScale;
use thiserror::Error;

//#[cfg(feature = "serde")]
//use serde::{Deserialize, Serialize};

mod sbas;

#[cfg(feature = "sbas")]
pub use sbas::sbas_selection_helper;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};

/// Constellation parsing & identification related errors
#[derive(Error, Clone, Debug, PartialEq)]
Expand Down Expand Up @@ -205,21 +200,15 @@ impl std::fmt::UpperHex for Constellation {
Self::BeiDou => write!(f, "BDS"),
Self::QZSS => write!(f, "QZSS"),
Self::IRNSS => write!(f, "IRNSS"),
Self::WAAS => write!(f, "WAAS"),
Self::EGNOS => write!(f, "EGNOS"),
Self::BDSBAS => write!(f, "BDSBAS"),
Self::AusNZ => write!(f, "AUSNZ"),
Self::MSAS => write!(f, "MSAS"),
Self::NSAS => write!(f, "NSAS"),
Self::GBAS => write!(f, "GBAS"),
Self::SPAN => write!(f, "SPAN"),
Self::GAGAN => write!(f, "GAGAN"),
Self::KASS => write!(f, "KASS"),
Self::ASBAS => write!(f, "ASBAS"),
Self::ASAL => write!(f, "ASAL"),
Self::SDCM => write!(f, "SDCM"),
Self::Mixed => write!(f, "MIXED"),
Self::SBAS => write!(f, "SBAS"),
c => {
if c.is_sbas() {
write!(f, "SBAS")
} else if c.is_mixed() {
write!(f, "MIXED")
} else {
Err(std::fmt::Error)
}
},
}
}
}
Expand Down
20 changes: 20 additions & 0 deletions gnss-rs/src/lib.rs
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;
15 changes: 15 additions & 0 deletions gnss-rs/src/macros.rs
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()
};
}
Loading

0 comments on commit 8c66b21

Please sign in to comment.