Skip to content

Commit 7cbc0ca

Browse files
authored
Updated the reported geoid model type to match the C library interface (#85)
1 parent 92f9631 commit 7cbc0ca

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

swiftnav-sys/build.rs

+2
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,9 @@ fn main() {
169169
.allowlist_var("pvt_err_msg")
170170
.allowlist_function("correct_iono")
171171
.allowlist_function("correct_tropo")
172+
.allowlist_type("geoid_model_t")
172173
.allowlist_function("get_geoid_offset")
174+
.allowlist_function("get_geoid_model")
173175
// Finish the builder and generate the bindings.
174176
.generate()
175177
// Unwrap the Result and panic on failure.

swiftnav/src/geoid.rs

+11-5
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ use crate::coords::LLHRadians;
2323
///
2424
/// Currently only one model is compiled into the code at a time
2525
pub enum GeoidModel {
26-
/// The EGM2008 geoid model, down sampled to 1 degree resolution
27-
Egm2008_1Deg,
28-
/// The EGM2008 geoid model, down sampled to 15 arc minute resolution
29-
Egm2008_15Min,
26+
/// The EGM96 geoid model
27+
Egm96,
28+
/// The EGM2008 geoid model
29+
Egm2008,
3030
}
3131

3232
/// Get the offset of the geoid from the WGS84 ellipsoid
@@ -44,5 +44,11 @@ pub fn get_geoid_offset<T: Into<LLHRadians>>(pos: T) -> f32 {
4444

4545
/// Gets the geoid model compiled into the Swiftnav crate
4646
pub fn get_geoid_model() -> GeoidModel {
47-
GeoidModel::Egm2008_1Deg
47+
let model = unsafe { swiftnav_sys::get_geoid_model() };
48+
49+
match model {
50+
swiftnav_sys::geoid_model_t_GEOID_MODEL_EGM96 => GeoidModel::Egm96,
51+
swiftnav_sys::geoid_model_t_GEOID_MODEL_EGM2008 => GeoidModel::Egm2008,
52+
_ => unimplemented!("Unknown geoid model {}", model),
53+
}
4854
}

0 commit comments

Comments
 (0)