Skip to content

Commit

Permalink
Fix error in the comment
Browse files Browse the repository at this point in the history
Small error in the comment. The "clamping" to unit range ``[0, 1]`` is done by dividing latitude with ``180.0`` and longitude with ``360.0``.
  • Loading branch information
PaulusParssinen authored May 2, 2024
1 parent 3ad0207 commit 69884b6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ pub fn encode(c: Coord<f64>, len: usize) -> Result<String, GeohashError> {
return Err(GeohashError::InvalidLength(len));
}

// divides the latitude by 90, then adds 1.5 to give a value between 1 and 2
// divides the latitude by 180, then adds 1.5 to give a value between 1 and 2
// then we take the first 32 bits of the significand as a u32
let lat32 = ((c.y * 0.005555555555555556 + 1.5).to_bits() >> 20) as u32;
// same as latitude, but a division by 180 instead of 90
// same as latitude, but a division by 360 instead of 180
let lon32 = ((c.x * 0.002777777777777778 + 1.5).to_bits() >> 20) as u32;

let mut interleaved_int = interleave(lat32, lon32);
Expand Down

0 comments on commit 69884b6

Please sign in to comment.