source: trunk/src/dms2dd.pro @ 2

Last change on this file since 2 was 2, checked in by pinsard, 14 years ago

first commit with original work of Marina Levy and Francoise Pinsard

  • Property svn:keywords set to Id
File size: 2.8 KB
Line 
1;+
2;
3; ==========
4; dms2dd.pro
5; ==========
6;
7; .. function:: dms2dd(degree,minute,second)
8;
9;    Calculate the decimal degree for a given degree minute and second
10;
11;    :param degree: degree
12;    :type degree: integer
13;    :raise degree: required
14;
15;    :param minute: minute
16;    :type minute: integer
17;    :raise minute: required
18;
19;    :param second: second
20;    :type second: integer
21;    :raise second: required
22;
23;    :returns: decimal degree or -1 if error in parameters type or dimension
24;    :rtype: double
25;
26; :examples:
27;
28; ::
29;
30;   IDL> degree=45
31;   IDL> minute=30
32;   IDL> second=30
33;   IDL> dd=dms2dd(degree,minute,second)
34;   IDL> print,dd
35;   45.5083
36;
37; :uses:
38;
39; :func:`report`
40;
41; :see also:
42;
43; http://www.csgnetwork.com/gpscoordconv.html
44;
45; :todo:
46;
47;  authorize arrays in inputs (like :func:`julday`)
48;
49; :history:
50;
51; - fplod 20101124T140937Z aedon.locean-ipsl.upmc.fr (Darwin)
52;
53;   * returned value type from float to double
54;   * Double constants in conversion
55;
56; - fplod 20101124T120209Z aedon.locean-ipsl.upmc.fr (Darwin)
57;
58;   * apply http://sphinx.pocoo.org/domains.html Info field lists
59;     to have a nicer parameters documentation
60;
61; - fplod 20101122T094140Z aedon.locean-ipsl.upmc.fr (Darwin)
62;
63;   * creation
64;
65; :version:
66;
67; $Id$
68;
69;-
70FUNCTION DMS2DD, degree, minute, second
71
72compile_opt idl2, strictarrsubs
73
74; Return to caller if errors
75ON_ERROR, 2
76
77usage = 'result=dms2dss(degree, minute, second)'
78
79; check parameters
80nparam = N_PARAMS()
81IF (nparam LT 3) THEN BEGIN
82   ras = report(['Incorrect number of arguments.' $
83         + '!C' $
84         + 'Usage : ' + usage])
85   return, -1
86ENDIF
87
88arg_type = size(degree,/type)
89IF ((arg_type NE 2) AND (arg_type NE 3)) THEN BEGIN
90   ras = report(['Incorrect arg type degree' $
91         + '!C' $
92         + 'Usage : ' + usage])
93   return, -1
94ENDIF
95
96arg_dim =  size(degree,/n_elements)
97IF (arg_dim GT 1) THEN BEGIN
98   ras = report(['Incorrect arg dimension degree' $
99         + '!C' $
100         + 'Usage : ' + usage])
101   return, -1
102ENDIF
103
104arg_type = size(minute,/type)
105IF ((arg_type NE 2) AND (arg_type NE 3)) THEN BEGIN
106   ras = report(['Incorrect arg type minute' $
107         + '!C' $
108         + 'Usage : ' + usage])
109   return, -1
110ENDIF
111
112arg_dim =  size(minute,/n_elements)
113IF (arg_dim GT 1) THEN BEGIN
114   ras = report(['Incorrect arg dimension minute' $
115         + '!C' $
116         + 'Usage : ' + usage])
117   return, -1
118ENDIF
119
120arg_type = size(second,/type)
121IF ((arg_type NE 2) AND (arg_type NE 3)) THEN BEGIN
122   ras = report(['Incorrect arg type second' $
123         + '!C' $
124         + 'Usage : ' + usage])
125   return, -1
126ENDIF
127
128arg_dim =  size(second,/n_elements)
129IF (arg_dim GT 1) THEN BEGIN
130   ras = report(['Incorrect arg dimension second' $
131         + '!C' $
132         + 'Usage : ' + usage])
133   return, -1
134ENDIF
135
136; conversion
137dd = degree + float(minute/60.d) + (second/60.d)/60.d
138
139return,dd
140
141END
Note: See TracBrowser for help on using the repository browser.