Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- CHROME_BIN=/opt/google/chrome/chrome
- function exit_with_error {
- if [ "$GUI" ]; then
- zenity --error --text "$1"
- else
- echo "$1" >&2
- fi
- exit 1
- }
- # Parses the output of exif and returns three numbers separated by a space.
- function parse_coords_output {
- echo -n "$1" | head -n 1 | sed "s/\s*//g" | sed "s/,/ /g"
- }
- function dms_to_decimal {
- eval "DMS=($1)"
- FORMULA="${DMS[0]} + ((${DMS[1]} * 60) + ${DMS[2]}) / 3600"
- echo "scale=7; $FORMULA" | bc
- }
- if [ ! $# -eq 1 ]; then
- exit_with_error "Expected one argument"
- elif [ ! -f "$1" ]; then
- exit_with_error "File doesn't exist: $1"
- fi
- RAW_LATITUDE=$(exif "$1" -t GPSLatitude -m 2>&1)
- RAW_LONGITUDE=$(exif "$1" -t GPSLongitude -m 2>&1)
- if [ ! $? -eq 0 ]; then
- exit_with_error "Couldn't find any coordinate metadata"
- fi
- LAT=$(dms_to_decimal "$(parse_coords_output "$RAW_LATITUDE")")
- LNG=$(dms_to_decimal "$(parse_coords_output "$RAW_LONGITUDE")")
- URL="http://maps.google.com/?q=loc:$LAT,$LNG"
- $CHROME_BIN $URL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement