Go to the documentation of this file.
24 # pragma warning (disable: 4127 4701)
27 #include "ConicProj.usage"
29 int main(
int argc,
const char*
const argv[]) {
34 bool lcc =
false, albers =
false,
reverse =
false, longfirst =
false;
40 std::string istring, ifile, ofile, cdelim;
43 for (
int m = 1;
m < argc; ++
m) {
44 std::string
arg(argv[
m]);
47 else if (
arg ==
"-c" ||
arg ==
"-a") {
50 if (
m + 2 >= argc)
return usage(1,
true);
52 for (
int i = 0;
i < 2; ++
i) {
59 catch (
const std::exception&
e) {
60 std::cerr <<
"Error decoding arguments of " <<
arg <<
": "
64 }
else if (
arg ==
"-l") {
65 if (++
m == argc)
return usage(1,
true);
73 catch (
const std::exception&
e) {
74 std::cerr <<
"Error decoding argument of " <<
arg <<
": "
78 }
else if (
arg ==
"-k") {
79 if (++
m == argc)
return usage(1,
true);
81 k1 = Utility::val<real>(std::string(argv[
m]));
83 catch (
const std::exception&
e) {
84 std::cerr <<
"Error decoding argument of " <<
arg <<
": "
88 }
else if (
arg ==
"-e") {
89 if (
m + 2 >= argc)
return usage(1,
true);
91 a = Utility::val<real>(std::string(argv[
m + 1]));
92 f = Utility::fract<real>(std::string(argv[
m + 2]));
94 catch (
const std::exception&
e) {
95 std::cerr <<
"Error decoding arguments of -e: " <<
e.what() <<
"\n";
99 }
else if (
arg ==
"-w")
100 longfirst = !longfirst;
101 else if (
arg ==
"-p") {
102 if (++
m == argc)
return usage(1,
true);
104 prec = Utility::val<int>(std::string(argv[
m]));
106 catch (
const std::exception&) {
107 std::cerr <<
"Precision " << argv[
m] <<
" is not a number\n";
110 }
else if (
arg ==
"--input-string") {
111 if (++
m == argc)
return usage(1,
true);
113 }
else if (
arg ==
"--input-file") {
114 if (++
m == argc)
return usage(1,
true);
116 }
else if (
arg ==
"--output-file") {
117 if (++
m == argc)
return usage(1,
true);
119 }
else if (
arg ==
"--line-separator") {
120 if (++
m == argc)
return usage(1,
true);
121 if (std::string(argv[
m]).
size() != 1) {
122 std::cerr <<
"Line separator must be a single character\n";
126 }
else if (
arg ==
"--comment-delimiter") {
127 if (++
m == argc)
return usage(1,
true);
129 }
else if (
arg ==
"--version") {
130 std::cout << argv[0] <<
": GeographicLib version "
134 return usage(!(
arg ==
"-h" ||
arg ==
"--help"),
arg !=
"--help");
137 if (!ifile.empty() && !istring.empty()) {
138 std::cerr <<
"Cannot specify --input-string and --input-file together\n";
141 if (ifile ==
"-") ifile.clear();
142 std::ifstream infile;
143 std::istringstream instring;
144 if (!ifile.empty()) {
145 infile.open(ifile.c_str());
146 if (!infile.is_open()) {
147 std::cerr <<
"Cannot open " << ifile <<
" for reading\n";
150 }
else if (!istring.empty()) {
151 std::string::size_type
m = 0;
153 m = istring.find(lsep,
m);
154 if (
m == std::string::npos)
158 instring.str(istring);
160 std::istream* input = !ifile.empty() ? &infile :
161 (!istring.empty() ? &instring : &std::cin);
163 std::ofstream outfile;
164 if (ofile ==
"-") ofile.clear();
165 if (!ofile.empty()) {
166 outfile.open(ofile.c_str());
167 if (!outfile.is_open()) {
168 std::cerr <<
"Cannot open " << ofile <<
" for writing\n";
172 std::ostream* output = !ofile.empty() ? &outfile : &std::cout;
174 if (!(lcc || albers)) {
175 std::cerr <<
"Must specify \"-c lat1 lat2\" or "
176 <<
"\"-a lat1 lat2\"\n";
190 std::string
s, eol, stra, strb, strc;
191 std::istringstream
str;
193 while (std::getline(*input,
s)) {
196 if (!cdelim.empty()) {
197 std::string::size_type
m =
s.find(cdelim);
198 if (
m != std::string::npos) {
199 eol =
" " +
s.substr(
m) +
"\n";
205 if (!(
str >> stra >> strb))
208 x = Utility::val<real>(stra);
209 y = Utility::val<real>(strb);
234 catch (
const std::exception&
e) {
235 *output <<
"ERROR: " <<
e.what() <<
"\n";
241 catch (
const std::exception&
e) {
242 std::cerr <<
"Caught exception: " <<
e.what() <<
"\n";
246 std::cerr <<
"Caught unknown exception\n";
static T AngNormalize(T x)
Albers equal area conic projection.
static int extra_digits()
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
static Math::real Decode(const std::string &dms, flag &ind)
Exception handling for GeographicLib.
void Reverse(real lon0, real x, real y, real &lat, real &lon, real &gamma, real &k) const
Header for GeographicLib::AlbersEqualArea class.
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 >)
#define GEOGRAPHICLIB_VERSION_STRING
void Forward(real lon0, real lat, real lon, real &x, real &y, real &gamma, real &k) const
void reverse(const MatrixType &m)
int main(int argc, const char *const argv[])
static int set_digits(int ndigits=0)
Header for GeographicLib::DMS class.
gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:11:17