;+ ; ; ========== ; dms2dd.pro ; ========== ; ; .. function:: dms2dd(degree,minute,second) ; ; Calculate the decimal degree for a given degree minute and second ; ; :param degree: degree ; :type degree: integer ; :raise degree: required ; ; :param minute: minute ; :type minute: integer ; :raise minute: required ; ; :param second: second ; :type second: integer ; :raise second: required ; ; :returns: decimal degree or -1 if error in parameters type or dimension ; :rtype: double ; ; :examples: ; ; .. code-block:: idl ; ; degree = 45 ; minute = 30 ; second = 30 ; dd = dms2dd(degree,minute,second) ; print,dd ; ; .. parsed-literal:: ; ; 45.5083 ; ; :uses: ; ; :func:`report ` ; ; :see also: ; ; http://www.csgnetwork.com/gpscoordconv.html ; ; :todo: ; ; authorize arrays in inputs (like :func:`julday `) ; ; :history: ; ; - fplod 20101124T140937Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * returned value type from float to double ; * Double constants in conversion ; ; - fplod 20101124T120209Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * apply http://sphinx.pocoo.org/domains.html Info field lists ; to have a nicer parameters documentation ; ; - fplod 20101122T094140Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * creation ; ; :version: ; ; $Id$ ; ;- FUNCTION DMS2DD, degree, minute, second compile_opt idl2, strictarrsubs ; Return to caller if errors ON_ERROR, 2 usage = 'result = dms2dss(degree, minute, second)' ; check parameters nparam = N_PARAMS() IF (nparam LT 3) THEN BEGIN ras = report(['Incorrect number of arguments.' $ + '!C' $ + 'Usage : ' + usage]) return, -1 ENDIF arg_type = size(degree,/type) IF ((arg_type NE 2) AND (arg_type NE 3)) THEN BEGIN ras = report(['Incorrect arg type degree' $ + '!C' $ + 'Usage : ' + usage]) return, -1 ENDIF arg_dim = size(degree,/n_elements) IF (arg_dim GT 1) THEN BEGIN ras = report(['Incorrect arg dimension degree' $ + '!C' $ + 'Usage : ' + usage]) return, -1 ENDIF arg_type = size(minute,/type) IF ((arg_type NE 2) AND (arg_type NE 3)) THEN BEGIN ras = report(['Incorrect arg type minute' $ + '!C' $ + 'Usage : ' + usage]) return, -1 ENDIF arg_dim = size(minute,/n_elements) IF (arg_dim GT 1) THEN BEGIN ras = report(['Incorrect arg dimension minute' $ + '!C' $ + 'Usage : ' + usage]) return, -1 ENDIF arg_type = size(second,/type) IF ((arg_type NE 2) AND (arg_type NE 3)) THEN BEGIN ras = report(['Incorrect arg type second' $ + '!C' $ + 'Usage : ' + usage]) return, -1 ENDIF arg_dim = size(second,/n_elements) IF (arg_dim GT 1) THEN BEGIN ras = report(['Incorrect arg dimension second' $ + '!C' $ + 'Usage : ' + usage]) return, -1 ENDIF ; conversion dd = degree + float(minute/60.d) + (second/60.d)/60.d return, dd END