1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//! Decoder for geohash-rs
use cratebase32;
use crateLEFT;
use crateRIGHT;
use VecDeque;
/// For each 5-bit chunk of the geohash, we calculate the midpoint of the current bound and then split
/// the bound into two halves based on the value of the 5-bit chunk
///
/// Arguments:
///
/// * `geohash`: The geohash string to decode.
///
/// Returns:
///
/// A GPSBoundInfo struct
///
/// Panics:
///
/// Panics when geohash String is invalid
///
/// # Examples
///
/// ```
/// use geohash_rs;
/// let gps_bounds = geohash_rs::decode(String::from("wydm9qyc"));
///
/// assert_eq!(gps_bounds.latitude[0], 37.56654739379883);
/// assert_eq!(gps_bounds.latitude[1], 37.56671905517578);
/// assert_eq!(gps_bounds.longitude[0], 126.97826385498047);
/// assert_eq!(gps_bounds.longitude[1], 126.97860717773438);
/// ```
/// `cal_coord_bound` takes a `bit_5` and a `bound_queue` and for each of the 5 bits in `bit_5` it calls
/// `cal_bound` with the `bit_5` and the bit.
///
/// Arguments:
///
/// * `bit_5`: the 5-bit binary representation of the current number
/// * `bound_queue`: a queue of bounding boxes, each bounding box is represented by a 2-element array,
/// the first element is the lower bound, the second element is the upper bound.
/// It takes a bit and a bound queue, and updates the bound queue
///
/// Arguments:
///
/// * `bit_5`: The 5-bit binary representation of the current character.
/// * `i`: the index of the bit we're currently looking at
/// * `bound_queue`: A queue of the bounds of the current bit.
/// `GPSBoundInfo` is a struct that contains two arrays of two floats each, one for latitude and one for
/// longitude.
///
/// Properties:
///
/// * `latitude`: [f32;2] - The latitude of the bounding box. The first value is the minimum latitude,
/// the second value is the maximum latitude.
/// * `longitude`: The longitude of the location.