Created
October 14, 2023 19:17
-
-
Save technetium/f8080a27917955ad686906dc6ddee7d4 to your computer and use it in GitHub Desktop.
MySql function to convert decimal degrees to Half, Decimal and Minutes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE FUNCTION D_TO_HDM(value FLOAT, halfs TEXT) | |
RETURNS TEXT | |
RETURN CONCAT( | |
IF(value > 0, LEFT(halfs, 1), RIGHT(halfs, 1)), FLOOR(ABS(value+1/120000)) , ' ' | |
, LPAD(FLOOR((ABS(value+1/120000)-FLOOR(ABS(value+1/120000)))*60), 2, "0") , '.' | |
, LPAD(ROUND((ABS(value+1/120000)*60-FLOOR(ABS(value+1/120000)*60))*1000), 3, "0") | |
) | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment