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

Function adjust_latitude

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

Adjusts 90 degree latitude to be lower so that a legal OLC code can be generated.

Source from the content-addressed store, hash-verified

93// Adjusts 90 degree latitude to be lower so that a legal OLC code can be
94// generated.
95double adjust_latitude(double latitude_degrees, size_t code_length) {
96 latitude_degrees = std::min(90.0, std::max(-90.0, latitude_degrees));
97
98 if (latitude_degrees < internal::kLatitudeMaxDegrees) {
99 return latitude_degrees;
100 }
101 // Subtract half the code precision to get the latitude into the code
102 // area.
103 double precision = compute_precision_for_length(code_length);
104 return latitude_degrees - precision / 2;
105}
106
107// Remove the separator and padding characters from the code.
108std::string clean_code_chars(const std::string &code) {

Callers 3

EncodeFunction · 0.85
ShortenFunction · 0.85
RecoverNearestFunction · 0.85

Calls 1

Tested by

no test coverage detected