Android Question GoogleMap coordinates accuracy

Sergey_New

Well-Known Member
Licensed User
Longtime User
I get the value:
B4X:
gmap.MyLocation.Latitude=55.801509857177734
I don't need such accuracy. How can I convert this value to the nearest whole seconds?
 

Sergey_New

Well-Known Member
Licensed User
Longtime User
This will be accurate to within one minute, but not one second.
 
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
I am sorry - you are right and I am wrong. Multiplying the decimal part by 3600 and rounding it will give you the number of seconds. Dividing that by 60 will give you the whole minutes and the remainder will be the seconds value. I cannot show you the code for this right now.
 
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
Try this code. It gives the right values for degrees, minutes and seconds but does not format the answer (that is, it does not add leading zeroes).
B4X:
    Dim degrees As Double = 55.801509857177734
    Dim seconds As Int = (degrees - Floor(degrees)) * 3600
    degrees = Floor(degrees)
    Dim minutes As Int = seconds / 60
    seconds = seconds Mod 60
    Log("Angle = " & degrees & ":" & minutes & ":" & seconds)

Result is - Angle = 55:48:5
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
other:
B4X:
    Dim lat As Double = 55.801509857177734
    Dim Grados As Int = Floor(lat)
    Dim Minutos As Int = Floor((lat - Grados) * 60)
    Dim Segundos As Int = Round((((lat - Grados) * 60) - Minutos) * 60)
    Log($"${Grados}:${Minutos}:${Segundos}"$)

    Dim latitud_decimal As Double = Grados + Minutos / 60 + Segundos / 3600
    Log(latitud_decimal)

1751147654347.png
 
Upvote 0

Sergey_New

Well-Known Member
Licensed User
Longtime User
Brian Dean, TILogistic thanks for your input!
I guess I didn't formulate my problem well.
The coordinate can be entered in either decimal or degrees, minutes and seconds format. The coordinate value is stored in the database in decimal format.
It looks like I have the wrong conversion from one format to another that takes into account the decimal part of the seconds.
 
Upvote 0

Similar Threads

Top