[Patch] Support KML files from Google Location History

Started by esm, November 13, 2013, 01:38:41 PM

Previous topic - Next topic

esm

Google Location Services[1] generates KML that exiftool can't grok. The attached patch + sample data + test case demonstrates the problem. My fix (massaging spaces into commas) is not ideal but does not require reworking the main 'split' logic.

[1] https://maps.google.com/locationhistory/b/0/

Thanks for exiftool. I think I'm going to find it very useful.

Phil Harvey

Wow.  I think this is the first time anyone has ever submitted a patch that included a test.

Well done!

This patch will be included in ExifTool 9.41.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Phil Harvey

I made one small change to ensure that the massaging of spaces doesn't break anything else:

-          s/(-?\d+\.\d+)\s+(-?\d+\.\d+)\s+(\d+)/$1,$2,$3/;
+          s{(\S+)\s+(\S+)\s+(\S+)(</gx:coord>)}{$1,$2,$3$4};


I hope this is OK.

Also, the last gx:coord in t/images/Geotag.kml was missing a space before the altitude, so I added it.

Thanks again for this patch!

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

esm

Oh, nice. That's much safer than mine, as well as more maintainable.

The missing space was the result of a botched perl -pi.BAK I ran to sanitize the coordinates. Thanks for catching that, as well as for your prompt responses.