Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional serde support #106

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions swiftnav/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ rustversion = "1.0"
chrono = { version = "0.4", optional = true }
swiftnav-sys = { version = "^0.9.0", path = "../swiftnav-sys/" }
strum = { version = "0.26", features = ["derive"] }
serde = { version = "1.0.204", features = ["derive"], optional = true }

[dev-dependencies]
float_eq = "1.0.1"

[features]
serde = ["dep:serde"]
4 changes: 4 additions & 0 deletions swiftnav/src/coords.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ use crate::{
///
/// Internally stored as an array of 3 [f64](std::f64) values: latitude, longitude (both in the given angular units) and height above the geoid in meters
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct LLHDegrees([f64; 3]);

impl LLHDegrees {
Expand Down Expand Up @@ -147,6 +148,7 @@ impl From<ECEF> for LLHRadians {
///
/// Internally stored as an array of 3 [f64](std::f64) values: latitude, longitude (both in the given angular units) and height above the geoid in meters
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct LLHRadians([f64; 3]);

impl LLHRadians {
Expand Down Expand Up @@ -238,6 +240,7 @@ impl From<ECEF> for LLHDegrees {
///
/// Internally stored as an array of 3 [f64](std::f64) values: x, y, z all in meters
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ECEF([f64; 3]);

impl ECEF {
Expand Down Expand Up @@ -436,6 +439,7 @@ impl MulAssign<&f64> for ECEF {
///
/// Internally stored as an array of 3 [f64](std::f64) values: N, E, D all in meters
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct NED([f64; 3]);

impl NED {
Expand Down
3 changes: 3 additions & 0 deletions swiftnav/src/reference_frame/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ mod params;
/// Reference Frames
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, EnumString, Display, EnumIter)]
#[strum(serialize_all = "UPPERCASE")]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum ReferenceFrame {
ITRF88,
ITRF89,
Expand Down Expand Up @@ -137,6 +138,7 @@ pub enum ReferenceFrame {
/// the scaling is in parts per billion. We also follow the
/// IERS convention for the sign of the rotation terms.
#[derive(Debug, PartialEq, PartialOrd, Clone, Copy)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct TimeDependentHelmertParams {
tx: f64,
tx_dot: f64,
Expand Down Expand Up @@ -216,6 +218,7 @@ impl TimeDependentHelmertParams {

/// A transformation from one reference frame to another.
#[derive(Debug, PartialEq, PartialOrd, Clone, Copy)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Transformation {
pub from: ReferenceFrame,
pub to: ReferenceFrame,
Expand Down
Loading