#!/usr/bin/perl -w # # Matija Nalis mnalis-osv@voyager.hr 20091207, version 0.1, GPLv3+ # # dowloads pictures from OpenStreetView.org KML file, and fixes GPS EXIF tags on them # (because of http://github.com/johnmckerrell/OpenStreetView/issues/#issue/16 bug) # So they'll be ready to use with JOSM AgPifoJ plugin or alike... # # This is just a quick&dirty kludge to parse XML and DL instead of using appropriate modules... # should fix that someday :) (or better write JOSM plugin) # # requires perl, exiftool, wget # on Debian-alike system just do: "apt-get install perl exiftool wget" # use strict; my $kml_file = $ARGV[0]; die "Usage: $0 \n" unless $kml_file; open (KML, '<', $kml_file) or die "can't open $kml_file: $!"; my $lastfile; while () { if (/([\d\.]+),([\d\.]+)<\/coordinates>/i) { my $lon=$1; my $lat=$2; print "C: $lastfile: $lon, $lat\n"; my $lonref='E'; if ($lon < 0) { $lon=abs($lon); $lonref='W' } my $latref='N'; if ($lat < 0) { $lat=abs($lat); $latref='S' } system 'wget', '-q', $lastfile; $lastfile =~ s/^.*\///; system 'exiftool', "-exif:gpslatitude=$lat", "-exif:gpslatituderef=$latref", "-exif:gpslongitude=$lon", "-exif:gpslongituderef=$lonref", "$lastfile"; } next unless /CDATA\[/i; $lastfile = $1; } close (KML);