본문으로 바로가기
//도분초를 위경도로 바꾸기
function DMStoDEC($deg,$min,$sec){
return $deg+((($min*60)+($sec))/3600);
}

//위경도를 도분초로 바꾸기
function DECtoDMS($dec , $type){
// Converts decimal longitude / latitude to DMS

	$vars = explode(".",$dec);
	$deg = $vars[0];
	$tempma = "0.".$vars[1];
		
	$tempma = $tempma * 3600;
	$min = floor($tempma / 60);
	$sec = $tempma - ($min*60);

	if($type=="lat"){
		if($deg<0) $dir="S";
		else $dir="N";
	}else{
		if($deg<0) $dir="W";
		else $dir="E";
	}

	return abs($deg)." ".$min."' ".round($sec)."''".$dir;
}