degree2decimal

By | June 18, 2013
Selec All Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
DROP FUNCTION IF EXISTS `degree2decimal`;
 
CREATE DEFINER = `root`@`localhost` FUNCTION `degree2decimal`(deg_coord FLOAT) 
 RETURNS FLOAT
BEGIN
	#converts NMEA/GPS Lat -Long TO DECIMAL Degrees. Code comments are SELF explanatory. 
        #The code IS NOT graceful, but it works.
	DECLARE degree INT;
	DECLARE minutes2 FLOAT;
	DECLARE dotdegree FLOAT;
	DECLARE decimal2 FLOAT;
 
	SET degree= (deg_coord/100);
	SET minutes2 = deg_coord-(degree*100);
	SET dotdegree=minutes2/60;
	SET decimal2=degree+dotdegree;
 
	RETURN decimal2;
END;