Printer Friendly Version      Send     
Click to Rate and Give Feedback
Related Articles
We introduce you to the benefits of building composite applications with the Composite Application Guidance for WPF from Microsoft patterns & practices.

By Glenn Block (September 2008)
ADO.NET Data Services provide Web-accessible endpoints that allow you to filter, sort, shape, and page data without having to build that functionality yourself.

By Shawn Wildermuth (September 2008)
See how routed events and routed commands in Windows Presentation Foundation form the basis for communication between the parts of your UI.

By Brian Noyes (September 2008)
Technology changes at a lightening-fast pace. This month Howard Dierking considers how the rapid changes affect developer priorities and magazine focus.

By Howard Dierking (September 2008)
More ...
Articles by this Author
As the thermometer rises, we cool down with a look at AJAX technologies.

By Joshua Trupin (September 2007)
Does mobility come from a motorized scooter, a cell phone, or a Pocket PC? It depends on who you are.

By Joshua Trupin (July 2007)
Ruminations on ten years of Visual Studio.

By Joshua Trupin (June 2007)


By Joshua Trupin (May 2007)
Josh Trupin discusses MSDN Magazine's awards from the Society for Technical Communication

By Joshua Trupin (April 2007)


By Joshua Trupin (March 2007)
Nothing’s more disappointing than clever design paired with poor implementation. Bluetooth headsets come to mind: they’re tiny, wireless, and cute. But, they don’t pair properly, they turn on when you want them off, or off when you want them on.

By Joshua Trupin (February 2007)
Josh Trupin revs the engine to get us all ready for Windows Vista.

By Joshua Trupin (January 2007)
More ...
Popular Articles
In this excerpt from his upcoming book, Laurence Moroney explains the basics of Silverlight animation and the animation tools available in Expression Blend.

By Lawrence Moroney (August 2008)
If you're unfamiliar with Windows Presentation Foundation (WPF), building that first Silverlight custom control can be a daunting experience. This article walks through the process.

By Jeff Prosise (August 2008)
In this article we introduce you to BizTalk Services, new technology that offers the Enterprise Service Bus features of BizTalk Server as a hosted service.

By Jon Flanders and Aaron Skonnard (June 2008)
One-time passwords offer solutions to dictionary attacks, phishing, interception, and lots of other security breaches. Here's how it all works.

By Dan Griffin (May 2008)
More ...
Read the Blog
SQL Server 2008 supports a new data type, HierarchyID, that helps solve some of the problems in modeling and querying hier­archical information. In the September 2008 issue of MSDN Magazine, Kent Tegels introduces you to the ...
Read more!
Many people using SharePoint technologies don't realize that there is auditing support built directly into the Windows SharePoint Services (WSS) 3.0 platform. In the September 2008 issue of MSDN Magazine, Ted Pattison walks you through a ...
Read more!
The September 2008 issue of MSDN Magazine is now available online. Here's what's in the issue: Hierarchy ID: Model ...
Read more!
Silverlight 2 features a rich and robust control model that is the basis for the controls included in the platform and for third-party control packages. You can also use this control model to build controls of your own. In the August 2008 issue of MSDN Magazine, Jeff Prosise describes how to ...
Read more!
In the August 2008 issue of MSDN Magazine, Matt Milner covers several topics regarding development with Windows Workflow Foundation, some that are intended to address specific reader questions, such as how to safely share a persistence database ...
Read more!
LINQ is a powerful tool enabling quick filtering data based on a standard query language. It can tear through a structured set of data using a simple and straightforward syntax. In the August 2008 issue of MSDN Magazine, Jared Parsons demonstrates a ...
Read more!
More ...
{ End Bracket }
Geopegging
Joshua Trupin

Code download available at: EndBracket2007_04.exe (174 KB)
Browse the Code Online

As part of my birthday haul last year, I received a gem of a gift: a new camera. And not just any camera, either. It was a new Nikon D200.
One of the features that really grabbed my interest was its built-in GPS capabilities. If you had a standard serial-port GPS device, you could plug it into the camera via a converter cable and location data would be written into each shot you took.
The problem was that the serial-port GPS receivers I owned were museum pieces that didn't work with the camera, and new GPS devices tend to have USB connections. Arrgh! I decided to take the most foolhardy plunge since I bought fajitas at a Manhattan street fair two years ago. I created my own homebrew solution out of OEM parts. To make a long story short, it actually worked. If you want the heartstopping play-by-play, you can find it at my blog.
Geopegging Adds GPS Location Data to a JPG(Click the image for a larger view)
I've been putting my photos up on my hosting site, trupin.smugmug.com. Smugmug has a nice feature that automatically maps all your tagged photos, and even though it used Google Earth, I liked it. But I knew I could take this idea a step further. Hundreds, perhaps thousands, of photos could soon be turned from throwaway snapshots into vitally important records of time and place. Adding location data to photos is known as geotagging, but my program would extend that term with a slightly more specific concept, "geopegging."
Geopegging, which is now defined as "adding GPS location data to a JPG through a map-based interface," is a concept that took a few steps to drag into reality. First, I had to figure out where the geo data actually went inside a JPG file. There's surprisingly little information about this online, but I used a variety of sources and the power of the Microsoft® .NET Framework to create a simple EXIF editor. If you want to find the camera's lens aperture at the time of the photo, you look at the field tagged 0x9202. It turns out that the GPS data all goes in tags numbered 0 through 8. This didn't fill me with confidence, because I imagined someone choosing the first numbers they could think of, well after the fact. The Framework includes a GetPropertyItem member in the System.Drawing.Image class, so it's easy to extract header data if you know the EXIF tag value.
Next, I wrote a program that hosted Microsoft Internet Explorer® inside a Windows® Forms app so that I could display Virtual Earth™ and allow a user to select the location to be added to a photo. That was a bit easier. The fun part was getting Virtual Earth working within a frame of my desktop app so that it could communicate back and forth with the Windows Forms code in the app. This part involves a bit of JavaScript inside the window plus some tricks (documented in the Virtual Earth online help) that gets the two parts of the program talking to one another.
The trick here is to wire up the WebBrowser control with some script through its DocumentText property. You use AttachEvent to call a script function when the browser control is clicked; this function then calls window.external.YourFunctionName and passes it a string.
There's more complexity, including handling the Virtual Earth control properly, converting values, and writing to the JPG file. I've put my basic geopegging program up as a download and invite you to take a look at it. Now I've got a world full of tagged photos, and I can update them any time I want. I don't need the homemade GPS device at all...but I still use it, if only to show off a bit.

Joshua Trupin is the Executive Editor of MSDN Magazine and TechNet Magazine.

© 2008 Microsoft Corporation and CMP Media, LLC. All rights reserved; reproduction in part or in whole without permission is prohibited.
Page view tracker