summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--doc/tag-photo.bash6
1 files changed, 3 insertions, 3 deletions
diff --git a/doc/tag-photo.bash b/doc/tag-photo.bash
index 83f10fd..5917f12 100644
--- a/doc/tag-photo.bash
+++ b/doc/tag-photo.bash
@@ -21,33 +21,33 @@ wps_locate() {
RV="$(xmlstarlet sel -N w=http://skyhookwireless.com/wps/2005 -t -m '/w:LocationRS/w:location/*' -o wl_ -v 'name()' -o '=' -v 'text()' -o ' ' - <<<"$X")"
sqlite3 "$LCACHE" "INSERT INTO lc (k,v) VALUES ('$APSKEY','$RV')" &>/dev/null
echo "$RV"
return 0
}
ts="$(TZ=UTC date +%s -d "$(exiftime -tc "$JPG"|cut -d\ -f3-|sed -e s/:/-/ -e s/:/-/)")"
APS="$(gawk <"$LOG" -F, -v ts="$ts" -- '
BEGIN { nap=0; }
$3=="NEWPHOTO" && $2>ts { pdt=$1; nextfile; }
$3=="AP" || $3=="NEWAP" {
n = ($4 in ap) ? ap[$4] : nap;
ap_dt[n] = $1; ap_ap[n]=$4; ap_rssi[n]=$5;
if(n==nap) ap[$4] = nap++;
}
$3=="POWERON" { nap=0; delete ap_dt; delete ap_ap; delete ap_rssi; delete ap; }
END {
for(i=0;i<nap;++i) {
if((pdt-ap_dt[i])>1800) continue;
printf("<access-point><mac>%s</mac><signal-strength>-%d</signal-strength></access-point>\n",ap_ap[i],ap_rssi[i]);
}
}
')"
-[[ -z "$APS" ]] && { echo "no access points" ; exit ; }
+[[ -z "$APS" ]] && { echo "no access points" ; return 2>/dev/null || exit ; }
WL="$(wps_locate "$APS")"
-[[ -z "$WL" ]] && { echo "couldn't find location" ; exit ; }
+[[ -z "$WL" ]] && { echo "couldn't find location" ; return 2>/dev/null || exit ; }
eval "$WL"
-[[ -z "$wl_latitude" || -z "$wl_longitude" || -z "$wl_hpe" ]] && { echo "invalid location ($WL)"; exit; }
+[[ -z "$wl_latitude" || -z "$wl_longitude" || -z "$wl_hpe" ]] && { echo "invalid location ($WL)"; return 2>/dev/null || exit; }
[[ "${wl_latitude:0:1}" = '-' ]] && wl_latitude="${wl_latitude:1}" wl_latitude_ref=S || wl_latitude_ref=N
[[ "${wl_longitude:0:1}" = '-' ]] && wl_longitude="${wl_longitude:1}" wl_longitude_ref=W || wl_longitude_ref=E
exiftool -GPSLatitude="$wl_latitude" -GPSLongitude="$wl_longitude" -GPSLatitudeRef=$wl_latitude_ref -GPSLongitudeRef=$wl_longitude_ref -GPSVersionID=0.0.2.2 -GPSProcessingMethod=WLAN "$JPG"
# XXX: exiftool doesn't like it -GPSHPositioningError="$wl_hpe"