+Geofellas Posted September 8, 2008 Share Posted September 8, 2008 I am not that familiar with the format strings used by the string.format function - I have currently created a rather unsatisfactory (yet working) bit of code to format the minutes part of a coordinate in the way we are used to - i.e. 00.000 (rounded to 3 decimal places with leading and trailing zeroes included) Here is the code that formats the entire latitude portion as currently implemented: local l = math.abs(lat) local deg = math.floor(l) local min = 60*(l - deg) local minint = math.floor(min) local mindec = min-minint+ 0.0005 if lat < 0 then cout = "S " else cout = "N " end cout = cout .. string.format("%2i",deg) .. [[ ]] .. string.format("%.2d",minint) .. [[.]] .. string.format("%.3i", mindec*1000) I would be grateful for any suggestions for improvement as this seems rather inelegant Thanks Quote Link to comment
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.