Added comments with proposal of UMT and MGRS improvements in future

Signed-off-by: S. Kozyr <s.trump@gmail.com>
This commit is contained in:
Sergiy Kozyr 2023-06-01 00:27:24 +03:00
parent f26cbacc21
commit 9b63a3dcad
Signed by: strump
GPG key ID: C622E5563CAC205D
3 changed files with 21 additions and 1 deletions

View file

@ -146,6 +146,10 @@ UTMPoint LatLonToUtm(double lat, double lon)
// Generate UTM string from UTM point parameters.
string UTMtoStr(UTMPoint point)
{
// Easting and northing are rounded to nearest integer. Because of that in some cases
// last 5 digits of UTM and MGRS coordinates could differ (inaccuracy is no more then 1 meter).
// Some UTM converters truncate easting and northing instead of rounding. Consider this option.
return to_string(point.zone_number) + string(1, point.zone_letter) + " " + \
to_string(int(round(point.easting))) + " " + \
to_string(int(round(point.northing)));

View file

@ -6,7 +6,14 @@
namespace utm_mgrs_utils
{
// Convert from Lat and Lon coordinates in WGS 84 projection to UTM string
/* Convert from Lat and Lon coordinates in WGS 84 projection to UTM string.
* Preconditions:
* -180 < lon <= 180
* -80 < lat <= 84
*
* TODO: use Universal polar stereographic coordinate system for North pole
* and South pole regions. Would be needed when OM shows 3D globe.
*/
std::string FormatUTM(double lat, double lon);
/* Convert from Lat and Lon coordinates in WGS 84 projection to MGRS square string
@ -16,6 +23,13 @@ std::string FormatUTM(double lat, double lon);
* prec = 3 gives MGRS coordinates "11S PA 723 118"
* prec = 4 gives MGRS coordinates "11S PA 7234 1184"
* prec = 5 gives MGRS coordinates "11S PA 72349 11844" (highest precision)
*
* Preconditions:
* -180 < lon <= 180
* -80 < lat <= 84
*
* TODO: use Universal polar stereographic coordinate system for North pole
* and South pole regions. Would be needed when OM shows 3D globe.
*/
std::string FormatMGRS(double lat, double lon, int prec);

View file

@ -81,6 +81,7 @@ size_t MatchInt(string const & query, int & value, size_t startPos)
// Parse UTM format "(\d\d)\s?(\W)\s+(\d+)\s+(\d+)" and converts it to lat,lon.
// Return true if parsed successfully or false otherwise.
// See utm_mgrs_coords_match_test.cpp for sample UTM strings
// TODO: Add support of Polar regions. E.g. "A 1492875 2040624"
std::optional<ms::LatLon> MatchUTMCoords(string const & query)
{
int easting, northing;
@ -109,6 +110,7 @@ std::optional<ms::LatLon> MatchUTMCoords(string const & query)
// Parse MGRS format "(\d\d\W)\s*(\W\W)\s*(\d+)\s*(\d+)" and converts it to lat,lon.
// Returns true if parsed successfully or false otherwise.
// See utm_mgrs_coords_match_test.cpp for sample MGRS strings
// TODO: Add support of Polar regions. E.g. "A SN 92875 40624"
std::optional<ms::LatLon> MatchMGRSCoords(std::string const & query)
{
long zone_code;