mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-01-19 04:02:09 +01:00
Refactoring
This commit is contained in:
parent
58e752a022
commit
2c816a509b
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
Krovak::Krovak(const Ellipsoid *ellipsoid, double standardParallel,
|
Krovak::Krovak(const Ellipsoid *ellipsoid, double standardParallel,
|
||||||
double azimuth, double scale, double centerLatitude, double longitudeOrigin,
|
double azimuth, double scale, double centerLatitude, double longitudeOrigin,
|
||||||
double falseEasting, double falseNorthing, Orientation orientation)
|
double falseEasting, double falseNorthing)
|
||||||
{
|
{
|
||||||
double phiC = deg2rad(centerLatitude);
|
double phiC = deg2rad(centerLatitude);
|
||||||
double sinPhiC = sin(phiC);
|
double sinPhiC = sin(phiC);
|
||||||
@ -28,34 +28,30 @@ Krovak::Krovak(const Ellipsoid *ellipsoid, double standardParallel,
|
|||||||
_cosAlphaC = cos(alphaC);
|
_cosAlphaC = cos(alphaC);
|
||||||
_sinAlphaC = sin(alphaC);
|
_sinAlphaC = sin(alphaC);
|
||||||
_lambda0 = deg2rad(longitudeOrigin);
|
_lambda0 = deg2rad(longitudeOrigin);
|
||||||
_orientation = orientation;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PointD Krovak::ll2xy(const Coordinates &c) const
|
PointD Krovak::ll2xy(const Coordinates &c) const
|
||||||
{
|
{
|
||||||
double phi = deg2rad(c.lat());
|
double phi = deg2rad(c.lat());
|
||||||
double lambda = deg2rad(c.lon());
|
double lambda = deg2rad(c.lon());
|
||||||
double sinPhi = sin(phi);
|
double eSinPhi = _e * sin(phi);
|
||||||
double eSinPhi = _e * sinPhi;
|
|
||||||
|
|
||||||
double U = 2.0 * (atan(_t0 * pow(tan(phi/2.0 + M_PI_4), _B)
|
double U = 2.0 * (atan(_t0 * pow(tan(phi/2.0 + M_PI_4), _B)
|
||||||
/ pow((1.0 + eSinPhi) / (1.0 - eSinPhi), _e * _B / 2.0)) - M_PI_4);
|
/ pow((1.0 + eSinPhi) / (1.0 - eSinPhi), _e * _B/2.0)) - M_PI_4);
|
||||||
|
double cosU = cos(U);
|
||||||
double V = _B * (_lambda0 - lambda);
|
double V = _B * (_lambda0 - lambda);
|
||||||
double T = asin(_cosAlphaC * sin(U) + _sinAlphaC * cos(U) * cos(V));
|
double T = asin(_cosAlphaC * sin(U) + _sinAlphaC * cosU * cos(V));
|
||||||
double D = asin(cos(U) * sin(V) / cos(T));
|
double D = asin(cosU * sin(V) / cos(T));
|
||||||
double theta = _n * D;
|
double theta = _n * D;
|
||||||
double r = _r0 * pow(tan(M_PI_4 + _phiP / 2.0), _n)
|
double r = _r0 * pow(tan(M_PI_4 + _phiP/2.0), _n)
|
||||||
/ pow(tan(T/2.0 + M_PI_4), _n);
|
/ pow(tan(T/2.0 + M_PI_4), _n);
|
||||||
double sign = (_orientation == North) ? -1.0 : 1.0;
|
|
||||||
|
|
||||||
return PointD(sign * (r * sin(theta) + _FE), sign * (r * cos(theta) + _FN));
|
return PointD(r * sin(theta) + _FE, r * cos(theta) + _FN);
|
||||||
}
|
}
|
||||||
|
|
||||||
Coordinates Krovak::xy2ll(const PointD &p) const
|
Coordinates Krovak::xy2ll(const PointD &p) const
|
||||||
{
|
{
|
||||||
double sign = (_orientation == North) ? -1.0 : 1.0;
|
double Xp = p.y() - _FN;
|
||||||
double Xp = sign * p.y() - _FN;
|
double Yp = p.x() - _FE;
|
||||||
double Yp = sign * p.x() - _FE;
|
|
||||||
double Xp2 = Xp * Xp;
|
double Xp2 = Xp * Xp;
|
||||||
double Yp2 = Yp * Yp;
|
double Yp2 = Yp * Yp;
|
||||||
double r = sqrt(Xp2 + Yp2);
|
double r = sqrt(Xp2 + Yp2);
|
||||||
|
@ -8,15 +8,9 @@ class Ellipsoid;
|
|||||||
class Krovak : public CT
|
class Krovak : public CT
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum Orientation {
|
|
||||||
North,
|
|
||||||
South
|
|
||||||
};
|
|
||||||
|
|
||||||
Krovak(const Ellipsoid *ellipsoid, double standardParallel,
|
Krovak(const Ellipsoid *ellipsoid, double standardParallel,
|
||||||
double azimuth, double scale, double centerLatitude,
|
double azimuth, double scale, double centerLatitude,
|
||||||
double longitudeOrigin, double falseEasting, double falseNorthing,
|
double longitudeOrigin, double falseEasting, double falseNorthing);
|
||||||
Orientation orientation);
|
|
||||||
|
|
||||||
virtual CT *clone() const {return new Krovak(*this);}
|
virtual CT *clone() const {return new Krovak(*this);}
|
||||||
|
|
||||||
@ -26,7 +20,26 @@ public:
|
|||||||
private:
|
private:
|
||||||
double _e, _A, _B, _t0, _n, _r0, _phiP;
|
double _e, _A, _B, _t0, _n, _r0, _phiP;
|
||||||
double _cosAlphaC, _sinAlphaC, _lambda0, _FE, _FN;
|
double _cosAlphaC, _sinAlphaC, _lambda0, _FE, _FN;
|
||||||
Orientation _orientation;
|
};
|
||||||
|
|
||||||
|
class KrovakNE : public CT
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
KrovakNE(const Ellipsoid *ellipsoid, double standardParallel,
|
||||||
|
double azimuth, double scale, double centerLatitude,
|
||||||
|
double longitudeOrigin, double falseEasting, double falseNorthing)
|
||||||
|
: _k(ellipsoid, standardParallel, azimuth, scale, centerLatitude,
|
||||||
|
longitudeOrigin, falseEasting, falseNorthing) {}
|
||||||
|
|
||||||
|
virtual CT *clone() const {return new KrovakNE(*this);}
|
||||||
|
|
||||||
|
virtual PointD ll2xy(const Coordinates &c) const
|
||||||
|
{PointD p(_k.ll2xy(c)); return PointD(-p.x(), -p.y());}
|
||||||
|
virtual Coordinates xy2ll(const PointD &p) const
|
||||||
|
{return _k.xy2ll(PointD(-p.x(), -p.y()));}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Krovak _k;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // KROVAK_H
|
#endif // KROVAK_H
|
||||||
|
@ -43,10 +43,10 @@ Projection::Projection(const PCS *pcs) : _gcs(pcs->gcs()), _units(pcs->units()),
|
|||||||
_ct = new WebMercator();
|
_ct = new WebMercator();
|
||||||
break;
|
break;
|
||||||
case 1041:
|
case 1041:
|
||||||
_ct = new Krovak(ellipsoid, setup.standardParallel1(),
|
_ct = new KrovakNE(ellipsoid, setup.standardParallel1(),
|
||||||
setup.standardParallel2(), setup.scale(), setup.latitudeOrigin(),
|
setup.standardParallel2(), setup.scale(), setup.latitudeOrigin(),
|
||||||
setup.longitudeOrigin(), setup.falseEasting(),
|
setup.longitudeOrigin(), setup.falseEasting(),
|
||||||
setup.falseNorthing(), Krovak::North);
|
setup.falseNorthing());
|
||||||
break;
|
break;
|
||||||
case 9801:
|
case 9801:
|
||||||
case 9815: // Oblique mercator aproximation using LCC1
|
case 9815: // Oblique mercator aproximation using LCC1
|
||||||
@ -74,7 +74,7 @@ Projection::Projection(const PCS *pcs) : _gcs(pcs->gcs()), _units(pcs->units()),
|
|||||||
_ct = new Krovak(ellipsoid, setup.standardParallel1(),
|
_ct = new Krovak(ellipsoid, setup.standardParallel1(),
|
||||||
setup.standardParallel2(), setup.scale(), setup.latitudeOrigin(),
|
setup.standardParallel2(), setup.scale(), setup.latitudeOrigin(),
|
||||||
setup.longitudeOrigin(), setup.falseEasting(),
|
setup.longitudeOrigin(), setup.falseEasting(),
|
||||||
setup.falseNorthing(), Krovak::South);
|
setup.falseNorthing());
|
||||||
break;
|
break;
|
||||||
case 9820:
|
case 9820:
|
||||||
_ct = new LambertAzimuthal(ellipsoid, setup.latitudeOrigin(),
|
_ct = new LambertAzimuthal(ellipsoid, setup.latitudeOrigin(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user