View difference between Paste ID: MJ29mt5f and 3BXH98mz
SHOW: | | - or go back to the newest paste.
1-
1+
#!/usr/bin/env bash
2-
CHROME_BIN=/opt/google/chrome/chrome
2+
3-
3+
CHROME_BIN=/opt/google/chrome/chrome
4-
function exit_with_error {
4+
5-
    if [ "$GUI" ]; then
5+
function exit_with_error {
6-
        zenity --error --text "$1"
6+
    if [ "$GUI" ]; then
7-
    else
7+
        zenity --error --text "$1"
8-
        echo "$1" >&2
8+
    else
9-
    fi
9+
        echo "$1" >&2
10-
10+
    fi
11-
    exit 1
11+
12-
}
12+
    exit 1
13-
13+
}
14-
# Parses the output of exif and returns three numbers separated by a space.
14+
15-
function parse_coords_output {
15+
# Parses the output of exif and returns three numbers separated by a space.
16-
    echo -n "$1" | head -n 1 | sed "s/\s*//g" | sed "s/,/ /g"
16+
function parse_coords_output {
17-
}
17+
    echo -n "$1" | head -n 1 | sed "s/\s*//g" | sed "s/,/ /g"
18-
18+
}
19-
function dms_to_decimal {
19+
20-
    eval "DMS=($1)"
20+
function dms_to_decimal {
21-
    FORMULA="${DMS[0]} + ((${DMS[1]} * 60) + ${DMS[2]}) / 3600"
21+
    eval "DMS=($1)"
22-
    echo "scale=7; $FORMULA" | bc
22+
    FORMULA="${DMS[0]} + ((${DMS[1]} * 60) + ${DMS[2]}) / 3600"
23-
}
23+
    echo "scale=7; $FORMULA" | bc
24-
24+
}
25-
if [ ! $# -eq 1 ]; then
25+
26-
    exit_with_error "Expected one argument"
26+
if [ ! $# -eq 1 ]; then
27-
elif [ ! -f "$1" ]; then
27+
    exit_with_error "Expected one argument"
28-
    exit_with_error "File doesn't exist: $1"
28+
elif [ ! -f "$1" ]; then
29-
fi
29+
    exit_with_error "File doesn't exist: $1"
30-
30+
fi
31-
RAW_LATITUDE=$(exif "$1" -t GPSLatitude -m 2>&1)
31+
32-
RAW_LONGITUDE=$(exif "$1" -t GPSLongitude -m 2>&1)
32+
RAW_LATITUDE=$(exif "$1" -t GPSLatitude -m 2>&1)
33-
33+
RAW_LONGITUDE=$(exif "$1" -t GPSLongitude -m 2>&1)
34-
if [ ! $? -eq 0 ]; then
34+
35-
    exit_with_error "Couldn't find any coordinate metadata"
35+
if [ ! $? -eq 0 ]; then
36-
fi
36+
    exit_with_error "Couldn't find any coordinate metadata"
37-
37+
fi
38-
LAT=$(dms_to_decimal "$(parse_coords_output "$RAW_LATITUDE")")
38+
39-
LNG=$(dms_to_decimal "$(parse_coords_output "$RAW_LONGITUDE")")
39+
LAT=$(dms_to_decimal "$(parse_coords_output "$RAW_LATITUDE")")
40-
URL="http://maps.google.com/?q=loc:$LAT,$LNG"
40+
LNG=$(dms_to_decimal "$(parse_coords_output "$RAW_LONGITUDE")")
41-
41+
URL="http://maps.google.com/?q=loc:$LAT,$LNG"
42
43
$CHROME_BIN $URL