Page 1 of 2 12 LastLast
Results 1 to 40 of 74

Thread: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)

  1. #1

    Thread Starter
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)

    A class for calculating between Latitude/Longitude and Universal Transverse Mercator (UTM) coordinates which accurate maps like to use. It will reverse calculate as well.

    You can set the class to use one of various datum ellipsoids such as WGS84, NAD83 and several others. The numbers programmed for each ellipsoid aren't the most accurate, but they can be easily modified to suit tastes. Currently, the error produced seems to be within a meter or so.

    Here is the class: GPS.vb

    Here's how to use it from Lat/Long in decimal coordinates (+ = N/E, - = S/W):
    Code:
            Dim lat As New GPS.Coordinate(myDecimalLatitude, GPS.CoordinateType.Latitude)
            Dim lng As New GPS.Coordinate(myDecimalLongitude, GPS.CoordinateType.Longitude)
            Dim utm As New GPS.UTM(lat, lng)
    
    
            Me.txtNorthing.Text = utm.Northing.ToString
            Me.txtEasting.Text = utm.Easting.ToString
            Me.txtZone.Text = utm.Zone.ToString
            Me.cmbHemisphere.Text = If(utm.UTMLatitudeHemisphere = GPS.UTMLat.North, "N", "S")
    Here's how to use it in the opposite direction. You need 4 pieces of info, Northing (m), Easting (m), Zone and whether it's N or S hemisphere (default is North):
    Code:
            Dim utm As New GPS.UTM(myNorthing, myEasting, myZone)
            utm.UTMLatitudeHemisphere = GPS.UTMLat.North
    
            Me.txtLatitude.Text = utm.Latitude.ToString
            Me.txtLongitude.Text = utm.Longitude.ToString
    All equations and figures taken from an Excel spreadsheet example written by Professor Steven Dutch, of University of Wisconsin-Green Bay and is primarily ripped from the 1973 U. S. Army Technical Manual on the Universal Transverse Mercator Grid. I only take credit for turning it into a VB.NET 2008 Class

    EDIT: I found a bug in the code that was flipping the sign of the Longitude during the UTM to Lat/Long conversion. New file uploaded with the fix.
    Last edited by Jenner; Oct 15th, 2009 at 09:09 AM.
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  2. #2
    New Member
    Join Date
    Mar 2009
    Posts
    1

    Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)

    Hi i have a UTM coordinates like this x = 520825 , y = 2869270
    How i can convert this coordinates to Latitude/Longitude? , my zone is 14 and Hemisphere is North.

    Regards
    Isaias

  3. #3

    Thread Starter
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)

    That would be the second example I posted above. Sorry, I noticed the variable names were still listed as "Latitude" and "Longitude" and not "Northing" and "Easting".

    But just make a new object, give it the 4 peices of information and read the latitude and longitude from it. It does the conversion as you change the data.
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  4. #4
    New Member
    Join Date
    Apr 2009
    Posts
    1

    Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)

    i get 'Truncate' is not a member of 'System.Math'

    any ideas??

  5. #5
    New Member
    Join Date
    Oct 2009
    Posts
    6

    Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)

    Hi,
    I’m working with data downloaded from a gps device, using vb2008 express I can open a file, load this into an array and extract the required lat long co-ordinates. I now need to convert these to utm so that I can do some basic trig to calculate distances.
    Your class seems ideal for the next step but as I'm only at the stage of creating basic programs I need some help to get the data from the array processed by the class and extract the utm data at the end.
    I’m just doing this for fun, in connection with my other hobby, paragliding, any help or direction as to where to get more info would be greatly appreciated.
    Thanks
    Chris

  6. #6

    Thread Starter
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)

    Get your numbers from the array. You should have a Lat and a Long number. Then just follow my example above. Put those numbers in the myDecimalLatitude and myDecimalLongitude spots in that example. For example, if you had Lat: 51.6702014 Long: -76.1103928, you'd do this (remember, negative coordinates indicate South latitudes and West longitudes):

    Code:
            Dim myDecimalLatitude = 51.6702014 
            Dim myDecimalLongitude = -76.1103928
    
            Dim lat As New GPS.Coordinate(myDecimalLatitude, GPS.CoordinateType.Latitude)
            Dim lng As New GPS.Coordinate(myDecimalLongitude, GPS.CoordinateType.Longitude)
            Dim utm As New GPS.UTM(lat, lng)
    
            'The results are instantly calculated and available:
            Me.txtNorthing.Text = utm.Northing.ToString
            Me.txtEasting.Text = utm.Easting.ToString
            Me.txtZone.Text = utm.Zone.ToString
            Me.cmbHemisphere.Text = If(utm.UTMLatitudeHemisphere = GPS.UTMLat.North, "N", "S")
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  7. #7
    New Member
    Join Date
    Oct 2009
    Posts
    6

    Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)

    thank you for your help with this, I still have some work to do on processing the data form the array but I am making progress with this. I can now see how the class works and think it is brilliant. I have tested the accuracy, at home here in Northumberland, UK, it is accurate to under 1 meter.
    Again, many thanks for your help.
    Chris

  8. #8

    Thread Starter
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)

    I'd say less than 1 meter is pretty good for most needs.

    I think this class can be implemented a little better, but I honestly haven't had the time to do it.
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  9. #9
    Frenzied Member
    Join Date
    Jun 2003
    Location
    Auckland
    Posts
    1,139

    Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)

    what do I have to import o get GPS working?
    Attached Images Attached Images  

  10. #10
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)

    Quote Originally Posted by kiwis View Post
    what do I have to import o get GPS working?
    Have you added the GPS.vb source file to your project? If not then how is the project supposed to know the GPS class exists?

  11. #11
    Frenzied Member
    Join Date
    Jun 2003
    Location
    Auckland
    Posts
    1,139

    Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)

    I thought I had but clearly not.

  12. #12

    Thread Starter
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)

    What errors are you getting exactly, because looking at your screenshot, it looks like you have the GPS class on the tab behind the Form1 object.
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  13. #13
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)

    Quote Originally Posted by Jenner View Post
    What errors are you getting exactly, because looking at your screenshot, it looks like you have the GPS class on the tab behind the Form1 object.
    Having the file open in VS doesn't mean it's part of the project. If you already have VS open and you download a VB file it will be opened in the same VS window, but it's not added to the project automatically.

  14. #14

    Thread Starter
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)

    True, hadn't thought of that. You can always "view" .vb files in the editor, it doesn't mean they've been added to your solution. He copy-pasted my code example in the global area of his class object as well. It needs to be inside a subroutine or a function block like all other non-defining code.
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  15. #15
    Frenzied Member
    Join Date
    Jun 2003
    Location
    Auckland
    Posts
    1,139

    Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)

    How can I place these coordinates on a map?
    Last edited by kiwis; Oct 20th, 2009 at 02:08 AM.

  16. #16

    Thread Starter
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)

    You just need a proper map that has UTM alignment information from what I understand. It'll have a grid of Northing and Easting on it with UTM coordinates; as opposed to a map with Lat and Long projections.
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  17. #17
    Frenzied Member
    Join Date
    Jun 2003
    Location
    Auckland
    Posts
    1,139

    Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)

    I can not seem to find a world map :-(

  18. #18
    Frenzied Member
    Join Date
    Jun 2003
    Location
    Auckland
    Posts
    1,139

    Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)

    The other option is I convert the northing value into pixels. So if there is 80° S latitude and 84° N then there is 164 in total start from the bottom. If my map was 492px high and I wanted to find something at 76S I would go 12 pixels high. 3 times.

    Only problem is this would be way out unless I made the 164 the true value as such, how many meters is it between 80 and 79??

  19. #19

    Thread Starter
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)

    Right, at this point, your problem seems to be one of conversion between real-world coordinates and what is displayed on the screen.
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  20. #20
    Frenzied Member
    Join Date
    Jun 2003
    Location
    Auckland
    Posts
    1,139

    Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)

    Yes. I want to be able to convert long and lat coord's onto a world map displayed in front of me on my screen

  21. #21
    New Member
    Join Date
    Feb 2010
    Posts
    5

    Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)

    I downloaded the file GPS.VB and loaded into VB.net. Using UTM to Lat/Lon, the Longitude that is returned is always 0.

    You mentioned in one of the post that the code had an error. Could you Please post the corrected code?

    Thanks

  22. #22

    Thread Starter
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)

    The error was fixed and posted long ago. The only error found in the code that has not been fixed in the download is an insignificant math error in the arc second calculation that makes the number off at most 1 inch at the equator. If you want to fix that, then just change this line in the object:

    Code:
                Dim e0 As Double = (315 * a * n ^ 4 / 51) * (1 - n)
    to this:

    Code:
                Dim e0 As Double = (315 * a * n ^ 4 / 512) * (1 - n)
    Are you instancing the class properly? Are you specifying the zone, northing, easting and hemisphere? You need all four pieces of information to convert from UTM to Lat/Long. See my example above.
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  23. #23
    New Member
    Join Date
    Feb 2010
    Posts
    5

    Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)

    Thanks for the reply:
    I am basicly taking a lat/lon and passing it to the LL To UTM converter then taking that result and passing it to the UTM to LL Converter.

    Here is what I do:
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    LLToUTM(31.5, 91.5)

    End Sub


    Public Sub LLToUTM(ByVal myDecimalLatitude As Single, ByVal myDecimalLongitude As Single)
    Dim txtNorthing As String
    Dim txtEasting As String
    Dim txtzone As String
    Dim cmbhemisphere As String

    Dim lat As New GPS.Coordinate(myDecimalLatitude, GPS.CoordinateType.Latitude)
    Dim lng As New GPS.Coordinate(myDecimalLongitude, GPS.CoordinateType.Longitude)
    Dim utm As New GPS.UTM(lat, lng)


    txtNorthing = utm.Northing.ToString '<<-This is 3485991.16655783
    txtEasting = utm.Easting.ToString '<<-This is 357546.073706798
    txtzone = utm.Zone.ToString ' <<-This is 46
    cmbhemisphere = If(utm.UTMLatitudeHemisphere = GPS.UTMLat.North, "N", "S") 'N
    TUMToLL(utm.Northing, utm.Easting, utm.UTMLatitudeHemisphere)
    End Sub

    Public Sub TUMToLL(ByVal MyNorthing As Single, ByVal myEasting As Single, ByVal myzone As String)
    Dim txtLatitude As String
    Dim txtLongitude As String
    Dim utm As New GPS.UTM(myNorthing, myEasting, myZone)
    utm.UTMLatitudeHemisphere = GPS.UTMLat.North

    txtLatitude = utm.Latitude.ToString '<<-This is 31° 29' 59.989" North
    txtLongitude = utm.Longitude.ToString '<<-This is '0° 0' 0.000" North
    End Sub



    The Longitue is returning a NORTH value.

    I downloaded the GPS.VB from the top if this post.


    Thanks again

  24. #24
    New Member
    Join Date
    Feb 2010
    Posts
    5

    Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)

    Well....as soon as i sent the previous reply...I saw my error. I sent the wrong parameter for the ZONE.


    Thanks It works GREAT

  25. #25
    New Member
    Join Date
    Feb 2010
    Posts
    5

    Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)

    Jenner
    Your class works great...Thanks
    But, I do have a question for you.

    Since the Easting and Northing returns values from their ZONES. How can I calculate a value such as distance from two points in two different Zones?


    Thanks again

  26. #26

    Thread Starter
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)

    The only way would be to convert the WGS coordinates to Lat/Long and perform a Great Circle calculation to get the arc length between them.
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  27. #27
    New Member
    Join Date
    Oct 2009
    Posts
    6

    Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)

    Hi Gary,
    You could use the Haversine formula, see http://en.wikipedia.org/wiki/Haversine_formula
    This calculates distance between two lat/long positions based on the earth as a perfect sphere; it gives an accuracy of about 0.3&#37; and is not too difficult to understand and code. The more complex Versine formula uses a model that can be based on a map datum such as wgs84 and is more accurate - but I couldn’t figure out how to code this, perhaps someone more able might have a go.
    cheers
    chris

  28. #28
    Addicted Member
    Join Date
    Jul 2007
    Posts
    130

    Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)

    Hi
    how to get my zone value?
    if i have those values
    lat=49.568511
    lon=27.104216
    what will be the code to convert them to N,E ?
    i try this code
    http://www.vbforums.com/showpost.php...59&postcount=1
    but it gives me wrong values !!
    what will be te right code?

    thanks in advance.

  29. #29

    Thread Starter
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)

    If it gives you the wrong values, then you're using it wrong.

    It works perfectly:

    Name:  GPSWorks.gif
Views: 27611
Size:  250.9 KB
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  30. #30
    Addicted Member
    Join Date
    Jul 2007
    Posts
    130

    Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)

    thanks for reply

    yea right this result also for me
    Northing=5490662.87262606
    Easting=507535.487639871
    Zone=35
    Hemisphere=N

    BUT when im in Google earth and i convert from lat and Lon to N,E from options it gives me
    27&#176; 6.253 N
    49&#176; 34.111 E

    so how to make it like Google result

  31. #31
    Member
    Join Date
    Mar 2005
    Posts
    41

    Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)

    Hi,

    thanks for you great class! But it doesn&#180;t work for me...

    I&#180;ve

    UTM in Format
    32337666
    5656482
    32N

    and I need to get WGS84 in this format

    50.94082111
    6.68391562
    !

    But when I start this code
    Code:
            Dim utm As New GPS.UTM(5656482.0, 32337666.0, 32)
            utm.UTMLatitudeHemisphere = GPS.UTMLat.North
    
            Label6.Text = utm.Latitude.ToString
            Label7.Text = utm.Longitude.ToString
    I get
    0&#176; 0' 0,000" North
    0&#176; 0' 0,000" North
    as result!!!

    Greets

    Byte

  32. #32

    Thread Starter
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)

    That's because your data is bad. How do you have numbers in the 32 million and 5 million range? If you put your numbers in any online converter you'll see some crazy funny-number results like a Lat of 520 degrees.
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  33. #33
    Member
    Join Date
    Mar 2005
    Posts
    41

    Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)

    Hi,

    I get the data from a address-database!
    What do you mean, my data is crazy?

    Do you think it isn&#180;t UTM ?


    ATENTION:

    on Site http://www.ipf.uni-karlsruhe.de/cgi-bin/trafo.tcl
    UTM 32 WGS84 -> Gauss-Krueger Nr.2/6 Grad (West-D)

    WORKS FINE !!!!!! But theres no source
    Need help, please....


    Greets

    Byte
    Last edited by Bytechanger; Mar 11th, 2010 at 02:17 AM.

  34. #34

    Thread Starter
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)

    Alright, I figured it out. This is such a stupid notation.
    Take your data:
    32337666
    5656482
    32N

    The first number is a combination of the Zone and the Easting: 32337666 You want to remove the Zone numbers before converting. They're always the first two. This is apparently a standard notation used by the Germans.
    So, put THESE numbers into the converter:
    Northing: 5656482
    Easting: 337666
    Zone: 32
    Hemisphere: N

    Of course, you can always edit the converter to accept that notation as the standard input and strip the zone off then.
    Last edited by Jenner; Mar 12th, 2010 at 08:54 AM.
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  35. #35
    New Member
    Join Date
    Apr 2010
    Posts
    3

    Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)

    Any chance you have the code for C#. I tried a bunch of converters but code would not compile. What imports ("using" in C# to I need).

    Cam

  36. #36

    Thread Starter
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)

    It's really simplistic code from a conversion standpoint. There's no events or event handlers, no fancy VB tricks. Just some basic constructors and math.

    Of course, you could always take up VB.NET.
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  37. #37
    New Member
    Join Date
    Apr 2010
    Posts
    3

    Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)

    Hello Jenner,

    I finally manged to get it to compile in C#. Not as straightforward as I had hoped.

    Another thing that I noticed is the follwong line:
    double sin1 = Math.PI / (180 * 3600); warning CS0219: The variable 'sin1' is assigned but its value is never used.

    Is this important or maybe it is just for testing?

    Cam

  38. #38

    Thread Starter
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)

    It doesn't surprise me. The equation set I used was simplified for slide-rule and table calculation and some terms were used in more than one figuring.
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  39. #39
    New Member
    Join Date
    Apr 2010
    Posts
    3

    Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)

    After compiling and using the code in C# I have tried to convert the coordinates from a user click on my Web Mapping Application. My coordinates are in UTM Zone 10.

    Sample coords are: 510472 E and 5440699 N.
    This gives results of 48.97625305 and -122.8564619 which is many miles to the south of where I want. I want to be able to zoom to google maps based on the user click.

    maybe something happened when I convert to C#.

    Jenner using the vb code what lat/long do you get for the above coords.

    Cameron

  40. #40

    Thread Starter
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)

    I get: 49.119 lat, -122.856 long (assuming north hemisphere)

    Yea, check the math in the latitude conversion.
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width