Newer
Older
function string = dd2dm( posit, latlon )
% STRING = DD2DM( posit, latlon )
% Convertit une position decimale en chaine de caractere
%
% string chaine de caracteres
% posit en degres decimaux
% latlon 0 pour la latitude - 1 pour la longitude
%
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
% representation ASCII du caractere degre
% pour assurer la comptatibilite windows/linux (ISO8859/UTF8)
degre = 176;
% Determine si latitude ou longitude
% ----------------------------------
if latlon == 1
neg = 'W';
pos = 'E';
else
neg = 'S';
pos = 'N';
end
% Cree les labels
% ---------------
if posit < 0
geo = neg;
else
geo = pos;
end
% Conversion et formattage
% on n'affiche pas les decimales pour les minutes
% car la precision n'est pas suffisante (currentpoint)
% ---------------------------------------------
% posit
h = fix( posit );
m = (posit - h ) * 60;
if abs(m) > 59
if posit > 0
h = h+1;
else
h = h-1;
end
m = 0;
end
string = sprintf( '%02d%c%06.3f %c', abs(h), degre, abs(m), geo );