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