Skip to content

Commit

Permalink
2018 Edition fixes
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit b80608f
Author: Stephan Hügel <shugel@tcd.ie>
Date:   Tue Dec 11 23:12:39 2018 +0000

    Fix use statements by building an rlib

commit 5c913c0
Author: Stephan Hügel <shugel@tcd.ie>
Date:   Tue Dec 11 22:47:53 2018 +0000

    More 2018 Edition fixes

commit 3a4ea8a
Author: Stephan Hügel <shugel@tcd.ie>
Date:   Tue Dec 11 22:43:42 2018 +0000

    More 2018 Edition fixes

commit bbccd96
Author: Stephan Hügel <shugel@tcd.ie>
Date:   Tue Dec 11 22:12:23 2018 +0000

    More edition fixes

commit 5aa6478
Author: Stephan Hügel <shugel@tcd.ie>
Date:   Tue Dec 11 17:33:29 2018 +0000

    More 2018 edition fix

commit 4227644
Author: Stephan Hügel <shugel@tcd.ie>
Date:   Tue Dec 11 17:10:24 2018 +0000

    Move to 2018 edition
  • Loading branch information
urschrei committed Dec 11, 2018
1 parent e3c387b commit b44feeb
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 43 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ keywords = ["OSGB36", "Geo", "FFI", "ETRS89", "OSTN02"]
repository = "https://github.com/urschrei/lonlat_bng"
documentation = "https://urschrei.github.io/lonlat_bng/"
readme = "README.md"
edition = "2018"

[dependencies]
libc = "0.2.40"
Expand All @@ -18,7 +19,7 @@ rayon = "1.0.0"

[lib]
name = "lonlat_bng"
crate-type = ["cdylib"]
crate-type = ["rlib", "cdylib"]
test = true
doctest = false
doc = true
Expand Down
7 changes: 2 additions & 5 deletions benches/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

extern crate test;
use test::Bencher;
extern crate lonlat_bng;
use lonlat_bng::convert_to_bng_threaded_vec;
use lonlat_bng::utils::get_ostn_ref;

extern crate rand;
use lonlat_bng;
use rand::distributions::{IndependentSample, Range};

#[bench]
Expand All @@ -18,6 +15,6 @@ fn bench_threads(b: &mut Bencher) {
let mut lon_vec = vec![between_lon.ind_sample(&mut rng); num_coords];
let mut lat_vec = vec![between_lat.ind_sample(&mut rng); num_coords];
b.iter(|| {
convert_to_bng_threaded_vec(&mut lon_vec, &mut lat_vec);
lonlat_bng::convert_to_bng_threaded_vec(&mut lon_vec, &mut lat_vec);
});
}
2 changes: 1 addition & 1 deletion src/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extern crate phf_codegen;
use phf_codegen;

use std::fs::File;
use std::io::prelude::*;
Expand Down
11 changes: 5 additions & 6 deletions src/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,14 @@ const N0: f64 = TRUE_ORIGIN_NORTHING;
// convergence factor
const F0: f64 = 0.9996012717;

extern crate libc;
use self::libc::c_double;
use libc::c_double;
use std::f64;
use std::mem;

use utils::check;
use utils::ostn15_shifts;
use utils::round_to_eight;
use utils::ToMm;
use crate::utils::check;
use crate::utils::ostn15_shifts;
use crate::utils::round_to_eight;
use crate::utils::ToMm;

/// Calculate the meridional radius of curvature
#[allow(non_snake_case)]
Expand Down
7 changes: 3 additions & 4 deletions src/ffi.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::slice;

extern crate libc;
use self::libc::c_void;
use libc::c_void;

#[repr(C)]
pub struct Array {
Expand All @@ -24,7 +23,7 @@ use super::convert_to_osgb36_threaded_vec;
/// # Examples
///
/// ```
/// # extern crate libc;
/// # use libc;
/// let lon_vec: Vec<f64> = vec![-2.0183041005533306];
/// let lat_vec: Vec<f64> = vec![54.589097162646141];
/// let lon_arr = Array {
Expand Down Expand Up @@ -77,7 +76,7 @@ impl<'a> From<Array> for &'a mut [f64] {
/// # Examples
///
/// ```
/// extern crate libc;
/// use libc;
/// let lon_vec: Vec<f64> = vec![-2.0183041005533306,
/// 0.95511887434519682,
/// 0.44975855518383501,
Expand Down
48 changes: 22 additions & 26 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,31 @@
//!
//! **An example FFI implementation using Python can be found at [Convertbng](https://github.com/urschrei/convertbng)**.
//!

extern crate ostn15_phf;
extern crate rand;
extern crate rayon;
use rayon::prelude::*;

mod conversions;
mod ffi;
pub mod utils;

pub use ffi::convert_epsg3857_to_wgs84_threaded;
pub use ffi::convert_etrs89_to_ll_threaded;
pub use ffi::convert_etrs89_to_osgb36_threaded;
pub use ffi::convert_osgb36_to_etrs89_threaded;
pub use ffi::convert_osgb36_to_ll_threaded;
pub use ffi::convert_to_bng_threaded;
pub use ffi::convert_to_etrs89_threaded;
pub use ffi::convert_to_lonlat_threaded;
pub use ffi::convert_to_osgb36_threaded;
pub use ffi::drop_float_array;
pub use ffi::Array;

pub use conversions::convert_epsg3857_to_wgs84;
pub use conversions::convert_etrs89;
pub use conversions::convert_etrs89_to_ll;
pub use conversions::convert_etrs89_to_osgb36;
pub use conversions::convert_osgb36;
pub use conversions::convert_osgb36_to_etrs89;
pub use conversions::convert_osgb36_to_ll;
pub use crate::ffi::convert_epsg3857_to_wgs84_threaded;
pub use crate::ffi::convert_etrs89_to_ll_threaded;
pub use crate::ffi::convert_etrs89_to_osgb36_threaded;
pub use crate::ffi::convert_osgb36_to_etrs89_threaded;
pub use crate::ffi::convert_osgb36_to_ll_threaded;
pub use crate::ffi::convert_to_bng_threaded;
pub use crate::ffi::convert_to_etrs89_threaded;
pub use crate::ffi::convert_to_lonlat_threaded;
pub use crate::ffi::convert_to_osgb36_threaded;
pub use crate::ffi::drop_float_array;
pub use crate::ffi::Array;

pub use crate::conversions::convert_epsg3857_to_wgs84;
pub use crate::conversions::convert_etrs89;
pub use crate::conversions::convert_etrs89_to_ll;
pub use crate::conversions::convert_etrs89_to_osgb36;
pub use crate::conversions::convert_osgb36;
pub use crate::conversions::convert_osgb36_to_etrs89;
pub use crate::conversions::convert_osgb36_to_ll;

use std::f64;
pub const NAN: f64 = f64::NAN;
Expand Down Expand Up @@ -155,11 +151,11 @@ fn convert_vec_direct<'a>(

#[cfg(test)]
mod tests {
use super::convert_vec_direct;
// use super::convert_vec_direct;
use super::*;
use conversions::convert_bng;
use crate::conversions::convert_bng;

extern crate libc;
use libc;
use std::ptr;

#[test]
Expand Down

0 comments on commit b44feeb

Please sign in to comment.