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

Function LatToInt

libs/ge0/url_generator.cpp:152–162  ·  view source on GitHub ↗

Map latitude: [-90, 90] -> [0, maxValue]

Source from the content-addressed store, hash-verified

150
151// Map latitude: [-90, 90] -> [0, maxValue]
152int 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)
165double LonIn180180(double lon)

Callers 2

LatLonToStringFunction · 0.85
UNIT_TESTFunction · 0.85

Calls 1

iroundFunction · 0.50

Tested by 1

UNIT_TESTFunction · 0.68