news 2020-09-19 08-58-13
QTH locator - PHP script (with error)
<?php
function qth_loc($dec_lat,$dec_lon){
$upper = "ABCDEFGHIJKLMNOPQRSTUVWX";
$lower = "abcdefghijklmnopqrstuvwx";
$adj_lat = $dec_lat + 90.0;
$adj_lon = $dec_lon + 180.0;
$grid_lat_sq = substr($upper,round(($adj_lat/10),0),1);
$grid_lon_sq = substr($upper,round(($adj_lon/20),0),1);
$grid_lat_field =$adj_lat%10;
$grid_lon_field =($adj_lon/2)%10;
$adj_lat_remainder = ($adj_lat - round($adj_lat,0)) * 60;
$adj_lon_remainder = ($adj_lon - round(($adj_lon/2),0)*2) * 60;
$grid_lat_subsq = substr($lower,round(($adj_lat_remainder/2.5),0),1);
$grid_lon_subsq = substr($lower,round(($adj_lon_remainder/5),0),1);
return $grid_lon_sq.$grid_lat_sq.$grid_lon_field.$grid_lat_field.$grid_lon_subsq.$grid_lat_subsq."n";
}
// Пример вызова
echo qth_loc(50.5479349,30.2019914);
2021-10-27_08-58-49