Advertisement
Guest User

sjtsk2wgs84

a guest
Oct 11th, 2013
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.27 KB | None | 0 0
  1.   protected function _sjtsk2wgs84($xx, $yy, $hh)
  2.   {
  3.     # vstup X a Y souřadnice v S-JTKS a nadmořská výška
  4.    # vystupem jsou souradnice WGS84, tedy longitude a latitude a upravena nadmořská výška
  5.    
  6.     # nadmorska vyska
  7.    $hh += 45;    
  8.    
  9.     # Vypocet zemepisnych souradnic z rovinnych souradnic
  10.    $a = 6377397.15508;
  11.     $e = 0.081696831215303;
  12.     $n = 0.97992470462083;
  13.     $konst_u_ro = 12310230.12797036;
  14.     $sinUQ = 0.863499969506341;
  15.     $cosUQ = 0.504348889819882;
  16.     $sinVQ = 0.420215144586493;
  17.     $cosVQ = 0.907424504992097;
  18.     $alfa = 1.000597498371542;
  19.     $k = 1.003419163966575;
  20.     $ro = sqrt($xx*$xx + $yy*$yy);
  21.     $epsilon = 2*atan($yy/($ro+$xx));
  22.     $D = $epsilon/$n;
  23.     $S = 2*atan(exp(1/$n*log($konst_u_ro/$ro)))-1*(M_PI)/2;
  24.     $sinS = sin($S);
  25.     $cosS = cos($S);
  26.     $sinU = $sinUQ*$sinS-$cosUQ*$cosS*cos($D);
  27.     $cosU = sqrt(1-$sinU*$sinU);
  28.     $sinDV = sin($D)*$cosS/$cosU;
  29.     $cosDV = sqrt(1-$sinDV*$sinDV);
  30.     $sinV = $sinVQ*$cosDV-$cosVQ*$sinDV;
  31.     $cosV = $cosVQ*$cosDV+$sinVQ*$sinDV;
  32.     $Ljtsk = 2*atan($sinV/(1+$cosV))/$alfa;
  33.     $t = exp(2/$alfa*log((1+$sinU)/$cosU/$k));
  34.     $pom = ($t-1)/($t+1);
  35.  
  36.     $sinB = '';
  37.  
  38.     while (abs($pom-$sinB)>1E-15)
  39.     {
  40.       $sinB = $pom;
  41.       $pom = $t*exp($e*log((1+$e*$sinB)/(1-$e*$sinB)));
  42.       $pom = ($pom-1)/($pom+1);
  43.     }
  44.     $Bjtsk = atan($pom/sqrt(1-$pom*$pom));
  45.     # Pravoúhlé souřadnice ve S-JTSK    
  46.    $a = 6377397.15508;
  47.     $f_1 = 299.152812853;
  48.     $e2 = 1-(1-1/$f_1)*(1-1/$f_1);
  49.     $ro = $a/sqrt(1-$e2*sin($Bjtsk)*sin($Bjtsk));
  50.     $x = ($ro+$hh)*cos($Bjtsk)*cos($Ljtsk);
  51.     $y = ($ro+$hh)*cos($Bjtsk)*sin($Ljtsk);
  52.     $z = ((1-$e2)*$ro+$hh)*sin($Bjtsk);
  53.  
  54.     # Pravoúhlé souřadnice v WGS-84
  55.    $dx = 570.69;
  56.     $dy = 85.69;
  57.     $dz = 462.84;
  58.     $wz = -5.2611/3600*M_PI/180;
  59.     $wy = -1.58676/3600*M_PI/180;
  60.     $wx = -4.99821/3600*M_PI/180;
  61.     $m = 3.543e-6;
  62.     $xn = $dx+(1+$m)*($x+$wz*$y-$wy*$z);
  63.     $yn = $dy+(1+$m)*(-$wz*$x+$y+$wx*$z);
  64.     $zn = $dz+(1+$m)*($wy*$x-$wx*$y+$z);
  65.  
  66.     # Geodetické souřadnice v systému WGS-84
  67.    $a = 6378137.0;
  68.     $f_1 = 298.257223563;
  69.     $a_b = $f_1/($f_1-1);
  70.     $p = sqrt($xn*$xn+$yn*$yn);
  71.     $e2 = 1-(1-1/$f_1)*(1-1/$f_1);
  72.     $theta = atan($zn*$a_b/$p);
  73.     $st = sin($theta);
  74.     $ct = cos($theta);
  75.     $t = ($zn+$e2*$a_b*$a*$st*$st*$st)/($p-$e2*$a*$ct*$ct*$ct);
  76.     $B = atan($t);
  77.     $L = 2*atan($yn/($p+$xn));
  78.     $H = sqrt(1+$t*$t)*($p-$a/sqrt(1+(1-$e2)*$t*$t));
  79.     # Formát výstupních hodnot  
  80.    $B = $B/M_PI*180;
  81.     $sirka = "N";
  82.     if ($B<0) { $B = -$B; $sirka = "S"; };
  83.     $stsirky = floor($B);
  84.     $B = ($B-$stsirky)*60;
  85.     $minsirky = floor($B);
  86.     $B = ($B-$minsirky)*60;
  87.     $vtsirky = round($B*1000)/1000;
  88.     $sirka = $sirka . $stsirky . "°" . $minsirky . "'" . $vtsirky;
  89.     $L = $L/M_PI*180;
  90.     $delka = "E";
  91.     if ($L<0) { $L = -$L; $delka = "W"; };
  92.     $stdelky = floor($L);
  93.     $L = ($L-$stdelky)*60;
  94.     $mindelky = floor($L);
  95.     $L = ($L-$mindelky)*60;
  96.     $vtdelky = round($L*1000)/1000;
  97.     $delka = $delka . $stdelky . "°" . $mindelky . "'" . $vtdelky;
  98.     $vyska = round(($H-45)*100)/100;
  99.     $vyska .= " m";
  100.  
  101.     # vratime vysledek, nejlepe asi jako pole tri stringu
  102.  
  103.     return array($sirka,$delka,$vyska);
  104.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement