Go to the documentation of this file.
26 # pragma warning (disable: 4127 4701)
29 #include "GeodesicProj.usage"
31 int main(
int argc,
const char*
const argv[]) {
36 bool azimuthal =
false, cassini =
false, gnomonic =
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 ==
"-c" ||
arg ==
"-z" ||
arg ==
"-g") {
51 cassini = azimuthal = gnomonic =
false;
52 cassini =
arg ==
"-c";
53 azimuthal =
arg ==
"-z";
54 gnomonic =
arg ==
"-g";
55 if (
m + 2 >= argc)
return usage(1,
true);
60 catch (
const std::exception&
e) {
61 std::cerr <<
"Error decoding arguments of " <<
arg <<
": "
66 }
else if (
arg ==
"-e") {
67 if (
m + 2 >= argc)
return usage(1,
true);
69 a = Utility::val<real>(std::string(argv[
m + 1]));
70 f = Utility::fract<real>(std::string(argv[
m + 2]));
72 catch (
const std::exception&
e) {
73 std::cerr <<
"Error decoding arguments of -e: " <<
e.what() <<
"\n";
77 }
else if (
arg ==
"-w")
78 longfirst = !longfirst;
79 else if (
arg ==
"-p") {
80 if (++
m == argc)
return usage(1,
true);
82 prec = Utility::val<int>(std::string(argv[
m]));
84 catch (
const std::exception&) {
85 std::cerr <<
"Precision " << argv[
m] <<
" is not a number\n";
88 }
else if (
arg ==
"--input-string") {
89 if (++
m == argc)
return usage(1,
true);
91 }
else if (
arg ==
"--input-file") {
92 if (++
m == argc)
return usage(1,
true);
94 }
else if (
arg ==
"--output-file") {
95 if (++
m == argc)
return usage(1,
true);
97 }
else if (
arg ==
"--line-separator") {
98 if (++
m == argc)
return usage(1,
true);
99 if (std::string(argv[
m]).
size() != 1) {
100 std::cerr <<
"Line separator must be a single character\n";
104 }
else if (
arg ==
"--comment-delimiter") {
105 if (++
m == argc)
return usage(1,
true);
107 }
else if (
arg ==
"--version") {
108 std::cout << argv[0] <<
": GeographicLib version "
112 return usage(!(
arg ==
"-h" ||
arg ==
"--help"),
arg !=
"--help");
115 if (!ifile.empty() && !istring.empty()) {
116 std::cerr <<
"Cannot specify --input-string and --input-file together\n";
119 if (ifile ==
"-") ifile.clear();
120 std::ifstream infile;
121 std::istringstream instring;
122 if (!ifile.empty()) {
123 infile.open(ifile.c_str());
124 if (!infile.is_open()) {
125 std::cerr <<
"Cannot open " << ifile <<
" for reading\n";
128 }
else if (!istring.empty()) {
129 std::string::size_type
m = 0;
131 m = istring.find(lsep,
m);
132 if (
m == std::string::npos)
136 instring.str(istring);
138 std::istream* input = !ifile.empty() ? &infile :
139 (!istring.empty() ? &instring : &std::cin);
141 std::ofstream outfile;
142 if (ofile ==
"-") ofile.clear();
143 if (!ofile.empty()) {
144 outfile.open(ofile.c_str());
145 if (!outfile.is_open()) {
146 std::cerr <<
"Cannot open " << ofile <<
" for writing\n";
150 std::ostream* output = !ofile.empty() ? &outfile : &std::cout;
152 if (!(azimuthal || cassini || gnomonic)) {
153 std::cerr <<
"Must specify \"-z lat0 lon0\" or "
154 <<
"\"-c lat0 lon0\" or \"-g lat0 lon0\"\n";
167 std::string
s, eol, stra, strb, strc;
168 std::istringstream
str;
170 std::cout << std::fixed;
171 while (std::getline(*input,
s)) {
174 if (!cdelim.empty()) {
175 std::string::size_type
m =
s.find(cdelim);
176 if (
m != std::string::npos) {
177 eol =
" " +
s.substr(
m) +
"\n";
183 if (!(
str >> stra >> strb))
186 x = Utility::val<real>(stra);
187 y = Utility::val<real>(strb);
216 catch (
const std::exception&
e) {
217 *output <<
"ERROR: " <<
e.what() <<
"\n";
223 catch (
const std::exception&
e) {
224 std::cerr <<
"Caught exception: " <<
e.what() <<
"\n";
228 std::cerr <<
"Caught unknown exception\n";
static int extra_digits()
void Forward(real lat, real lon, real &x, real &y, real &azi, real &rk) const
void Forward(real lat0, real lon0, real lat, real lon, real &x, real &y, real &azi, real &rk) const
Array< double, 1, 3 > e(1./3., 0.5, 2.)
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
int main(int argc, const char *const argv[])
void Reverse(real x, real y, real &lat, real &lon, real &azi, real &rk) const
Exception handling for GeographicLib.
Header for GeographicLib::AzimuthalEquidistant class.
Header for GeographicLib::Utility class.
EIGEN_DEVICE_FUNC const EIGEN_STRONG_INLINE ArgReturnType arg() const
Azimuthal equidistant projection.
str(const char *c, const SzType &n)
Header for GeographicLib::CassiniSoldner class.
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
void Reverse(real lat0, real lon0, real x, real y, real &lat, real &lon, real &azi, real &rk) const
Header for GeographicLib::Gnomonic class.
#define GEOGRAPHICLIB_VERSION_STRING
void reverse(const MatrixType &m)
static int set_digits(int ndigits=0)
Header for GeographicLib::DMS class.
Cassini-Soldner projection.
Header for GeographicLib::Geodesic class.
gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:02:22