Extract GPS coord from Google Maps to geotag photos

This is a quick tip related to something that I just tried today and that worked.

My camera SONY DSC-HX100V has GPS capability built-in but it won't work everywhere and it needs some time to acquire the satellite signal. This way if you just want to take a quick snap you may end with photos that don’t have GPS location in their Exif metadata. GPS is a recent capability when we talk about cameras.

SONY DSC-HX100V camera with built-in GPSFigure 1 - SONY DSC-HX100V camera with built-in GPS

Taking that into consideration, let’s say you have some photos in iPhoto (Mac OS) or whatever program you use to manage your photos. I mention iPhoto here since it’s the app I use. Those photos don't have a location set due to no GPS signal available where the photos were taken. So how can one add that missing GPS location info/data on those photos? By the way, this process is called geotagging.

This is what I’ve tried and what worked perfectly in my case:

1 - Open Google Maps and find the place/point where you’ve taken the photos.

2 - Right click that place/point you want in the map and select Center Map here.

3 - Click the Link button. Black mouse pointer is over it in the screenshot bellow.

Google Maps link popup box with URL that contains GPS coordinatesFigure 2 - Google Maps link popup box with URL that contains GPS coordinates

A popup box will open. Copy the text/URL and paste it in your preferred text editor app. The link will look something like this:

http://maps.google.com/maps/ms?msid=201266260819946046546.0004a0e1b939dec67f18e&msa=0&ll=-22.428568,-44.619633&spn=0.001983,0.004128

Pay attention to the highlighted part that correspond to the longitude and latitude data.

4 - Select the photos you want in iPhoto to apply Location information and press command+I to access the Assign a Place box. Copy the highlighted text above and paste it in the box. Press the enter key to finish the task.

Adding GPS coordinates to iPhoto Assign a Place boxFigure 3 - Adding GPS coordinates to iPhoto Assign a Place box

This procedure works great when you just want to add GPS coordinates in your photos no matter if your camera has a built-in GPS or not since any photo can be geotagged nowadays.

Hope it helps!

You can check my photos in this slideshow:

ResourceManager with External Localization Assembly

As a software developer I like to work with everything that is related to software Localization known as L10n. Besides being a developer working defining the architecture that will be adopted in a given project and doing the hard “FUN” work writing the code, I’m also a translator if you don’t know it yet.

One thing I've been trying to do recently is to be able to use localized strings that are present in an external assembly [ DLL ] using the ResourceManager object.
I have localized strings in resource [ .resx ] files that are specific for each locale I support. I place these .resx files in a separate class library project to maintain things organized.

So, suppose the namespace of this class library is MyProject.L10n and the .resx file name is Localization.resx. This gives me access to a class named Localization within the code. I also have Localization.pt.resx. I support English and Portuguese locales in my project for now. This naming pattern allows me to have in the future a file called Localization.es-ES.resx for Castilian Spanish (as written and spoken in Spain) and another one called Localization.es-AR.resx for Argentine Spanish. During runtime the .NET framework will select the correct .resx file to extract the localized string from based on the current culture the user has set while browsing my website.

After adding a reference to this class library, I'm able to use this code in my ASP.NET MVC project in a Razor view:

MyProject.L10n.Localization.LocalizedString;

This works as expected, but it's not what I need, though. As you see the localized string key [ LocalizedString ] is hard coded. I want to be able to use the method GetString from the ResourceManager object so that I can write code like this:

ResourceManager.GetString(item.DynamicLocalizedStringValue);

The problem and the catchy here is that in order to use the resource manager the way I want, I have to point it to the external assembly this way:

grid.Column(
columnName: "Type",
header: Localization.Type,format: (item) => new ResourceManager("MyProject.L10n.Localization", typeof(Localization).Assembly).GetString(item.Type.ToString()))

This part does the tricky: typeof(Localization).Assembly

In the code block above I’m using WebGrid that is a new helper that comes with ASP.NET MVC 3. It simplifies the task of rendering tabular data. When I do item.Type.ToString() I’m actually getting different values for each row of my grid and I pass this dynamic value to ResourceManager that in return gives me the translated/localized version of a give string key.

Going even further I’ve implemented a Razor’s Helper method in a file called Helpers.cshtml and placed such file inside the App_Code folder. This is the helper’s code:

@using System.Resources
@using MyProject.L10n

@helper GetLocalizedString(string stringValue)
{
    ResourceManager rm = new ResourceManager("MyProject.L10n.Localization", typeof (Localization).Assembly);

    @rm.GetString(stringValue);
}

Now it’s just a matter of calling the helper this way in whatever place/view I need it:

grid.Column(
columnName: "Type",
header: Localization.Type,
format: (item) => @Helpers.GetLocalizedString(item.Type.ToString()))

The above code is way more clear than the one I showed your before…

Hope this post helps shed some light in this subject since the only thing that should be done is to get a reference to the assembly that holds the Localization class and pass it to the ResourceManger’s constructor.