44 if (!(setzone >= MINPSEUDOZONE && setzone <= MAXZONE))
46 if (setzone >= MINZONE || setzone ==
INVALID)
50 if (setzone == UTM || (lat >= -80 && lat < 84)) {
56 int zone = (ilon + 186)/6;
58 if (band == 7 && zone == 31 && ilon >= 3)
60 else if (band == 9 && ilon >= 0 && ilon < 42)
61 zone = 2 * ((ilon + 183)/12) + 1;
70 int setzone,
bool mgrslimits) {
73 +
"d not in [-90d, 90d]");
74 bool northp1 = lat >= 0;
75 int zone1 = StandardZone(lat, lon, setzone);
83 bool utmp = zone1 != UPS;
86 lon0 = CentralMeridian(zone1),
88 dlon =
abs(dlon - 360 *
floor((dlon + 180)/360));
93 +
"d more than 60d from center of UTM zone " 100 +
"d more than 20d from " 101 + (northp1 ?
"N" :
"S") +
" pole");
104 int ind = (utmp ? 2 : 0) + (northp1 ? 1 : 0);
105 x1 += falseeasting_[ind];
106 y1 += falsenorthing_[ind];
107 if (! CheckCoords(zone1 != UPS, northp1, x1, y1, mgrslimits,
false) )
110 +
" out of legal range for " 128 if (!(zone >= MINZONE && zone <= MAXZONE))
130 +
" not in range [0, 60]");
131 bool utmp = zone != UPS;
132 CheckCoords(utmp, northp, x, y, mgrslimits);
133 int ind = (utmp ? 2 : 0) + (northp ? 1 : 0);
134 x -= falseeasting_[ind];
135 y -= falsenorthing_[ind];
138 x, y, lat, lon, gamma, k);
144 bool mgrslimits,
bool throwp) {
148 int ind = (utmp ? 2 : 0) + (northp ? 1 : 0);
149 if (x < mineasting_[ind] - slop || x > maxeasting_[ind] + slop) {
150 if (!throwp)
return false;
152 + (mgrslimits ?
"MGRS/" :
"")
153 + (utmp ?
"UTM" :
"UPS") +
" range for " 154 + (northp ?
"N" :
"S" ) +
" hemisphere [" 160 if (y < minnorthing_[ind] - slop || y > maxnorthing_[ind] + slop) {
161 if (!throwp)
return false;
163 + (mgrslimits ?
"MGRS/" :
"")
164 + (utmp ?
"UTM" :
"UPS") +
" range for " 165 + (northp ?
"N" :
"S" ) +
" hemisphere [" 175 int zoneout,
bool northpout,
real& xout,
real& yout,
177 bool northp = northpin;
178 if (zonein != zoneout) {
188 if (zone1 == 0 && northp != northpout)
190 (
"Attempt to transfer UPS coordinates between hemispheres");
195 if (zoneout == 0 && northp != northpout)
197 (
"Attempt to transfer UPS coordinates between hemispheres");
202 if (northp != northpout)
210 unsigned zlen = unsigned(zonestr.size());
215 throw GeographicErr(
"More than 7 characters in zone specification " 218 const char*
c = zonestr.c_str();
220 int zone1 = strtol(c, &q, 10);
227 ", use just the hemisphere for UPS");
228 }
else if (!(zone1 >= MINUTMZONE && zone1 <= MAXUTMZONE))
230 +
" not in range [1, 60]");
231 else if (!isdigit(zonestr[0]))
235 throw GeographicErr(
"More than 2 digits use to specify zone " 238 string hemi(zonestr, q - c);
239 for (std::string::iterator
p = hemi.begin();
p != hemi.end(); ++
p)
240 *
p =
char(std::tolower(*
p));
241 if (q == c && (hemi ==
"inv" || hemi ==
"invalid")) {
246 bool northp1 = hemi ==
"north" || hemi ==
"n";
247 if (!(northp1 || hemi ==
"south" || hemi ==
"s"))
248 throw GeographicErr(
string(
"Illegal hemisphere ") + hemi +
" in " 249 + zonestr +
", specify north or south");
256 return string(abbrev ?
"inv" :
"invalid");
257 if (!(zone >= MINZONE && zone <= MAXZONE))
259 +
" not in range [0, 60]");
262 os << setfill(
'0') << setw(2) << zone;
264 os << (northp ?
'n' :
's');
266 os << (northp ?
"north" :
"south");
272 if (epsg >= epsg01N && epsg <= epsg60N) {
273 zone = (epsg - epsg01N) + MINUTMZONE;
275 }
else if (epsg == epsgN) {
278 }
else if (epsg >= epsg01S && epsg <= epsg60S) {
279 zone = (epsg - epsg01S) + MINUTMZONE;
280 }
else if (epsg == epsgS) {
291 else if (zone >= MINUTMZONE && zone <= MAXUTMZONE)
292 epsg = (zone - MINUTMZONE) + epsg01S;
293 if (epsg >= 0 && northp)
294 epsg += epsgN - epsgS;
static std::string EncodeZone(int zone, bool northp, bool abbrev=true)
static const int falseeasting_[4]
Header for GeographicLib::Utility class.
Header for GeographicLib::UTMUPS class.
static const int minnorthing_[4]
static const int maxnorthing_[4]
static const int maxeasting_[4]
static void Transfer(int zonein, bool northpin, real xin, real yin, int zoneout, bool northpout, real &xout, real &yout, int &zone)
static void DecodeEPSG(int epsg, int &zone, bool &northp)
void Forward(real lon0, real lat, real lon, real &x, real &y, real &gamma, real &k) const
static const TransverseMercator & UTM()
static const int mineasting_[4]
static int LatitudeBand(real lat)
Header for GeographicLib::TransverseMercator class.
void Forward(bool northp, real lat, real lon, real &x, real &y, real &gamma, real &k) const
Header for GeographicLib::MGRS class.
void Reverse(bool northp, real x, real y, real &lat, real &lon, real &gamma, real &k) const
static void Forward(real lat, real lon, int &zone, bool &northp, real &x, real &y, real &gamma, real &k, int setzone=STANDARD, bool mgrslimits=false)
static const int falsenorthing_[4]
const mpreal gamma(const mpreal &x, mp_rnd_t r=mpreal::get_default_rnd())
static int EncodeEPSG(int zone, bool northp)
static const PolarStereographic & UPS()
Namespace for GeographicLib.
EIGEN_DEVICE_FUNC const Scalar & q
static void DecodeZone(const std::string &zonestr, int &zone, bool &northp)
static std::string str(T x, int p=-1)
void Reverse(real lon0, real x, real y, real &lat, real &lon, real &gamma, real &k) const
static void Reverse(int zone, bool northp, real x, real y, real &lat, real &lon, real &gamma, real &k, bool mgrslimits=false)
EIGEN_DEVICE_FUNC const FloorReturnType floor() const
Exception handling for GeographicLib.
ofstream os("timeSchurFactors.csv")
static bool CheckCoords(bool utmp, bool northp, real x, real y, bool msgrlimits=false, bool throwp=true)
static Math::real UTMShift()
Header for GeographicLib::PolarStereographic class.
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
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T fmod(const T &a, const T &b)
static int StandardZone(real lat, real lon, int setzone=STANDARD)