-
Notifications
You must be signed in to change notification settings - Fork 0
/
photos-to-map.sh
executable file
·30 lines (23 loc) · 1.52 KB
/
photos-to-map.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
set -e
IFS=$'\t'
cat "$(dirname "${0}")/prefix.xml"
while read -r Directory FileName GPSLatitude GPSLongitude GPSAltitude GPSDateTime; do
if [ "-" == "${GPSLatitude}" -o "-" == "${GPSLongitude}" -o "-" == "${GPSDateTime}" ]; then
continue
fi
before=$(date -d @"$(( $(date -d "${GPSDateTime:0:10}Z" '+%s') - 86400 ))" --utc +%F)
after=$(date -d @"$(( $(date -d "${GPSDateTime:0:10}Z" '+%s') + 86400 ))" --utc +%F)
filter="${before}%20-%20${after}"
coordinates="${GPSLongitude},${GPSLatitude}"
if ! [ -z "${GPSAltitude}" ]; then
coordinates="${coordinates},${GPSAltitude}"
fi
echo " <Placemark>"
echo " <name>[${GPSDateTime:0:10}] ${FileName}</name>"
echo " <description><![CDATA[<p><a href=\"https://photos.google.com/search/${GPSDateTime:0:10}%20${FileName}\"><img height='200px' src='${Directory}/${FileName}' /></a></p><p><a href=\"https://photos.google.com/search/${filter}\">Days</a>, <a href=\"https://photos.google.com/search/${GPSDateTime:0:10}\">Day</a>, <a href=\"https://photos.google.com/search/${GPSDateTime:0:10}%20${FileName}\">Exact</a></p><p>${Directory}/<b>${FileName}</b></p><p><b>Date:</b> ${GPSDateTime}</p>]]></description>"
echo " <styleUrl>#mainStyleMap</styleUrl>"
echo " <Point><coordinates>${coordinates}</coordinates></Point>"
echo " </Placemark>"
done <<< "$(exiftool -c "%+.6f" -Directory -FileName -GPSLatitude# -GPSLongitude# -GPSAltitude# -GPSDateTime -dateFormat "%Y-%m-%dT%H:%M:%S%z" -T -args -ex -r "${1:-.}")"
cat "$(dirname "${0}")/suffix.xml"