mirror of
https://github.com/Brandon-Rozek/website.git
synced 2024-11-09 10:40:34 -05:00
Added scripts to grab EXIF GPS data and create WPT GPX
This commit is contained in:
parent
220f2b7571
commit
980ac04f51
3 changed files with 97 additions and 0 deletions
27
LLA2WPT.sh
Executable file
27
LLA2WPT.sh
Executable file
|
@ -0,0 +1,27 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
show_usage() {
|
||||
echo "Usage: LLA2WPT.sh [LAT] [LON] [ALT] [?NAME]"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Check argument count
|
||||
if [ "$#" -ne 3 ] | [ "$#" -ne 4 ]; then
|
||||
show_usage
|
||||
fi
|
||||
|
||||
|
||||
LAT="$1"
|
||||
LON="$2"
|
||||
ALT="$3"
|
||||
NAME=${4-""}
|
||||
|
||||
echo "<wpt lat=\"$LAT\" lon=\"$LON\">"
|
||||
echo -e "\t<ele>$ALT</ele>"
|
||||
echo -e "\t<name>$4</name>"
|
||||
echo "</wpt>"
|
||||
|
46
getLLA.sh
Executable file
46
getLLA.sh
Executable file
|
@ -0,0 +1,46 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
show_usage() {
|
||||
echo "Usage: getLLA.sh [imagefile]"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Check argument count
|
||||
if [ "$#" -ne 1 ]; then
|
||||
show_usage
|
||||
fi
|
||||
|
||||
# Check that relevant command exist
|
||||
if ! command -v identify > /dev/null; then
|
||||
echo "Command identify from imagemagick not found. Exiting..."
|
||||
fi
|
||||
|
||||
IMAGE_FILE="$1"
|
||||
LAT=$(identify -format "%[EXIF:GPSLatitude]\n" "$IMAGE_FILE")
|
||||
LAT_DIR=$(identify -format "%[EXIF:GPSLatitudeRef]\n" "$IMAGE_FILE")
|
||||
LON=$(identify -format "%[EXIF:GPSLongitude]\n" "$IMAGE_FILE")
|
||||
LON_DIR=$(identify -format "%[EXIF:GPSLongitudeRef]\n" "$IMAGE_FILE")
|
||||
ALT=$(identify -format "%[EXIF:GPSAltitude]\n" "$IMAGE_FILE")
|
||||
|
||||
DegreesToDecimal() {
|
||||
L0=$(echo "$1" | cut -d "," -f 1)
|
||||
L1=$(echo "$1" | cut -d "," -f 2)
|
||||
L2=$(echo "$1" | cut -d "," -f 3)
|
||||
echo "scale=6;$L0 + $L1/60 + $L2/3600" | bc
|
||||
}
|
||||
|
||||
LAT_DEC=$(DegreesToDecimal "$LAT")
|
||||
LON_DEC=$(DegreesToDecimal "$LON")
|
||||
ALT_DEC=$(echo "scale=6;$ALT" | bc)
|
||||
|
||||
LAT_PREFIX=$([ $LAT_DIR == "S" ] && echo "-" || echo "")
|
||||
LON_PREFIX=$([ $LON_DIR == "W" ] && echo "-" || echo "")
|
||||
|
||||
echo "$LAT_PREFIX$LAT_DEC"
|
||||
echo "$LON_PREFIX$LON_DEC"
|
||||
echo "$ALT_DEC"
|
||||
|
24
getWPT.sh
Executable file
24
getWPT.sh
Executable file
|
@ -0,0 +1,24 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
show_usage() {
|
||||
echo "Usage: getWPT.sh [imagefile] [?name]"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Check argument count
|
||||
if [ "$#" -ne 1 ]; then
|
||||
show_usage
|
||||
fi
|
||||
|
||||
getLLA="$(dirname $0)/getLLA.sh"
|
||||
LLA=$("$getLLA" "$1")
|
||||
IMAGE_NAME=$(basename "$1")
|
||||
NAME_ARG=${2-""}
|
||||
NAME=$([ "$NAME_ARG" != "" ] && echo "$NAME_ARG" || echo "$IMAGE_NAME")
|
||||
|
||||
echo -e "$LLA\n$NAME" | xargs $(dirname $0)/LLA2WPT.sh
|
||||
|
Loading…
Reference in a new issue