mirror of
https://github.com/alexanderepstein/Bash-Snippets
synced 2018-11-08 02:59:35 +01:00
Added ability to grab static map of location and route map of route
This commit is contained in:
parent
684a962eb3
commit
c17839f558
44
maps/maps
44
maps/maps
@ -5,7 +5,7 @@ currentVersion="1.11.0"
|
||||
configuredClient=""
|
||||
configuredPython=""
|
||||
source ~/.bash_profile ## allows grabbing enviornment variable
|
||||
apiKey=$MAPQUEST_API_KEY
|
||||
MAPQUEST_API_KEY=$MAPQUEST_API_KEY
|
||||
|
||||
## This function determines which http get tool the system has installed and returns an error if there isnt one
|
||||
getConfiguredClient()
|
||||
@ -105,7 +105,7 @@ update()
|
||||
fi
|
||||
}
|
||||
|
||||
#first direction not grepped correctly cannot grep distances correctly all other directionms are grepped correctly.
|
||||
|
||||
getDirections()
|
||||
{
|
||||
response=$(httpGet "https://www.mapquestapi.com/directions/v2/route?key=$MAPQUEST_API_KEY&from=$1&to=$2&outFormat=json&ambiguities=ignore&routeType=fastest&doReverseGeocode=false&enhancedNarrative=true&avoidTimedConditions=false")
|
||||
@ -126,7 +126,25 @@ getDirections()
|
||||
done
|
||||
#for distance in $tempDistances
|
||||
directions[0]=$firstDirection
|
||||
}
|
||||
|
||||
getDirectionsMap()
|
||||
{
|
||||
echo "Generating route map from $1 to $2"
|
||||
if [[ "$OSTYPE" == "linux"* ]];then
|
||||
if command -v display &>/dev/null ;then
|
||||
mkdir ~/temp || return 1
|
||||
httpGet "https://www.mapquestapi.com/staticmap/v5/map?start=$1&end=$2&size=600,400@2x&key=$MAPQUEST_API_KEY" >> ~/temp/routeImage.png || return 1
|
||||
display ~/temp/routeImage.png > /dev/null || return 1
|
||||
else
|
||||
echo "To use the map image features you must install imagemagick"
|
||||
fi
|
||||
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
mkdir ~/temp
|
||||
httpGet "https://www.mapquestapi.com/staticmap/v5/map?start=$1&end=$2&size=600,400@2x&key=$MAPQUEST_API_KEY" >> ~/temp/routeImage.png || return 1
|
||||
open ~/temp/routeImage.png > /dev/null
|
||||
fi
|
||||
rm -rf ~/temp > /dev/null
|
||||
}
|
||||
|
||||
printDirections()
|
||||
@ -154,8 +172,30 @@ printDirections()
|
||||
echo
|
||||
}
|
||||
|
||||
|
||||
getStaticMap()
|
||||
{
|
||||
echo "Generating static map for $1"
|
||||
if [[ "$OSTYPE" == "linux"* ]];then
|
||||
if command -v display &>/dev/null ;then
|
||||
mkdir ~/temp || return 1
|
||||
httpGet "https://www.mapquestapi.com/staticmap/v5/map?key=$MAPQUEST_API_KEY¢er=$1&zoom=15&type=hyb&size=600,400@2x" >> ~/temp/mapImage.png || return 1
|
||||
display ~/temp/mapImage.png > /dev/null || return 1
|
||||
else
|
||||
echo "To use the map image features you must install imagemagick"
|
||||
fi
|
||||
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
mkdir ~/temp || return 1
|
||||
httpGet "https://www.mapquestapi.com/staticmap/v5/map?key=$MAPQUEST_API_KEY¢er=$1&zoom=15&type=hyb&size=600,400@2x" >> ~/temp/mapImage.png || return 1
|
||||
open ~/temp/mapImage.png > /dev/null || return 1
|
||||
fi
|
||||
rm -rf ~/temp > /dev/null || return 1
|
||||
}
|
||||
|
||||
getConfiguredPython || exit 1
|
||||
getConfiguredClient || exit 1
|
||||
checkInternet || exit 1
|
||||
getDirections Denver Boulder || exit 1
|
||||
printDirections Denver Boulder || exit 1
|
||||
getDirectionsMap Denver Boulder || exit 1
|
||||
getStaticMap Paramus || exit 1
|
||||
|
Loading…
Reference in New Issue
Block a user