Welcome!

PowerBuilder Authors: Dan Joe Barry, Carmen Gonzalez, Ian Thain, Yakov Werde, Paul Slater

Related Topics: PowerBuilder

PowerBuilder: Article

Integrate Real-Time GPS Data Into Your PowerBuilder Applications

would you want to integrate real-time GPS data into your PowerBuilder applications anyway?

What we need now is a way to extract each individual sentence out of the stream to be passed for parsing to the NMEA object. For that I wrote the wf_get_token function. This will extract a string based upon a delimiter. For the NMEA stream, that is the newline character.

Finally, we will need a way to convert the latitude and longitude returned by the receiver to decimal degrees. This is necessary for the MapPoint method GetLocation. The formula for doing so is:

There are some other conversions necessary for GetLocation as well. They are as follows:

We can determine the sign based upon the direction returned by the NMEA sentence. Finally, we can map our current position by using the following MapPoint code.

loo_Location = ioo_Map.GetLocation(ldb_Lat, ldb_Long, ldb_Alt)
loo_PinCurrentFix=ioo_Map.AddPushpin(loo_Location,"You are here!")
loo_Location.GoTo()
loo_PinCurrentFix.Select()

There are many other operations you can perform in MapPoint, for example, directions from point A to point B. A good resource is an article written in PBDJ (Vol. 11, issue 10) entitled "Using MS MapPoint in PowerBuilder" by Arthur Hefti. The source for that article can be found here: http://gemsres.com/story/jul05/107019/source.html.

Step 5: Put it all together. Add the following code to the clicked button of your "Get GPS Data" button.

ib_Connected = wf_detect_bt()
If ib_Connected Then
      wf_write_gps()
      sleep(3)
      wf_read_gps()
End If

Step 6: Cleanup

ole_MapControl.Object.CloseMap()
wf_close_bt()

That's it.

One final note, if you plan on connecting to a Bluetooth serial port greater than COM9, you will need to use this syntax "\\.\COMxx" as the port name. Just substitute the port number you wish to use for xx. The cause of the problem is that CreateFile accepts strings "COM1" - "COM9" as names of devices but rejects doing so for two or more digit numbers.

If you are interested in learning more, check out the following references. In addition, you can find the complete source code for this project on CodeExchange in the PowerBuilder special hardware section.

Resources

More Stories By Deanne M. Chance

Ms. Chance graduated in 1996 with a degree in computer science from the University of Illinois. She has been a frequent contributor to the PowerBuilder Developer's Journal and gave a key presentation at Sybase TechWave 2005 entitled "A Real-Time Physical Inventory Solution Using PocketBuilder ASA and a WiFi Connection." She has held several engineering positions, starting a career at Motorola where she focused on mobile I.P. by doing real-time embedded programming for the base radio controller group as part of the iDEN/Nextel project.

Comments (4) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
josen30308 05/06/09 07:38:00 PM EDT

I just got a simple question. wich is the code NMEA and where am I supposed to put this code?
Josen30308@hotmail.com

sincerely

Jose

SYS-CON Belgium News Desk 02/19/06 01:43:54 PM EST

We begin this article by asking the question: Why would you want to integrate real-time GPS data into your PowerBuilder applications anyway? After all, it's not likely you are going to connect a GPS receiver to your desktop computer and ask yourself where you are currently located. (At least I hope not!)

news desk 02/18/06 02:49:34 PM EST

We begin this article by asking the question: Why would you want to integrate real-time GPS data into your PowerBuilder applications anyway? After all, it's not likely you are going to connect a GPS receiver to your desktop computer and ask yourself where you are currently located. (At least I hope not!)

SYS-CON Belgium News Desk 02/18/06 01:20:55 PM EST

We begin this article by asking the question: Why would you want to integrate real-time GPS data into your PowerBuilder applications anyway? After all, it's not likely you are going to connect a GPS receiver to your desktop computer and ask yourself where you are currently located. (At least I hope not!)