1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-10-06 06:43:22 +02:00

Added support for Krovak projection

This commit is contained in:
Martin Tůma 2018-05-29 00:17:20 +02:00
parent 6bee2a46f1
commit 7d412a274d
6 changed files with 133 additions and 2 deletions

View File

@ -129,7 +129,8 @@ HEADERS += src/config.h \
src/map/rectd.h \
src/map/geocentric.h \
src/map/mercator.h \
src/map/jnxmap.h
src/map/jnxmap.h \
src/map/krovak.h
SOURCES += src/main.cpp \
src/common/coordinates.cpp \
src/common/rectc.cpp \
@ -226,7 +227,8 @@ SOURCES += src/main.cpp \
src/data/oziparsers.cpp \
src/map/geocentric.cpp \
src/map/mercator.cpp \
src/map/jnxmap.cpp
src/map/jnxmap.cpp \
src/map/krovak.cpp
RESOURCES += gpxsee.qrc
TRANSLATIONS = lang/gpxsee_cs.ts \
lang/gpxsee_sv.ts \

View File

@ -21,6 +21,7 @@ ED50(ED77) / UTM zone 40N,2060,4154,16040,9001,9807,4400,8801,0,9102,8802,57,910
ED50(ED77) / UTM zone 41N,2061,4154,16041,9001,9807,4400,8801,0,9102,8802,63,9102,8805,0.9996,9201,8806,500000,9001,8807,0,9001,,,,,,
Dabola 1981 / UTM zone 28N,2063,4315,16028,9001,9807,4400,8801,0,9102,8802,-15,9102,8805,0.9996,9201,8806,500000,9001,8807,0,9001,,,,,,
Dabola 1981 / UTM zone 29N,2064,4315,16029,9001,9807,4400,8801,0,9102,8802,-9,9102,8805,0.9996,9201,8806,500000,9001,8807,0,9001,,,,,,
S-JTSK (Ferro) / Krovak,2065,4818,19952,9001,9819,6501,1036,30.1717303,9110,8806,0,9001,8807,0,9001,8811,49.3,9110,8818,78.3,9110,8819,0.9999,9201,8833,42.3,9110
Naparima 1955 / UTM zone 20N,2067,4158,16020,9001,9807,4400,8801,0,9102,8802,-63,9102,8805,0.9996,9201,8806,500000,9001,8807,0,9001,,,,,,
ELD79 / Libya zone 5,2068,4159,18240,9001,9807,4499,8801,0,9102,8802,9,9102,8805,0.9999,9201,8806,200000,9001,8807,0,9001,,,,,,
ELD79 / Libya zone 6,2069,4159,18241,9001,9807,4499,8801,0,9102,8802,11,9102,8805,0.9999,9201,8806,200000,9001,8807,0,9001,,,,,,
@ -1766,6 +1767,7 @@ Korea 2000 / West Belt 2010,5185,4737,5101,9001,9807,4530,8801,38,9102,8802,125,
Korea 2000 / Central Belt 2010,5186,4737,5102,9001,9807,4530,8801,38,9102,8802,127,9102,8805,1,9201,8806,200000,9001,8807,600000,9001,,,,,,
Korea 2000 / East Belt 2010,5187,4737,5103,9001,9807,4530,8801,38,9102,8802,129,9102,8805,1,9201,8806,200000,9001,8807,600000,9001,,,,,,
Korea 2000 / East Sea Belt 2010,5188,4737,5104,9001,9807,4530,8801,38,9102,8802,131,9102,8805,1,9201,8806,200000,9001,8807,600000,9001,,,,,,
S-JTSK (Ferro) / Krovak East North,5221,4818,5218,9001,1041,4499,1036,30.1717303,9110,8806,0,9001,8807,0,9001,8811,49.3,9110,8818,78.3,9110,8819,0.9999,9201,8833,42.3,9110
WGS 84 / Gabon TM,5223,4326,5222,9001,9807,4499,8801,0,9102,8802,12,9102,8805,0.9996,9201,8806,500000,9001,8807,500000,9001,,,,,,
Kandawala / Sri Lanka Grid,5234,4244,5231,9001,9807,4400,8801,7.0001729,9110,8802,80.461816,9110,8805,0.9999238418,9201,8806,200000,9001,8807,200000,9001,,,,,,
SLD99 / Sri Lanka Grid 1999,5235,5233,5232,9001,9807,4400,8801,7.00016975,9110,8802,80.46181671,9110,8805,0.9999238418,9201,8806,500000,9001,8807,500000,9001,,,,,,
@ -1844,6 +1846,8 @@ RSRGD2000 / MSLC2000,5479,4764,5475,9001,9802,4500,8821,-78,9110,8822,163,9110,8
RSRGD2000 / BCLC2000,5480,4764,5476,9001,9802,4500,8821,-74.3,9110,8822,165,9110,8823,-73.4,9110,8824,-75.2,9110,8826,5000000,9001,8827,3000000,9001,,,
RSRGD2000 / PCLC2000,5481,4764,5477,9001,9802,4500,8821,-71.3,9110,8822,166,9110,8823,-70.4,9110,8824,-72.2,9110,8826,3000000,9001,8827,1000000,9001,,,
RGAF09 / UTM zone 20N,5490,5489,16020,9001,9807,4400,8801,0,9102,8802,-63,9102,8805,0.9996,9201,8806,500000,9001,8807,0,9001,,,,,,
S-JTSK / Krovak,5513,4156,5509,9001,9819,6501,1036,30.1717303,9110,8806,0,9001,8807,0,9001,8811,49.3,9110,8818,78.3,9110,8819,0.9999,9201,8833,24.5,9110
S-JTSK / Krovak East North,5514,4156,5510,9001,1041,4499,1036,30.1717303,9110,8806,0,9001,8807,0,9001,8811,49.3,9110,8818,78.3,9110,8819,0.9999,9201,8833,24.5,9110
CI1971 / Chatham Islands Map Grid,5518,4672,5517,9001,9807,4500,8801,-44,9110,8802,-176.3,9110,8805,1,9201,8806,350000,9001,8807,650000,9001,,,,,,
CI1979 / Chatham Islands Map Grid,5519,4673,5517,9001,9807,4500,8801,-44,9110,8802,-176.3,9110,8805,1,9201,8806,350000,9001,8807,650000,9001,,,,,,
DHDN / 3-degree Gauss-Kruger zone 1,5520,4314,16261,9001,9807,4530,8801,0,9102,8802,3,9102,8805,1,9201,8806,1500000,9001,8807,0,9001,,,,,,

Can't render this file because it is too large.

74
src/map/krovak.cpp Normal file
View File

@ -0,0 +1,74 @@
#include "ellipsoid.h"
#include "krovak.h"
Krovak::Krovak(const Ellipsoid *ellipsoid, double standardParallel,
double azimuth, double scale, double centerLatitude, double longitudeOrigin,
double falseEasting, double falseNorthing, Orientation orientation)
{
double phiC = deg2rad(centerLatitude);
double sinPhiC = sin(phiC);
double sinPhiC2 = sinPhiC * sinPhiC;
double cosPhiC = cos(phiC);
double cosPhiC2 = cosPhiC * cosPhiC;
double cosPhiC4 = cosPhiC2 * cosPhiC2;
double alphaC = deg2rad(azimuth);
_phiP = deg2rad(standardParallel);
_e = sqrt(ellipsoid->es());
_A = ellipsoid->radius() * sqrt(1.0 - ellipsoid->es())
/ (1.0 - ellipsoid->es() * sinPhiC2);
_B = sqrt(1.0 + (ellipsoid->es() * cosPhiC4 / (1.0 - ellipsoid->es())));
double gamma0 = asin(sinPhiC / _B);
_t0 = tan(M_PI_4 + gamma0 / 2.0) * pow((1.0 + _e * sinPhiC) /
(1.0 - _e * sinPhiC), _e*_B / 2.0) / pow(tan(M_PI_4 + phiC/2.0), _B);
_n = sin(_phiP);
_r0 = scale * _A / tan(_phiP);
_FE = falseEasting;
_FN = falseNorthing;
_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 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);
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 theta = _n * D;
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));
}
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 Xp2 = Xp * Xp;
double Yp2 = Yp * Yp;
double r = sqrt(Xp2 + Yp2);
double theta = atan(Yp / Xp);
double D = theta / sin(_phiP);
double T = 2.0 * (atan(pow(_r0 / r, 1.0/_n) * tan(M_PI_4 + _phiP/2.0))
- M_PI_4);
double U = asin(_cosAlphaC * sin(T) - _sinAlphaC * cos(T) * cos(D));
double V = asin(cos(T) * sin(D) / cos(U));
double phi = U;
for (int i = 0; i < 3; i++)
phi = 2.0 * (atan(pow(_t0, -1.0/_B) * pow(tan(U/2.0 + M_PI_4), 1.0/_B)
* pow((1.0 + _e * sin(phi))/(1.0 - _e * sin(phi)), _e/2.0)) - M_PI_4);
return Coordinates(rad2deg(_lambda0 - V/_B), rad2deg(phi));
}

32
src/map/krovak.h Normal file
View File

@ -0,0 +1,32 @@
#ifndef KROVAK_H
#define KROVAK_H
#include "ct.h"
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);
virtual CT *clone() const {return new Krovak(*this);}
virtual PointD ll2xy(const Coordinates &c) const;
virtual Coordinates xy2ll(const PointD &p) const;
private:
double _e, _A, _B, _t0, _n, _r0, _phiP;
double _cosAlphaC, _sinAlphaC, _lambda0, _FE, _FN;
Orientation _orientation;
};
#endif // KROVAK_H

View File

@ -32,6 +32,7 @@ static bool parameter(int key, double val, int units, Projection::Setup &setup)
case 8802:
case 8812:
case 8822:
case 8833:
{AngularUnits au(units);
if (au.isNull())
return false;
@ -39,6 +40,7 @@ static bool parameter(int key, double val, int units, Projection::Setup &setup)
return true;
case 8805:
case 8815:
case 8819:
setup.setScale(val);
return true;
case 8806:
@ -58,12 +60,14 @@ static bool parameter(int key, double val, int units, Projection::Setup &setup)
setup.setFalseNorthing(lu.toMeters(val));}
return true;
case 8813:
case 8818:
case 8823:
{AngularUnits au(units);
if (au.isNull())
return false;
setup.setStandardParallel1(au.toDegrees(val));}
return true;
case 1036:
case 8814:
case 8824:
{AngularUnits au(units);

View File

@ -5,6 +5,7 @@
#include "lambertconic.h"
#include "albersequal.h"
#include "lambertazimuthal.h"
#include "krovak.h"
#include "latlon.h"
#include "gcs.h"
#include "pcs.h"
@ -15,11 +16,13 @@ Projection::Method::Method(int id)
{
switch (id) {
case 1024:
case 1041:
case 9801:
case 9802:
case 9804:
case 9807:
case 9815:
case 9819:
case 9820:
case 9822:
_id = id;
@ -39,6 +42,12 @@ Projection::Projection(const PCS *pcs) : _gcs(pcs->gcs()), _units(pcs->units()),
case 1024:
_ct = new WebMercator();
break;
case 1041:
_ct = new Krovak(ellipsoid, setup.standardParallel1(),
setup.standardParallel2(), setup.scale(), setup.latitudeOrigin(),
setup.longitudeOrigin(), setup.falseEasting(),
setup.falseNorthing(), Krovak::North);
break;
case 9801:
case 9815: // Oblique mercator aproximation using LCC1
_ct = new LambertConic1(ellipsoid, setup.latitudeOrigin(),
@ -61,6 +70,12 @@ Projection::Projection(const PCS *pcs) : _gcs(pcs->gcs()), _units(pcs->units()),
setup.longitudeOrigin(), setup.scale(), setup.falseEasting(),
setup.falseNorthing());
break;
case 9819:
_ct = new Krovak(ellipsoid, setup.standardParallel1(),
setup.standardParallel2(), setup.scale(), setup.latitudeOrigin(),
setup.longitudeOrigin(), setup.falseEasting(),
setup.falseNorthing(), Krovak::South);
break;
case 9820:
_ct = new LambertAzimuthal(ellipsoid, setup.latitudeOrigin(),
setup.longitudeOrigin(), setup.falseEasting(),