MCPcopy Create free account
hub / github.com/comaps/comaps / compute_precision_for_length

Function compute_precision_for_length

3party/open-location-code/openlocationcode.cc:66–71  ·  view source on GitHub ↗

Compute the latitude precision value for a given code length. Lengths <= 10 have the same precision for latitude and longitude, but lengths > 10 have different precisions due to the grid method having fewer columns than rows.

Source from the content-addressed store, hash-verified

64// have the same precision for latitude and longitude, but lengths > 10 have
65// different precisions due to the grid method having fewer columns than rows.
66double compute_precision_for_length(int code_length) {
67 if (code_length <= 10) {
68 return pow_neg(internal::kEncodingBase, floor((code_length / -2) + 2));
69 }
70 return pow_neg(internal::kEncodingBase, -3) / pow(5, code_length - 10);
71}
72
73// Returns the position of a char in the encoding alphabet, or -1 if invalid.
74int get_alphabet_position(char c) {

Callers 2

adjust_latitudeFunction · 0.85
ShortenFunction · 0.85

Calls 1

pow_negFunction · 0.85

Tested by

no test coverage detected