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
/// Normalize co-ordinates that lie outside of the normal ranges. | |
/// Longitude wrapping simply requires adding +- 360 to the value until it comes into range. | |
/// | |
/// For the latitude values, we need to flip the longitude whenever the latitude crosses a pole. | |
/// | |
/// Description and original source was ported from https://gist.github.com/missinglink/d0a085188a8eab2ca66db385bb7c023a to rust | |
pub fn wrap_latlon(mut lat: f64, mut lon: f64) -> (f64, f64) { | |
let quadrant = ((lat.abs() / 90_f64).floor() % 4_f64) as i8; | |
let pole = if lat > 0_f64 { 90_f64 } else { -90_f64 }; | |
let offset = lat % 90_f64; |