Convert UTM point parameters to MGRS parameters. Additional 2 char code is deducted. Easting and northing parameters are reduced to 5 digits.
| 212 | // Convert UTM point parameters to MGRS parameters. Additional 2 char code is deducted. |
| 213 | // Easting and northing parameters are reduced to 5 digits. |
| 214 | std::string UTMtoMgrsStr(UTMPoint const & point, int precision) |
| 215 | { |
| 216 | if (point.zoneLetter == 'Z') |
| 217 | return "Latitude limit exceeded"; |
| 218 | auto const eastingStr = strings::to_string_width(static_cast<long>(point.easting), precision + 1); |
| 219 | auto northingStr = strings::to_string_width(static_cast<long>(point.northing), precision + 1); |
| 220 | |
| 221 | if (northingStr.size() > 6) |
| 222 | northingStr = northingStr.substr(northingStr.size() - 6); |
| 223 | |
| 224 | return strings::to_string_width(point.zoneNumber, 2) + point.zoneLetter + ' ' + |
| 225 | Get100kId(point.easting, point.northing, point.zoneNumber) + ' ' + eastingStr.substr(1, precision) + ' ' + |
| 226 | northingStr.substr(1, precision); |
| 227 | } |
| 228 | } // namespace |
| 229 | |
| 230 | // Convert UTM parameters to lat,lon for WSG 84 ellipsoid. |
no test coverage detected