2018-03-30 10:04:14 +00:00
|
|
|
function dmsOutput = deg2dms(deg)
|
|
|
|
% DEG2DMS Conversion of degrees to degrees, minutes, and seconds.
|
|
|
|
% The output format (dms format) is: (degrees*100 + minutes + seconds/100)
|
|
|
|
|
2020-02-08 00:20:02 +00:00
|
|
|
% Copyright (C) Kai Borre
|
2018-03-30 10:04:14 +00:00
|
|
|
% February 7, 2001
|
|
|
|
% Updated by Darius Plausinaitis
|
2020-02-08 00:20:02 +00:00
|
|
|
% GNSS-SDR is a software defined Global Navigation
|
|
|
|
% Satellite Systems receiver
|
|
|
|
%
|
|
|
|
% This file is part of GNSS-SDR.
|
|
|
|
%
|
|
|
|
% SPDX-License-Identifier: GPL-3.0-or-later
|
2018-03-30 10:04:14 +00:00
|
|
|
|
|
|
|
%%% Save the sign for later processing
|
|
|
|
neg_arg = false;
|
|
|
|
if deg < 0
|
2018-04-03 17:15:25 +00:00
|
|
|
% Only positive numbers should be used while splitting into deg/min/sec
|
2018-03-30 10:04:14 +00:00
|
|
|
deg = -deg;
|
|
|
|
neg_arg = true;
|
|
|
|
end
|
|
|
|
|
|
|
|
%%% Split degrees minutes and seconds
|
|
|
|
int_deg = floor(deg);
|
|
|
|
decimal = deg - int_deg;
|
|
|
|
min_part = decimal*60;
|
|
|
|
min = floor(min_part);
|
|
|
|
sec_part = min_part - floor(min_part);
|
|
|
|
sec = sec_part*60;
|
|
|
|
|
|
|
|
%%% Check for overflow
|
|
|
|
if sec == 60
|
|
|
|
min = min + 1;
|
|
|
|
sec = 0;
|
|
|
|
end
|
|
|
|
if min == 60
|
|
|
|
int_deg = int_deg + 1;
|
|
|
|
min = 0;
|
|
|
|
end
|
|
|
|
|
|
|
|
%%% Construct the output
|
|
|
|
dmsOutput = int_deg * 100 + min + sec/100;
|
|
|
|
|
|
|
|
%%% Correct the sign
|
|
|
|
if neg_arg == true
|
|
|
|
dmsOutput = -dmsOutput;
|
|
|
|
end
|
|
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%% end deg2dms.m %%%%%%%%%%%%%%%%
|