Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Code Samples & Tips > Tutorials
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Tutorials Basic4ppc tutorials


GPS application - Part II


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-13-2007, 02:15 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 2,636
Default GPS application - Part II

This is the second part of the GPS tutorial.
The first part could be found here: GPS application - Part I

In this part we will discuss how to convert the coordinates between Lat/Lon and UTM formats and between different datums.

The coordinates which are received from GPS devices are in Lat/Lon format.
While this format is useful for aviation and large scale maps, it is less useful for smaller scale maps.
The complete world is divided into 60 zones (each zone covers 6 degrees longitude).
In each zone a UTM grid is defined.
As long as the interest area is in one zone it is usually easier to work with UTM.
Most topographic maps only have a UTM grid.
One of the benefits of UTM is that the coordinates are measured in meters unlike Lat / Lon coordinates which are measured in degrees.
So calculations of distance and bearing with UTM coordinates are much easier (assuming that both coordinates are in the same zone).

To make things harder, there are many datums available and each datum represents a slightly different measurement of the earth surface.
Most GPS devices and most modern maps use the WGS84 datum.

Using the Converter (found in the GPS library), we can make the required conversions easily.

We will now add UTM coordinates to our GPS program.
First choose Tools - Add Object - Converter, and name it Converter.
The most useful method of Converter (with the longest name) is:
WGS84LatLonToUTM. This method receives Lat/Lon coordinates (in their decimal format) in WGS84 datum and returns UTM coordinates in the same datum.
The return value is a structure (or an array) with 4 fields:
XZone, X, YZone (ASCII value), Y.
We will declare such a structure in Sub Globals, and name it UTM:
Code:
Sub Globals
    port = 8
    baudrate = 9600
    counter = 0
    Dim Type (Xzone,X,Yzone,Y) UTM 'The order is important!
End Sub
Inside the GPSDecoded event we will use this structure to get the four values.
Remember that when you need to reference a complete array or structure you should add '()' after its name.
Code:
If GPS1.DecimalLatitude <> 0 OR GPS1.DecimalLongitude<>0 Then
        UTM() = converter.WGS84LatLonToUTM(GPS1.DecimalLatitude,GPS1.DecimalLongitude)
        lstData.Add("UTM Zone: " & UTM.Xzone & Chr(UTM.Yzone))
        lstData.Add("UTM: " & Round(UTM.X) & " " & Round(UTM.Y))
End If
As you see in the code, we first check that the Lat/Lon coordinates are valid (if both equal 0 then there is probably no satellites reception).
The Yzone is an ASCII value, so we use Chr to show the relevant letter.


* The Yzone isn't displayed in this image.

Now for the other methods of Converter:
ChangeDatum - Converts Lat/Lon coordinates between two datums.
LatLonToUTM / UTMToLatLon - Converts between the two formats using a specific datum.
WGS84UTMToLatLon - Converts between the two formats using the WGS84 datum.
See the GPS help for more information and examples of using these methods.
Attached Files
File Type: zip GPS.zip (9.9 KB, 112 views)
Reply With Quote
  #2 (permalink)  
Old 11-28-2007, 05:07 PM
Knows the basics
 
Join Date: May 2007
Posts: 85
Default

hi Erel,

A time ago I ask the question what will I use, UTM or LAT-LON... the replys I get are very good: if you do not CROSS the UTM border, use UTM... But that is something you never now... do you cross the UTM border?
So I decide to use for all time the LAT_LON data, and with much more calculation time , I am definatly happy with it, espacialy in B4PPC with his automatic data convertions...
If you cross the border in UTM, and you must do calculating time for that fact, I think you lose as much time as in calculating with LAT-LON data.
The results of my calculations are also meters at the end, so I get the same results, and I can ashure you: it works very good... So, thinks well before you decide...

Put Claude Belgium

Last edited by Put Claude : 11-28-2007 at 05:14 PM. Reason: forgot something
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
GPS application - Part I Erel Tutorials 4 02-13-2008 06:39 AM
Application Name kawawong Questions & Help Needed 1 02-12-2008 09:38 AM
My first application Erel Tutorials 8 10-16-2007 01:00 PM
Getting value from other other application in runtime Rioven Questions & Help Needed 19 09-20-2007 09:13 AM
DB Application scott93727 Share Your Creations 0 05-02-2007 05:24 AM


All times are GMT. The time now is 11:36 PM.


Powered by vBulletin® Version 3.6.10
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0