21 const char* spaces =
" \t\n\v\f\r,";
22 for (string::size_type pos0 = 0, pos1; pos0 != string::npos;) {
23 pos1 =
s.find_first_not_of(spaces, pos0);
24 if (pos1 == string::npos)
26 pos0 =
s.find_first_of(spaces, pos1);
27 sa.push_back(
s.substr(pos1, pos0 == string::npos ? pos0 : pos0 - pos1));
31 MGRS::Reverse(sa[0], _zone, _northp, _easting, _northing, prec, centerp);
33 _lat, _long, _gamma, _k);
34 }
else if (sa.size() == 2) {
38 _zone, _northp, _easting, _northing, _gamma, _k);
39 }
else if (sa.size() == 3) {
40 unsigned zoneind, coordind;
41 if (sa[0].
size() > 0 && isalpha(sa[0][sa[0].
size() - 1])) {
44 }
else if (sa[2].
size() > 0 && isalpha(sa[2][sa[2].
size() - 1])) {
49 +
" of the form UTM/UPS Zone + Hemisphere"
50 +
" (ex: 38n, 09s, n)");
52 for (
unsigned i = 0;
i < 2; ++
i)
53 (
i ? _northing : _easting) = Utility::val<real>(sa[coordind +
i]);
55 _lat, _long, _gamma, _k);
58 throw GeographicErr(
"Coordinate requires 1, 2, or 3 elements");
65 os << fixed << setprecision(prec);
66 real a = longfirst ? _long : _lat;
67 real b = longfirst ? _lat : _long;
83 return DMS::Encode(longfirst ? _long : _lat,
unsigned(prec),
85 " " +
DMS::Encode(longfirst ? _lat : _long,
unsigned(prec),
91 prec =
max(-1,
min(6, prec) + 5);
93 MGRS::Forward(_zone, _northp, _easting, _northing, _lat, prec, mgrs);
99 prec =
max(-1,
min(6, prec) + 5);
101 MGRS::Forward(_alt_zone, _northp, _alt_easting, _alt_northing, _lat, prec,
107 real easting,
real northing,
int prec,
108 bool abbrev, std::string& utm) {
117 os << setw(-prec) << 0;
123 os << setw(-prec) << 0;
131 UTMUPSString(_zone, _northp, _easting, _northing, prec, abbrev, utm);
140 _zone, northp,
e,
n,
z);
142 UTMUPSString(_zone, northp,
e,
n, prec, abbrev, utm);
148 UTMUPSString(_alt_zone, _northp, _alt_easting, _alt_northing, prec,
158 _alt_zone, northp,
e,
n,
z);
160 UTMUPSString(_alt_zone, northp,
e,
n, prec, abbrev, utm);
165 if (_lat == 0 || (_northp && _lat >= 0) || (!_northp && _lat < 0) ||