????JFIF??x?x????'
| Server IP : 79.136.114.73 / Your IP : 216.73.217.114 Web Server : Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.29 OpenSSL/1.0.1f System : Linux b8009 3.13.0-170-generic #220-Ubuntu SMP Thu May 9 12:40:49 UTC 2019 x86_64 User : www-data ( 33) PHP Version : 5.5.9-1ubuntu4.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/www.supervision-online.se/login/scripts/ |
Upload File : |
<?php
function grid_to_geodetic($x, $y, $central_meridian) {
$lat_lon[] = 2;
$axis = 6378137.0; // GRS 80.
$flattening = 1.0 / 298.257222101; // GRS 80.
$lat_of_origin = 0.0;
$scale = 1.0;
$false_northing = 0.0;
$false_easting = 150000.0;
// Prepare ellipsoid-based stuff.
$e2 = $flattening * (2.0 - $flattening);
$n = $flattening / (2.0 - $flattening);
$a_roof = $axis / (1.0 + $n) * (1.0 + $n*$n/4.0 + $n*$n*$n*$n/64.0);
$delta1 = $n/2.0 - 2.0*$n*$n/3.0 + 37.0*$n*$n*$n/96.0 - $n*$n*$n*$n/360.0;
$delta2 = $n*$n/48.0 + $n*$n*$n/15.0 - 437.0*$n*$n*$n*$n/1440.0;
$delta3 = 17.0*$n*$n*$n/480.0 - 37*$n*$n*$n*$n/840.0;
$delta4 = 4397.0*$n*$n*$n*$n/161280.0;
$Astar = $e2 + $e2*$e2 + $e2*$e2*$e2 + $e2*$e2*$e2*$e2;
$Bstar = -(7.0*$e2*$e2 + 17.0*$e2*$e2*$e2 + 30.0*$e2*$e2*$e2*$e2) / 6.0;
$Cstar = (224.0*$e2*$e2*$e2 + 889.0*$e2*$e2*$e2*$e2) / 120.0;
$Dstar = -(4279.0*$e2*$e2*$e2*$e2) / 1260.0;
// Convert.
$deg_to_rad = M_PI / 180;
$lambda_zero = $central_meridian * $deg_to_rad;
$xi = ($x - $false_northing) / ($scale * $a_roof);
$eta = ($y - $false_easting) / ($scale * $a_roof);
$xi_prim = $xi -
$delta1*sin(2.0*$xi) * cosh(2.0*$eta) -
$delta2*sin(4.0*$xi) * cosh(4.0*$eta) -
$delta3*sin(6.0*$xi) * cosh(6.0*$eta) -
$delta4*sin(8.0*$xi) * cosh(8.0*$eta);
$eta_prim = $eta -
$delta1*cos(2.0*$xi) * sinh(2.0*$eta) -
$delta2*cos(4.0*$xi) * sinh(4.0*$eta) -
$delta3*cos(6.0*$xi) * sinh(6.0*$eta) -
$delta4*cos(8.0*$xi) * sinh(8.0*$eta);
$phi_star = asin(sin($xi_prim) / cosh($eta_prim));
$delta_lambda = atan(sinh($eta_prim) / cos($xi_prim));
$lon_radian = $lambda_zero + $delta_lambda;
$lat_radian = $phi_star + sin($phi_star) * cos($phi_star) *
($Astar +
$Bstar*pow(sin($phi_star), 2) +
$Cstar*pow(sin($phi_star), 4) +
$Dstar*pow(sin($phi_star), 6));
$lat_lon[0] = $lat_radian * 180.0 / M_PI;
$lat_lon[1] = $lon_radian * 180.0 / M_PI;
//echo($lat_lon[0].",". $lat_lon[1]);
return $lat_lon;
}
function geodetic_to_grid($latitude,$longitude,$central_meridian) {
$lat_lon[] = 2;
$axis = 6378137.0; // GRS 80.
$flattening = 1.0 / 298.257222101; // GRS 80.
$lat_of_origin = 0.0;
$scale = 1.0;
$false_northing = 0.0;
$false_easting = 150000.0;
# Prepare ellipsoid-based stuff.
$e2 = $flattening * (2.0 - $flattening);
$n = $flattening / (2.0 - $flattening);
$a_roof = $axis / (1.0 + $n) * (1.0 + $n*$n/4.0 + $n*$n*$n*$n/64.0);
$A = $e2;
$B = (5.0*$e2*$e2 - $e2*$e2*$e2) / 6.0;
$C = (104.0*$e2*$e2*$e2 - 45.0*$e2*$e2*$e2*$e2) / 120.0;
$D = (1237.0*$e2*$e2*$e2*$e2) / 1260.0;
$beta1 = $n/2.0 - 2.0*$n*$n/3.0 + 5.0*$n*$n*$n/16.0 + 41.0*$n*$n*$n*$n/180.0;
$beta2 = 13.0*$n*$n/48.0 - 3.0*$n*$n*$n/5.0 + 557.0*$n*$n*$n*$n/1440.0;
$beta3 = 61.0*$n*$n*$n/240.0 - 103.0*$n*$n*$n*$n/140.0;
$beta4 = 49561.0*$n*$n*$n*$n/161280.0;
# Convert.
$deg_to_rad = M_PI / 180.0;
$phi = $latitude * $deg_to_rad;
$lambda = $longitude * $deg_to_rad;
$lambda_zero = $central_meridian * $deg_to_rad;
$phi_star = $phi - sin($phi) * cos($phi) * ($A +
$B * pow(sin($phi), 2) +
$C * pow(sin($phi), 4) +
$D * pow(sin($phi), 6));
$delta_lambda = $lambda - $lambda_zero;
$xi_prim = atan(tan($phi_star) / cos($delta_lambda));
$eta_prim = atanh(cos($phi_star) * sin($delta_lambda));
$x = $scale * $a_roof * ($xi_prim +
$beta1 * sin(2.0*$xi_prim) * cosh(2.0*$eta_prim) +
$beta2 * sin(4.0*$xi_prim) * cosh(4.0*$eta_prim) +
$beta3 * sin(6.0*$xi_prim) * cosh(6.0*$eta_prim) +
$beta4 * sin(8.0*$xi_prim) * cosh(8.0*$eta_prim)) +
$false_northing;
$y = $scale * $a_roof * ($eta_prim +
$beta1 * cos(2.0*$xi_prim) * sinh(2.0*$eta_prim) +
$beta2 * cos(4.0*$xi_prim) * sinh(4.0*$eta_prim) +
$beta3 * cos(6.0*$xi_prim) * sinh(6.0*$eta_prim) +
$beta4 * cos(8.0*$xi_prim) * sinh(8.0*$eta_prim)) +
$false_easting;
//$x = ($x * 1000.0) / 1000.0;
//$y = ($y * 1000.0) / 1000.0;
$lat_lon[0] = $x;
$lat_lon[1] = $y;
return $lat_lon;
}
$link = mysql_connect ("localhost", "root", "root123");
mysql_select_db ("supervision");
$sql = "SELECT * FROM tblPositions";
$result1 = mysql_query($sql);
while ($row = mysql_fetch_assoc($result1)){
$arr = grid_to_geodetic($row['pos_lat'],$row['pos_long'],15);
$sql = "update tblPositions set pos_lat = '".$arr[0]."', pos_long = '".$arr[1]."' where id = " .$row['id'];
echo($sql."<br>");
}
?>