Contents
Maidenhead Locators
Comprise 4 pairs of characters, each pair representing Longitude, Latitude.
AB12cd34
Where -
- A & B are Base 18 (A..R)
- 1 & 2 are Base 10 (0..9)
- c & d are Base 24 (a..x)
- 3 & 4 are Base 10 (0..9)
Giving a total range in each direction of 0..43199
Calculation
To calculate using integer arithmatic, scale to 0..43199
|
|
Using int
is fine, each square runs from 0 to 0.9999… so drop the non-integer part.
Then break down
|
|
(And the same for lat)
Convert the 2nd and 4th to Strings, and the 1st and 3rd to letters (1st uppercase, 3rd lowercase)
Extending The CLLocacion class to return Maidenhead strings -
|
|