Convert GPS Coordinates

FabioG

Active Member
Licensed User
Longtime User
Hello,

I need help

I have GPS coordinates in this format
043 47'16 N
011 24'41 E

and I need to convert this format


43.787778
11.411389


consider that 043 47'16 N 011 24'41 E and 43.787778 11.411389
refer to the same point on the map, but of course they are in different formats.

Who can help me?

thank you very much

Fabio
 
Last edited:

derez

Expert
Licensed User
Longtime User
B4X:
Sub dms(st As String) As Double
Dim d,m,s As Double
d = st.SubString2(0,3)
m = st.SubString2(4,6)/60
s = st.SubString2(7,9)/3600
Return NumberFormat(d+m+s , 1,6)
End Sub
 
Last edited:
Upvote 0

FabioG

Active Member
Licensed User
Longtime User
B4X:
Sub dms(st As String) As Double
Dim d,m,s As Double
d = st.SubString2(0,3)
m = st.SubString2(4,6)/60
s = st.SubString2(7,9)/3600
Return NumberFormat(d+m+s , 1,6)
End Sub


I'm sorry, okay
 
Last edited:
Upvote 0

AndroIwe

Member
Licensed User
Longtime User
Hello,

i testet this:

B4X:
Sub Globals
   Dim Label1 As Label
   Dim Label2 As Label
   Dim EditText1 As EditText
   Dim EditText2 As EditText
   Dim Input As String
   Dim Output As Double
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.

End Sub

Sub Activity_Create(FirstTime As Boolean)
   'Do not forget to load the layout file created with the visual designer. For example:
   Activity.LoadLayout("GPSUmrechner")
    
End Sub

Sub Button1_Click
    Input=EditText1.Text
   Output = dms(Input)
   EditText2.Text = Output

Sub dms(st As String) As Double
   Dim d,m,s As Double
   d = st.SubString2(0,3)
   m = st.SubString2(4,6)/60
   s = st.SubString2(7,9)/3600
   Return NumberFormat(d+m+s , 1,6)
End Sub

and got an error:

Error description: Syntax error.
Occurred on line: 44
Sub dms(st As String) As Double

Think this is only a small error, but i didn't find the error.

Please can you help me ...

Thanks,
Duffy
 
Upvote 0

MLDev

Active Member
Licensed User
Longtime User
You're missing a End Sub for Sub Button1_Click.

B4X:
Sub Button1_Click
    Input=EditText1.Text
    Output = dms(Input)
    EditText2.Text = Output
End Sub
 
Last edited:
Upvote 0

Highwinder

Active Member
Licensed User
Longtime User
I have a similar problem if anyone can help me. I am getting GPS coordinates from my app that look like this:

(example copied from above post)
43.787778
111.411389
What I need is the format to look exactly like this:

123° 04'W 49° 09'N
(this coordinate does not match above example)

Can anyone help me?
 
Last edited:
Upvote 0
Top