Go to the documentation of this file.
   25 #  pragma warning (disable: 4127 4701) 
   28 #include "TransverseMercatorProj.usage" 
   30 int main(
int argc, 
const char* 
const argv[]) {
 
   35     bool exact = 
true, extended = 
false, series = 
false, 
reverse = 
false,
 
   43     std::string istring, ifile, ofile, cdelim;
 
   46     for (
int m = 1; 
m < argc; ++
m) {
 
   47       std::string 
arg(argv[
m]);
 
   50       else if (
arg == 
"-t") {
 
   54       } 
else if (
arg == 
"-s") {
 
   58       } 
else if (
arg == 
"-l") {
 
   59         if (++
m >= argc) 
return usage(1, 
true);
 
   67         catch (
const std::exception& 
e) {
 
   68           std::cerr << 
"Error decoding argument of " << 
arg << 
": " 
   72       } 
else if (
arg == 
"-k") {
 
   73         if (++
m >= argc) 
return usage(1, 
true);
 
   75           k0 = Utility::val<real>(std::string(argv[
m]));
 
   77         catch (
const std::exception& 
e) {
 
   78           std::cerr << 
"Error decoding argument of " << 
arg << 
": " 
   82       } 
else if (
arg == 
"-e") {
 
   83         if (
m + 2 >= argc) 
return usage(1, 
true);
 
   85           a = Utility::val<real>(std::string(argv[
m + 1]));
 
   86           f = Utility::fract<real>(std::string(argv[
m + 2]));
 
   88         catch (
const std::exception& 
e) {
 
   89           std::cerr << 
"Error decoding arguments of -e: " << 
e.what() << 
"\n";
 
   93       } 
else if (
arg == 
"-w")
 
   94         longfirst = !longfirst;
 
   95       else if (
arg == 
"-p") {
 
   96         if (++
m == argc) 
return usage(1, 
true);
 
   98           prec = Utility::val<int>(std::string(argv[
m]));
 
  100         catch (
const std::exception&) {
 
  101           std::cerr << 
"Precision " << argv[
m] << 
" is not a number\n";
 
  104       } 
else if (
arg == 
"--input-string") {
 
  105         if (++
m == argc) 
return usage(1, 
true);
 
  107       } 
else if (
arg == 
"--input-file") {
 
  108         if (++
m == argc) 
return usage(1, 
true);
 
  110       } 
else if (
arg == 
"--output-file") {
 
  111         if (++
m == argc) 
return usage(1, 
true);
 
  113       } 
else if (
arg == 
"--line-separator") {
 
  114         if (++
m == argc) 
return usage(1, 
true);
 
  115         if (std::string(argv[
m]).
size() != 1) {
 
  116           std::cerr << 
"Line separator must be a single character\n";
 
  120       } 
else if (
arg == 
"--comment-delimiter") {
 
  121         if (++
m == argc) 
return usage(1, 
true);
 
  123       } 
else if (
arg == 
"--version") {
 
  124         std::cout << argv[0] << 
": GeographicLib version " 
  128         return usage(!(
arg == 
"-h" || 
arg == 
"--help"), 
arg != 
"--help");
 
  131     if (!ifile.empty() && !istring.empty()) {
 
  132       std::cerr << 
"Cannot specify --input-string and --input-file together\n";
 
  135     if (ifile == 
"-") ifile.clear();
 
  136     std::ifstream infile;
 
  137     std::istringstream instring;
 
  138     if (!ifile.empty()) {
 
  139       infile.open(ifile.c_str());
 
  140       if (!infile.is_open()) {
 
  141         std::cerr << 
"Cannot open " << ifile << 
" for reading\n";
 
  144     } 
else if (!istring.empty()) {
 
  145       std::string::size_type 
m = 0;
 
  147         m = istring.find(lsep, 
m);
 
  148         if (
m == std::string::npos)
 
  152       instring.str(istring);
 
  154     std::istream* input = !ifile.empty() ? &infile :
 
  155       (!istring.empty() ? &instring : &std::cin);
 
  157     std::ofstream outfile;
 
  158     if (ofile == 
"-") ofile.clear();
 
  159     if (!ofile.empty()) {
 
  160       outfile.open(ofile.c_str());
 
  161       if (!outfile.is_open()) {
 
  162         std::cerr << 
"Cannot open " << ofile << 
" for writing\n";
 
  166     std::ostream* output = !ofile.empty() ? &outfile : &std::cout;
 
  178     std::string 
s, eol, stra, strb, strc;
 
  179     std::istringstream 
str;
 
  181     std::cout << std::fixed;
 
  182     while (std::getline(*input, 
s)) {
 
  185         if (!cdelim.empty()) {
 
  186           std::string::size_type 
m = 
s.find(cdelim);
 
  187           if (
m != std::string::npos) {
 
  188             eol = 
" " + 
s.substr(
m) + 
"\n";
 
  194         if (!(
str >> stra >> strb))
 
  197           x = Utility::val<real>(stra);
 
  198           y = Utility::val<real>(strb);
 
  224       catch (
const std::exception& 
e) {
 
  225         *output << 
"ERROR: " << 
e.what() << 
"\n";
 
  231   catch (
const std::exception& 
e) {
 
  232     std::cerr << 
"Caught exception: " << 
e.what() << 
"\n";
 
  236     std::cerr << 
"Caught unknown exception\n";
 
  
static T AngNormalize(T x)
static int extra_digits()
Array< double, 1, 3 > e(1./3., 0.5, 2.)
An exact implementation of the transverse Mercator projection.
static std::string str(T x, int p=-1)
Namespace for GeographicLib.
static void DecodeLatLon(const std::string &dmsa, const std::string &dmsb, real &lat, real &lon, bool longfirst=false)
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
static constexpr double lon0
void Reverse(real lon0, real x, real y, real &lat, real &lon, real &gamma, real &k) const
static Math::real Decode(const std::string &dms, flag &ind)
Exception handling for GeographicLib.
int main(int argc, const char *const argv[])
Header for GeographicLib::TransverseMercator class.
void Forward(real lon0, real lat, real lon, real &x, real &y, real &gamma, real &k) const
Header for GeographicLib::Utility class.
EIGEN_DEVICE_FUNC const EIGEN_STRONG_INLINE ArgReturnType arg() const
str(const char *c, const SzType &n)
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
void Reverse(real lon0, real x, real y, real &lat, real &lon, real &gamma, real &k) const
void Forward(real lon0, real lat, real lon, real &x, real &y, real &gamma, real &k) const
#define GEOGRAPHICLIB_VERSION_STRING
void reverse(const MatrixType &m)
static int set_digits(int ndigits=0)
Header for GeographicLib::TransverseMercatorExact class.
Header for GeographicLib::DMS class.
Transverse Mercator projection.
static constexpr double k
gtsam
Author(s): 
autogenerated on Wed May 28 2025 03:08:23