28 #define _USE_MATH_DEFINES
31 #include "../../../../shared/api/physical_constants.h"
34 namespace projections {
36 MaxLongitude (27.11 ), orignX (5122000 ), orignY (10000100 ),tileSize(256, 256)
51 return (1.0 / 298.257222101);
59 lat =
bound(lat, MinLatitude, MaxLatitude);
60 lng =
bound(lng, MinLongitude, MaxLongitude);
61 QVector <double> lks(3);
70 ret.SetX((qint64) floor((lks[0] + orignX) / res));
71 ret.SetY((qint64) floor((orignY - lks[1]) / res));
82 QVector <double> lks(2);
83 lks[0]=(x * res) - orignX;
84 lks[1]=-(y * res) + orignY;
88 ret.
SetLat(
bound(lks[1], MinLatitude, MaxLatitude));
89 ret.
SetLng(
bound(lks[0], MinLongitude, MaxLongitude));
93 QVector <double> LKS94Projection::DTM10(
const QVector <double>& lonlat)
96 double semiMajor = 6378137.0;
97 double semiMinor = 6356752.3142451793;
99 es = 1.0 - (semiMinor * semiMinor) / (semiMajor * semiMajor);
102 double lon = lonlat[0] *
DEG2RAD;
103 double lat = lonlat[1] *
DEG2RAD;
104 double h = lonlat.count() < 3 ? 0 : std::isnan(lonlat[2]) ? 0 : lonlat[2];
105 double v = semiMajor / sqrt(1 - es * pow(sin(lat), 2));
106 double x = (v +
h) * cos(lat) * cos(lon);
107 double y = (v +
h) * cos(lat) * sin(lon);
108 double z = ((1 - es) * v + h) * sin(lat);
109 QVector <double> ret(3);
115 QVector <double> LKS94Projection::MTD10(QVector <double>& pnt)
117 QVector <double> ret(3);
118 const double COS_67P5 = 0.38268343236508977;
119 const double AD_C = 1.0026000;
122 double semiMajor = 6378137.0;
123 double semiMinor = 6356752.3141403561;
126 es = 1.0 - (semiMinor * semiMinor) / (semiMajor * semiMajor);
127 ses = (pow(semiMajor, 2) - pow(semiMinor, 2)) / pow(semiMinor, 2);
130 double Z = pnt.count() < 3 ? 0 : std::isnan(pnt[2]) ? 0 : pnt[2];
137 lon = atan2(pnt[1], pnt[0]);
172 double W2 = pnt[0] * pnt[0] + pnt[1] * pnt[1];
174 double T0 = Z * AD_C;
175 double S0 = sqrt(T0 * T0 + W2);
176 double Sin_B0 = T0 / S0;
177 double Cos_B0 = W / S0;
178 double Sin3_B0 = pow(Sin_B0, 3);
179 double T1 = Z + semiMinor * ses * Sin3_B0;
180 double Sum = W - semiMajor * es * Cos_B0 * Cos_B0 * Cos_B0;
181 double S1 = sqrt(T1 * T1 + Sum * Sum);
182 double Sin_p1 = T1 / S1;
183 double Cos_p1 = Sum / S1;
184 double Rn = semiMajor / sqrt(1.0 - es * Sin_p1 * Sin_p1);
185 if(Cos_p1 >= COS_67P5)
187 Height = W / Cos_p1 - Rn;
190 if(Cos_p1 <= -COS_67P5)
192 Height = W / -Cos_p1 - Rn;
196 Height = Z / Sin_p1 + Rn * (es - 1.0);
201 lat = atan(Sin_p1 / Cos_p1);
208 QVector <double> LKS94Projection::DTM00(QVector <double>& lonlat)
210 double scaleFactor = 0.9998;
211 double centralMeridian = 0.41887902047863912;
212 double latOrigin = 0.0;
213 double falseNorthing = 0.0;
214 double falseEasting = 500000.0;
215 double semiMajor = 6378137.0;
216 double semiMinor = 6356752.3141403561;
217 double metersPerUnit = 1.0;
219 double e0, e1, e2, e3;
223 es = 1.0 - pow(semiMinor / semiMajor, 2);
228 ml0 = semiMajor *
mlfn(e0, e1, e2, e3, latOrigin);
229 esp = es / (1.0 - es);
233 double lon = lonlat[0] *
DEG2RAD;
234 double lat = lonlat[1] *
DEG2RAD;
236 double delta_lon = 0.0;
237 double sin_phi, cos_phi;
245 al = cos_phi * delta_lon;
250 con = 1.0 - es * pow(sin_phi, 2);
251 n = semiMajor / sqrt(con);
252 ml = semiMajor *
mlfn(e0, e1, e2, e3, lat);
254 double x = scaleFactor * n * al * (1.0 + als / 6.0 * (1.0 - t + c + als / 20.0 *
255 (5.0 - 18.0 * t + pow(t, 2) + 72.0 * c - 58.0 * esp))) + falseEasting;
257 double y = scaleFactor * (ml - ml0 + n * tq * (als * (0.5 + als / 24.0 *
258 (5.0 - t + 9.0 * c + 4.0 * pow(c, 2) + als / 30.0 * (61.0 - 58.0 * t
259 + pow(t, 2) + 600.0 * c - 330.0 * esp))))) + falseNorthing;
261 if(lonlat.count() < 3)
263 QVector <double> ret(2);
264 ret[0]= x / metersPerUnit;
265 ret[1]= y / metersPerUnit;
270 QVector <double> ret(3);
271 ret[0]= x / metersPerUnit;
272 ret[1]= y / metersPerUnit;
278 QVector <double> LKS94Projection::DTM01(QVector <double>& lonlat)
281 double semiMajor = 6378137.0;
282 double semiMinor = 6356752.3141403561;
284 es = 1.0 - (semiMinor * semiMinor) / (semiMajor * semiMajor);
288 double lon = lonlat[0] *
DEG2RAD;
289 double lat = lonlat[1] *
DEG2RAD;
290 double h = lonlat.count() < 3 ? 0 : std::isnan(lonlat[2]) ? 0 : lonlat[2];
291 double v = semiMajor / sqrt(1 - es * pow(sin(lat), 2));
292 double x = (v +
h) * cos(lat) * cos(lon);
293 double y = (v +
h) * cos(lat) * sin(lon);
294 double z = ((1 - es) * v + h) * sin(lat);
295 QVector <double> ret(3);
301 QVector <double> LKS94Projection::MTD01(QVector <double>& pnt)
303 const double COS_67P5 = 0.38268343236508977;
304 const double AD_C = 1.0026000;
307 double semiMajor = 6378137.0;
308 double semiMinor = 6356752.3142451793;
311 es = 1.0 - (semiMinor * semiMinor) / (semiMajor * semiMajor);
312 ses = (pow(semiMajor, 2) - pow(semiMinor, 2)) / pow(semiMinor, 2);
316 bool At_Pole =
false;
317 double Z = pnt.count() < 3 ? 0 : std::isnan(pnt[2]) ? 0 : pnt[2];
324 lon = atan2(pnt[1], pnt[0]);
352 QVector<double> ret(3);
361 double W2 = pnt[0] * pnt[0] + pnt[1] * pnt[1];
363 double T0 = Z * AD_C;
364 double S0 = sqrt(T0 * T0 + W2);
365 double Sin_B0 = T0 / S0;
366 double Cos_B0 = W / S0;
367 double Sin3_B0 = pow(Sin_B0, 3);
368 double T1 = Z + semiMinor * ses * Sin3_B0;
369 double Sum = W - semiMajor * es * Cos_B0 * Cos_B0 * Cos_B0;
370 double S1 = sqrt(T1 * T1 + Sum * Sum);
371 double Sin_p1 = T1 / S1;
372 double Cos_p1 = Sum / S1;
373 double Rn = semiMajor / sqrt(1.0 - es * Sin_p1 * Sin_p1);
375 if(Cos_p1 >= COS_67P5)
377 Height = W / Cos_p1 - Rn;
380 if(Cos_p1 <= -COS_67P5)
382 Height = W / -Cos_p1 - Rn;
386 Height = Z / Sin_p1 + Rn * (es - 1.0);
391 lat = atan(Sin_p1 / Cos_p1);
393 QVector<double> ret(3);
399 QVector <double> LKS94Projection::MTD11(QVector <double>& p)
401 double scaleFactor = 0.9998;
402 double centralMeridian = 0.41887902047863912;
403 double latOrigin = 0.0;
404 double falseNorthing = 0.0;
405 double falseEasting = 500000.0;
406 double semiMajor = 6378137.0;
407 double semiMinor = 6356752.3141403561;
408 double metersPerUnit = 1.0;
410 double e0, e1, e2, e3;
414 es =(semiMinor * semiMinor) / (semiMajor * semiMajor);
420 ml0 = semiMajor *
mlfn(e0, e1, e2, e3, latOrigin);
421 esp = es / (1.0 - es);
428 double sin_phi, cos_phi, tan_phi;
429 double c, cs,
t, ts,
n, r, d, ds;
430 qlonglong max_iter = 6;
432 double x = p[0] * metersPerUnit - falseEasting;
433 double y = p[1] * metersPerUnit - falseNorthing;
435 con = (ml0 + y / scaleFactor) / semiMajor;
439 delta_phi = ((con + e1 * sin(2.0 * phi) - e2 * sin(4.0 * phi) + e3 * sin(6.0 * phi)) / e0) - phi;
441 if(fabs(delta_phi) <=
EPSLoN)
445 throw "Latitude failed to converge";
450 SinCos(phi, sin_phi, cos_phi);
452 c = esp * pow(cos_phi, 2);
456 con = 1.0 - es * pow(sin_phi, 2);
457 n = semiMajor / sqrt(con);
458 r = n * (1.0 - es) / con;
459 d = x / (n * scaleFactor);
462 double lat = phi - (n * tan_phi * ds / r) * (0.5 - ds / 24.0 * (5.0 + 3.0 * t +
463 10.0 * c - 4.0 * cs - 9.0 * esp - ds / 30.0 * (61.0 + 90.0 * t +
464 298.0 * c + 45.0 * ts - 252.0 * esp - 3.0 * cs)));
466 double lon =
AdjustLongitude(centralMeridian + (d * (1.0 - ds / 6.0 * (1.0 + 2.0 * t +
467 c - ds / 20.0 * (5.0 - 2.0 * c + 28.0 * t - 3.0 * cs + 8.0 * esp +
468 24.0 * ts))) / cos_phi));
472 QVector<double> ret(2);
479 QVector<double> ret(3);
490 QVector<double> ret(2);
492 ret[1] = centralMeridian *
RAD2DEG;
498 QVector<double> ret(3);
500 ret[1] = centralMeridian *
RAD2DEG;
516 ret = 1587.50317500635;
522 ret = 793.751587503175;
528 ret = 529.167725002117;
534 ret = 264.583862501058;
540 ret = 132.291931250529;
546 ret = 52.9167725002117;
552 ret = 26.4583862501058;
558 ret = 13.2291931250529;
564 ret = 6.61459656252646;
570 ret = 2.64583862501058;
576 ret = 1.32291931250529;
582 ret = 0.529167725002117;
631 ret = Size(149, 103);
637 ret = Size(374, 259);
643 ret = Size(749, 519);
649 ret = Size(1594, 1100);
655 ret = Size(3188, 2201);
661 ret = Size(7971, 5502);
667 ret = Size(15943, 11005);
673 ret = Size(39858, 27514);
713 ret = Size(181, 125);
719 ret = Size(454, 311);
725 ret = Size(903, 623);
731 ret = Size(1718, 1193);
737 ret = Size(3437, 2386);
743 ret = Size(8594, 5966);
749 ret = Size(17189, 11932);
755 ret = Size(42972, 29831);