an obvious if/elseif/elseif -> switch refactoring
* reorganizing and labeling; no code changes
* more comment and organization changes
* added lambdas for clamping lon/lat and checking (integer) lon/lat validity
* many trivial (non-code-changing) reoderings and such
* more cosmetic changes
* more cosmetic surgery
* more commenting