Map latitude: [-90, 90] -> [0, maxValue]
| 150 | |
| 151 | // Map latitude: [-90, 90] -> [0, maxValue] |
| 152 | int LatToInt(double lat, int maxValue) |
| 153 | { |
| 154 | // M = maxValue, L = maxValue-1 |
| 155 | // lat: -90 90 |
| 156 | // x: 0 1 2 L M |
| 157 | // |--+--|--+--|--...--|--+--| |
| 158 | // 000111111222222...LLLLLMMMM |
| 159 | |
| 160 | double const x = (lat + 90.0) / 180.0 * maxValue; |
| 161 | return x < 0 ? 0 : (x > maxValue ? maxValue : math::iround(x)); |
| 162 | } |
| 163 | |
| 164 | // Make lon in [-180, 180) |
| 165 | double LonIn180180(double lon) |