Convert Lat/Long to degrees

I'm looking for a function to convert Lat / Long to degrees and minutes.

lon   -122.1284680368919
lat   37.76387287100824


 37°45'52.72"N
122° 7'46.53"W

anybody got something like this?

Thanks.

NG,
LVL 13
nike_golfAsked:
Who is Participating?
 
GrahamSkanConnect With a Mentor RetiredCommented:
That seems to have missed the Function and End Function
Function DMS(dblDegrees As Double, bLatitude As Boolean) As String
    Dim dda As Double
    Dim d As Integer
    Dim m As Integer
    Dim s As Double
    Dim r As Double
    Dim strLon As String
    Dim sign As Integer
    
    sign = Sgn(dblDegrees)
    dda = Abs(dblDegrees)
    d = Int(Abs(dda))
    r = (dda - d) * 60
    m = Int(r)
    s = (r - m) * 60
    DMS = d & "°" & m & "'" & Format(s, "00.00") & """" & IIf(bLatitude, IIf(sign = -1, "S", "N"), IIf(sign = -1, "W", "E"))
End Function

Open in new window

0
 
Rog DManager Inforamtion SystemsCommented:
Doing a little google I found the following....

Yes it's in Javascript, but maybe you can use this as a basis for what you need to do.

http://javascript.internet.com/math-related/latitude-longitude-converter.html

Rog
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
FER_GCommented:
Try to see some of the next examples ...

http://tinyurl.com/2cgtq6
http://tinyurl.com/25t26f

I hope they can help you.
FerG

Saludos.
--
Ing. Fernando D. Giletta
MP: 4035 CIEC
San Fco. Cba. Arg.


0
 
hbustanCommented:
Check out this link (I'm sure you will like this one):

http://www.tma.dk/gps/
0
 
GrahamSkanRetiredCommented:

    Dim dda As Double
    Dim d As Integer
    Dim m As Integer
    Dim s As Double
    Dim r As Double
    Dim strLon As String
    Dim sign As Integer
    
    sign = Sgn(dblDegrees)
    dda = Abs(dblDegrees)
    d = Int(Abs(dda))
    r = (dda - d) * 60
    m = Int(r)
    s = (r - m) * 60
    DMS = d & "°" & m & "'" & Format(s, "00.00") & """" & IIf(bLatitude, IIf(sign = -1, "S", "N"), IIf(sign = -1, "W", "E"))

Open in new window

0
 
Jaime OlivaresSoftware ArchitectCommented:
Is it VB6 or vb.net, I can provide you a vb.net funcion like:


Public Function FormatCoord(ByVal value As Double, ByVal isLatitude As Boolean) As String 
    Dim deg As Double, min As Double, sec As Double 
    
    Dim gr As Double = Math.Abs(value) 
    deg = CSng(Math.Floor(gr)) 
    gr -= deg 
    min = CSng(Math.Floor(gr / 60F)) 
    sec = gr - min * 60F 
    
    If latitude Then 
        Return String.Format("{0:0#}°{1:0#}'{2:0#.#}""", deg, min, sec) + (IIf(value < 0,"S","N")) 
    Else 
        Return String.Format("{0:0##}°{1:0#}'{2:0#.#}""", deg, min, sec) + (IIf(value < 0,"W","E")) 
    End If 
End Function 

Open in new window

0
 
Jaime OlivaresSoftware ArchitectCommented:
sorry, typo, at line 10, should be:

     If isLatitude Then
0
 
nike_golfAuthor Commented:
Wow! thanks for the responses.

Vb6 is the development platform so Java is out.

NG,
0
All Courses

From novice to tech pro — start learning today.