Returns the position of a char in the encoding alphabet, or -1 if invalid.
| 72 | |
| 73 | // Returns the position of a char in the encoding alphabet, or -1 if invalid. |
| 74 | int get_alphabet_position(char c) { |
| 75 | // We use a lookup table for performance reasons (e.g. over std::find). |
| 76 | if (c >= 'C' && c <= 'X') return internal::kPositionLUT[c - 'C']; |
| 77 | if (c >= 'c' && c <= 'x') return internal::kPositionLUT[c - 'c']; |
| 78 | if (c >= '2' && c <= '9') return c - '2'; |
| 79 | return -1; |
| 80 | } |
| 81 | |
| 82 | // Normalize a longitude into the range -180 to 180, not including 180. |
| 83 | double normalize_longitude(double longitude_degrees) { |