#!/usr/bin/awk -f # # makekmlgallery -- make KML gallery from GPS data in EXIF # # usage: ls *.jpg | makekmlgallery > my.kml # (see below for more examples) # # http://www.heikopurnhagen.net/software/makekmlgallery # # This program is available under the terms of the GNU General Public # License (GPL). All usual disclaimers apply! # # requires exiftool # http://www.sno.phy.queensu.ca/~phil/exiftool/ # requires a gallery generated by makehtmlgallery7 # http://www.heikopurnhagen.net/software/makehtmlgallery7 # # Heiko Purnhagen (mail@heikopurnhagen.net) # HP 20090615 BEGIN { if (ARGC==1) { print "usage: \\ls *.jpg | makekmlgallery title=\"Summer 99\" srcdir=\".\" keepgps=1 linkbase=http://www.site.net/summer key=_all > my.kml" > "/dev/stderr"; print "" > "/dev/stderr"; } title = "makekmlgallery"; srcdir = "."; keepgps = 0; oldcoord = ""; linkbase = ""; key = ""; } { if (NR==1) { print "\n\ \n\ \n\ " title ""; } img = $1; captionstart = length($1)+2; if (match($2,"[0-9+\\-]")) { captionstart += length($2)+1; } imgcaption = substr($0,captionstart); imgurl = linkbase "/" img key "_.html"; strlatlon = ""; stralt = ""; getlla = "exiftool -S -GPSPosition -c '%f' -GPSAltitude " srcdir "/" img; getlla | getline strlatlon; getlla | getline stralt; close(getlla); split(strlatlon,latlon); split(stralt,alt); coord = ""; if (latlon[1]=="GPSPosition:") { if (latlon[5]=="W") { coord = coord "-"; } coord = coord latlon[4] ","; if (latlon[3]=="S") { coord = coord "-"; } coord = coord latlon[2]; if (alt[1]=="GPSAltitude:") { coord = coord "," alt[2]; } } if (latlon[1]=="GPSPosition:" || keepgps) { if (latlon[1]!="GPSPosition:") { coord = oldcoord; } } if (coord != "") { print " \n\ \n\ " img "\n\ \n\ \n\ " imgurl "\n\
\n\
\n\
\n\ ]]>\n\
\n\ #" img "\n\ \n\ clampedToGround\n\ " coord "\n\ \n\
"; } oldcoord = coord; } END { print "
\n\
"; } #--