Continues migration with DDS, Common
This commit is contained in:
1 parent
9b15cee841
commit
fa48db111e
668 files changed
+111841
-2
No files matched your search
Executable
+45
@@ -0,0 +1,45 @@
|
||||
|
||||
|
||||
|
||||
#include <GeographicLib/UTMUPS.hpp>
|
||||
#include <GeographicLib/MGRS.hpp>
|
||||
#include <string>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (argc != 2)
|
||||
{
|
||||
fprintf(stderr, "Usage: %s <mgrs>\n", argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::string mgrs = argv[1];
|
||||
mgrs.erase(remove_if(mgrs.begin(), mgrs.end(), isspace), mgrs.end());
|
||||
|
||||
int prec;
|
||||
double lonDeg, latDeg;
|
||||
try
|
||||
{
|
||||
int zone;
|
||||
bool northp;
|
||||
double x, y;
|
||||
GeographicLib::MGRS::Reverse(mgrs, zone, northp, x, y, prec, true);
|
||||
GeographicLib::UTMUPS::Reverse(zone, northp, x, y, latDeg, lonDeg);
|
||||
|
||||
GeographicLib::UTMUPS::Forward(latDeg, lonDeg, zone, northp, x, y);
|
||||
GeographicLib::MGRS::Forward(zone, northp, x, y, prec, mgrs);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
fprintf(stderr, "Error converting %s to Lon/Lat coords\n", mgrs.c_str());
|
||||
return -2;
|
||||
}
|
||||
std::string part1, part2, part3, part4;
|
||||
part1 = mgrs.substr(0, 3);
|
||||
part2 = mgrs.substr(3, 2);
|
||||
part3 = mgrs.substr(5, prec);
|
||||
part4 = mgrs.substr(5 + prec, prec);
|
||||
fprintf(stdout, "%s %s %s %s = %13.10f, %13.10f ( %13.10f, %13.10f )\n",
|
||||
part1.c_str(), part2.c_str(), part3.c_str(), part4.c_str(), lonDeg, latDeg, lonDeg / 180. * M_PI, latDeg / 180. * M_PI);
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user