# Android QuestionGet lat,lon from NE value

#### darabon

##### Active Member
I have a 3543.5463N,5128.1168E value (Degree and minute base)
How do can I convert that into latitude and longitude values?
I found below code for C but I cannot convert to basic
B4X:
``````float _loc_lat_bydegree_to_loc_lat_bypos_(char *_lat, char _ns) {
float real, img;
real = ((_lat[0] - '0') * 10) + _lat[1] - '0';
img = atof(&_lat[2]);
img = img / 60.0;
if (_ns == 'S') img = img * -1;
img = img + (float) real;
return img;
}
float _loc_long_bydegree_to_loc_long_bypos_(char *_long, char _ew) {
float real, img;
real = ((_long[0] - '0') * 100) + ((_long[1] - '0') * 10) + _long[2] - '0';
img = atof(&_long[3]);
img = img / 60.0;
if (_ew == 'W') img = img * -1;
img = img + (float) real;
return img;
}``````

#### darabon

##### Active Member
I solved it
B4X:
``````Sub DMSToLocation(N As String,E As String) As Double()

Dim data1,data2 As String
data1 = N
data2 = E

Dim type1,type2 As String
type1 = data1.SubString(data1.Length-1).ToLowerCase
type2 = data2.SubString(data1.Length-1).ToLowerCase

Dim n1 As String = data1.SubString2(0,2)
Dim n2 As String = data1.SubString2(2,data1.Length-1)

Dim e1 As String = data2.SubString2(0,2)
Dim e2 As String = data2.SubString2(2,data2.Length-1)

Dim lat As Double
Dim lon As Double

If type1 = "n" Then
lat = NumberFormat(n1 + (n2/60),0,5)
End If

If type2 = "e" Then
lon = NumberFormat(e1 + (e2/60),0,5)
End If

If type1 = "s" Then
n2 = n2 * -1
lat = NumberFormat(n1 + (n2/60),0,5)
End If

If type2 = "w" Then
e2 = e2 * -1
lon = NumberFormat(e1 + (e2/60),0,5)
End If

Return Array As Double(lat,lon)

End Sub``````

Replies
40
Views
3K
Android Question Null not evaluating as Null
Replies
30
Views
4K
Android Question Lat/Long and Intent
Replies
1
Views
1K
Replies
2
Views
1K
Replies
5
Views
14K