Thursday, December 18, 2008

Visual Studio Google Gadget

I was curious as to how Google Gadgets worked, and for that matter, how they were built. I set out to Google's site and looked up Google Gadget. Found the API, downloaded the SDK and I was off to a good start. My project: list recent Visual Studio projects. One step further than that, I want to be able to select which Visual Studio version I wanted to list the projects for.

After a bit of research of how to access the registry through javascript, I was off to a good start. I created the basic form, which was basically just a shell, no real content. On the load event, it would call a method that would 1) find out which version of Visual Studio to look at 2) look under the proper Visual Studio folder and see what recent projects are in the MRU. For each project found, it parses the string path and keeps the solution name and sticks it in a label on the form. If no projects are found, it creates a label that says "No Projects".

I then proceeded to create the Options page, which basically is just 3 mutually exclusive checkboxes for the 3 Visual Studio versions in question (2003, 2005 & 2008). Based on what is selected here, this will affect what is displayed on the main form.

Finally, I worked on the information displayed in the About page. I created the package (*.gg file) and tested it out thoroughly. It works like a charm!

If you're interested, here is the code (VisualStudioProjects.zip) and the gadget (Visual Studio Recent Projects-Sebastien Limoges.gg).

Tuesday, December 9, 2008

Google Maps vs Virtual Earth

I started looking at the details of Google Maps (GM) and noticed that they ignore everything after the 6th decimal. Normally, I'd say that's good enough, but in the case of GPS locations, that is very limiting. I then looked at Virtual Earth (VE) and noticed they didn't have that limitation. The other advantage of VE vs GM is that there's a higher threshold for requests per day and no need to register to receive a special key.

So I set out to test the flexibility of this Virtual Earth and quickly notice that it's using HTML and JavaScript inside a browser. This might be troublesome later when I try to stick this on the Window Mobile 6 (WM6) platform, but I'll deal with that later. For now, I just want to see if I can do what I want in a quick prototype fashion.

I start looking at the Virtual Earth SDK (http://msdn.microsoft.com/en-us/library/aa905677.aspx) and looking at the live demo (http://dev.live.com/virtualearth/sdk/) I see all I could possibly want for this project: type of map (Road, Satellite, hybrid), I can add pushpins (which are Shapes in VE) and I can grab coordinates by responding to mouse events.

After a few hours of testing and messing around with the different possibilities and permutations, I came up with a finished product that quickly demos the ability of VE for this project. You can get the code for this example at the bottom of this entry.

For the purpose of this prototype, I went back again to my good old blue hole #1 at NAS Jacksonville. I first set the "center" of the hole to get the appropriate map. I then set tentative 100, 150 & 200 yds markers and I set another one to simulate where I'd be on the tee box. I add event handlers for the mouse clicks. I set different functionality for both left click and right click. Left Click gets the coordinates of where I clicked on the map both in pixels & in latitude and longitude. It also tells me the distance (yds & ft) from where I clicked to where I'm currently at. Right Click sets my new current location, which would be handled by the GPS data normally. I also added two buttons, a plus and a minus to assist with zooming in and out (if you don't have a scroll button on your mouse). You can see below a screen shot of what it looks like in IE6.

All and all, I'm very happy with this prototype. The next step will be to figure out how to stick this inside the WM6 environment.

Until next time,

Sebastien Limoges

Monday, December 1, 2008

Upcoming MSDN Tiki Hut Roadshow related to my project efforts

I found out that there will be an MSDN Tiki Roadshow this Wednesday, December 3rd @ the FCCJ North Campus and one of the sessions relate to GPS programming. I'm going to make my best effort to be there to see if there's any aspect of data analysis that I'm forgetting and to see how they put a solution together.

For more info, go to the event's site: https://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032389331&culture=en-US

Saturday, November 22, 2008

It all starts with the math...

Okay, maybe not, but I thought that for this project, this would be a major part of the functionality: calculating the distance between two points. How exactly do you calculate the distance between to coordinates? Well, you can use some basic math to figure it out... if the earth was flat. Then there is the spherical formula, which would be nice, if the earth was a perfect sphere. What we end up with is a spheroid (sphere flattened at the poles), and the best formula to use for this (as per my Google research) is the Haversine formula.

To use the Haversine formula, you have to make sure your coordinates are in radians, not degrees. That's simple: radians = PI / 180 * degrees. How do you go from 30° 13' 4.07" N to something the formula can use : 30.21779722222222? You parse the string. Everything is related to 1 hour. So 30 / 1 + 13 / 60 + 4.07 / 3600 gives you the 30.21779722222222 and the N gives you the sign (+). If it was South or West, it would have been negative. The formula returns miles, so if I want yards, I multiply the result by 1760 and if I want feet, I multiply by 5280.

Now that I had figured out the formulas, I set out to create a class that would handle this work. I create a class called Haversine (after the formula used) and create a Distance method that returns a double and takes in 3 parameters: Position 1, Position 2 & Distance Type. Positions are a structure containing 2 double values for latitude and longitude. I also create a method that converts degrees into radians and vice versa. The last method is parseReg which takes a string. Basically it converts a value (30° 13' 4.07" N) that is degrees, minutes, seconds & direction into a double (30.21779722222222).

To test this puppy out, I use coordinates from my favorite golf hole at NAS, Red Hole # 1. I take the coordinates of the center of the green and the coordinates of the 200 yard marker. So the center of the green's coordinates are 30 13 4.07N latitude by 81 40 58.55W longitude. The 200 yard marker's coordinates are 30 12 58.18N latitude by 81 40 57.89W longitude. Plug those in the class and I get a result of 199.951410648 yards. For golf application, I'm willing to take this as pretty accurate, especially since the coordinates for the hole were captured off of Google Earth's site, not physical reading on the course.

Well, I'm very happy with the progress made today. I have a class that can handle all the math behind calculating the distance between to points in either yards or feet. The next hard part will be to use actual satellite pictures (probably from Google Earth's site), get coordinates from all 4 corners of the picture and then be able to use those coordinates to be figure out the distance between a point on that picture and the current GPS device location. To explain, let's say I'm looking at a bird's eye view of the hole I'm on. I'm on the tee box and I want to know how far is it to reach that creek on the left. I click on the screen where I see the end of the creek on the left and based on my current coordinates and the coordinates of where I clicked, it tells me that it's 187 yards out. That's the next goal.

Until next time,

Sebastien Limoges

The code of the Haversine class is available for download below.

Thursday, November 20, 2008

First steps toward starting the Golf Mobile GPS project

Before jumping into the development, I decided to make some research as to what was needed to do such development. It was obvious that I needed Visual Studio 2005 or greater, but what else? I found that I needed Windows Mobile 6 Professional SDK (not standard if you want to use PDA phones as your target platform), ActiveSync 4.5 (Windows XP) or greater or Windows Mobile Device Center (Windows Vista). As it turns out, Windows Mobile 6 comes pre-installed (in ROM) with .NET Compact Framework 2.0 & SQL Server 2005 Compact Edition.

Note: it was recommended that you install the .NET Compact Framework 2.0 Service Pack 1, and if using Visual Studio 2005: Visual Studio 2005 Service Pack 1 and the SQL Server 2005 Compact Edition Tools for Visual Studio 2005.

Since both my development machine are Windows Vista Ultimate, I set out to download the Windows Mobile 6 Professional SDK and install it. My goal is to get this application working on my AT&T Tilt phone equiped with Windows Mobile 6.

Here are the links to the different components needed (other than Visual Studio):

Windows Mobile 6 Professional SDK Refresh
http://www.microsoft.com/downloads/details.aspx?familyid=06111a3a-a651-4745-88ef-3d48091a390b&displaylang=en

---- If Using Windows XP ----
ActiveSync 4.5
http://www.microsoft.com/downloads/details.aspx?FamilyID=9e641c34-6f7f-404d-a04b-dc09f8141141&DisplayLang=en

---- If Using Vista ----
Windows Mobile Device Center
http://www.microsoft.com/downloads/details.aspx?familyid=46F72DF1-E46A-4A5F-A791-09F07AAA1914&displaylang=en

You can read all about what is new for developers in Windows Mobile 6 at http://msdn.microsoft.com/en-us/library/bb278115.aspx#WhatYouNeedtoStartingBuildingWindowsMobile6Applications.

The download took a while (approx 1.5 hrs for 454 MB) and so did the setup. For good measures, I also downloaded the Windows Mobile 6.1 Professional Images (USA) (http://www.microsoft.com/downloads/details.aspx?familyid=3D6F581E-C093-4B15-AB0C-A2CE5BFFDB47&displaylang=en) which took about 45 mins for 272 MB.

To see if my setup is working properly, I try to run the GPS Intermediate Driver (GPSID) example (http://msdn.microsoft.com/en-us/netframework/cc719033.aspx). My first attempt ended with an error on deployment. I looked and after a few seconds of reading the error message over, I noticed that my target was Windows Mobile 6 Professional Device and not Windows Mobile 6 Professional Emulator. So I changed that and tried again. I see the app window coming up but nothing happens when I click on GPS On, which is as expected. I then go to File | Configure and set the Shared folder path to C:\Program Files\Windows Mobile 6 SDK\Tools\GPS. This allows me to see that path, and more specifically the FakeGPS cab file in there, as if it was on a Storage Card of my emulator. I then open File Explorer and navigate to the Storage Card and click on the FakeGPS.cab file to install it. I follow the prompt and when it's done, I close File Explorer. I then go to Start menu and run Fake GPS. I enable the GPS and make sure that it has the fake GPS text file data selected and then click Done. I'm back to the GPSID app and click on GPS On and voila! I see that this sample app is working and "receiving" and displaying GPS data successfully. When I close the emulator, it prompts me if I want to save the emulator state before exiting. To save the trouble of having to redo all these configuration steps, I choose Yes.

Well this concludes the setup and testing of my setup. My next step is to figure out what I want to accomplish with my application, come up with a design and start designing the framework and UI for it.

Until next time,

Sebastien Limoges

Wednesday, November 19, 2008

Golf GPS Application with Satellite imagery for Mobile Devices

This is my blog about my attempt to create a golf application that will not only give me basic numerical information of where I am in regards to the green and other obstacles, but also a satellite view of where it is I am in relation to the green and other obstacles.

Come back to see information on my progress (or lack thereof) in my attempt to complete this project.