Ukázka převodu WGS (zažitý zápis zeměpisné šířky a zeměpisné délky) na Decimal Degrees pomoci PHP.


function WGStoDD($x, $y) {
   //Decimal Degrees = Degrees + minutes/60 + seconds/3600
      $x1 = explode("°", $x);
      $y1 = explode("°", $y);
      $x2 = explode("'", $x1[1]);
      $y2 = explode("'", $y1[1]);
      $x3 = explode('"', $x2[1]);
      $y3 = explode('"', $y2[1]);
      if($x3[1] == "S") { $lat = "-"; } else { $lat = "+"; }
      if($y3[1] == "W") { $lon = "-"; } else { $lon = "+"; }
      $allx = $x1[0] +$x2[0]/60 +$x3[0]/3600;
      $ally = $y1[0] +$y2[0]/60 +$y3[0]/3600;
      return ($lat .$allx ."/" .$lon .$ally);
}

function DDtoWGS($x, $y) {
   $x1 = explode(".", $x); //$x1[0] = hodiny
   $y1 = explode(".", $y); //$y1[0] = hodiny
   if($x1[0] < 0) { $lat = "S"; } else { $lat = "N"; }
   if($y1[0] < 0) { $lon = "W"; } else { $lon = "E"; }
   $x2 = "0." .$x1[1] * 60;
   $y2 = "0." .$y1[1] * 60;
   $x3 = explode(".", $x2); //$x3[0] = minuty
   $y3 = explode(".", $y2); //$y3[0] = minuty
   $x4 = "0." .$x3[1] * 60;
   $x4 = "0." .$x3[1] * 60;
   $x5 = explode(".", $x4); //$x5[0] = sekundy
   $y5 = explode(".", $y4); //$y5[0] = sekundy
   return ($x1[0] ."°" .$x3[1] ."'" .$x5[1] .'"' .$lat .'/' .$y1[0] ."°" .$y3[1] ."'" .$y5[1] .'"' .$lon);
}


$obs[zemepisna_sirka] = "48°58'28.276\"N";
$obs[zemepisna_delka] = "14°28'27.926\"E";
   
$vysl = explode ('/', DDtoWGS ($obs[zemepisna_sirka], $obs[zemepisna_delka]));
$vysl2 = explode ('/', WGStoDD ($vysl[0], $vysl[1]));;
      
echo '\nVstup: ' .trim($obs[zemepisna_sirka]) .', ' .trim($obs[zemepisna_delka]);
echo '\nVystup_WGS: ' .$vysl[0] .', ' .$vysl[1];
echo '\nPrevod zpet: ' .$vysl2[0] .', ' .$vysl2[1] .'\n';