B4A Library [B4X] [class] Geodesic - Convert Lat Lon / UTM coordinates

Discussion in 'Additional libraries, classes and official updates' started by Erel, Jul 2, 2013.

  1. Erel

    Erel Administrator Staff Member Licensed User

    The attached class allows you to convert coordinates between Lat Lon coordinates and UTM coordinates.

    The conversion is done with WGS84 datum. Note that the class code can handle other datums as well.

    Usage example:
    Sub Activity_Create(FirstTime As Boolean)
    Dim g As Geodesic
    Dim u As UTM
       u.UtmXZone = 
       u.X = 
       u.Y = 
       u.NorthHemisphere = 
    Dim ll As LatLon
       ll = g.WGS84UTMTOLatLon(u)
    Log(ll.Lat & "N " & ll.Lon & "E")
    End Sub
    There were reports of inaccurate results. I wasn't able to reproduce them. Make sure to test it thoroughly.

    Attached Files:

    Last edited: Jul 10, 2016
  2. laviniut

    laviniut Active Member Licensed User

    Sorry, how to convert GPS coordinates, like in GPS tutorial example from you, to decimal degrees ?
  3. klaus

    klaus Expert Licensed User

    The GPS library returns decimal degrees !
    If you look in the code of the GPSTutorial project you would see in the GPS_LocationChanged routine that the original location values are converted to minutes !
    Replace this routine:
    Sub GPS_LocationChanged (Location1 As Location)
        lblLat.Text = 
    "Lat = " & Location1.ConvertToMinutes(Location1.Latitude)
        lblLon.Text = 
    "Lon = " & Location1.ConvertToMinutes(Location1.Longitude)
        lblSpeed.Text = 
    "Speed = " & Location1.Speed
    End Sub
    by this one !
    Sub GPS_LocationChanged (Location1 As Location)
        lblLat.Text = 
    "Lat = " & Location1.Latitude
        lblLon.Text = 
    "Lon = " & Location1.Longitude
        lblSpeed.Text = 
    "Speed = " & Location1.Speed
    End Sub
    You could use NumberFormat to format the output.
    Devan likes this.
  4. laviniut

    laviniut Active Member Licensed User

    Yes, i see now. Thank you. I was in a hurry and i have not seen that.
  5. arnold steger

    arnold steger Member Licensed User

    i have a big database whit utm coordinates without utmxzone.
    example point from database: 733149.983999997 5183855.2929
    i want convert in lat/lon.
    how can find the u.UtmXZone for each point?
  6. DaveW

    DaveW Active Member Licensed User

    You can't. There are 60 zones covering the earth, every one of which will have a valid position 733149.983999997 5183855.2929 - or any other X & Y combination. Assuming these are in Northing Easting order then each zone will have a point with these coordinates about 460Km East or West of the adjacent zone.
    nimafallah, Devan and arnold steger like this.
  7. Celso

    Celso Member Licensed User

    Hi, can you example how to convert ex:-19.868847,-43.965379 to UMC ?
  8. Erel

    Erel Administrator Staff Member Licensed User

    Dim geo As Geodesic
    Dim ll As LatLon
    ll.Lat = -
    ll.Lon = -
    Dim utm As UTM = geo.WGS84LatLonToUTM(ll)
  9. jamesnz

    jamesnz Active Member Licensed User

    where is the geodesic Library?
    has it been removed , or incorporated elsewhere ?
    Geodesic.bas appears to be a blank file ?
  10. DonManfred

    DonManfred Expert Licensed User

    No, it is 8kb in size and has 260 lines...
    Download it again

    It is not a library btw, it is a class which you need to add to your app.
    Erel and jamesnz like this.
  11. jamesnz

    jamesnz Active Member Licensed User

    got it, was trying to open it directly, thanks ( again) Manfred:)
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice