Added ability to grab static map of location and route map of route
This commit is contained in:
parent
684a962eb3
commit
c17839f558
64
maps/maps
64
maps/maps
|
@ -5,7 +5,7 @@ currentVersion="1.11.0"
|
||||||
configuredClient=""
|
configuredClient=""
|
||||||
configuredPython=""
|
configuredPython=""
|
||||||
source ~/.bash_profile ## allows grabbing enviornment variable
|
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
|
## This function determines which http get tool the system has installed and returns an error if there isnt one
|
||||||
getConfiguredClient()
|
getConfiguredClient()
|
||||||
|
@ -105,17 +105,17 @@ update()
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
#first direction not grepped correctly cannot grep distances correctly all other directionms are grepped correctly.
|
|
||||||
getDirections()
|
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")
|
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")
|
||||||
firstDirection=$(echo $response | grep -Eo "origNarrative\":\"[a-Z -./0-9]*" | grep -Eo "[^origNarrative\":][a-Z -./0-9]*" )
|
firstDirection=$(echo $response | grep -Eo "origNarrative\":\"[a-Z -./0-9]*" | grep -Eo "[^origNarrative\":][a-Z -./0-9]*" )
|
||||||
tempDirections=($(echo $response | grep -Eo "\"narrative\":\"[a-Z -./0-9]*"))
|
tempDirections=($(echo $response | grep -Eo "\"narrative\":\"[a-Z -./0-9]*"))
|
||||||
distances=($(echo $response | grep -Eo "distance\":[0-9]*[.][0-9]*" | grep -Eo "[^distance\":][0-9]*[.][0-9]*" ))
|
distances=($(echo $response | grep -Eo "distance\":[0-9]*[.][0-9]*" | grep -Eo "[^distance\":][0-9]*[.][0-9]*" ))
|
||||||
count="-1"
|
count="-1"
|
||||||
temp=${tempDirections[0]}
|
temp=${tempDirections[0]}
|
||||||
for direct in "${tempDirections[@]}"
|
for direct in "${tempDirections[@]}"
|
||||||
do
|
do
|
||||||
if [[ $(echo $direct | grep -Eo "narrative" ) == "narrative" ]];then
|
if [[ $(echo $direct | grep -Eo "narrative" ) == "narrative" ]];then
|
||||||
count=$(echo $count + 1 | bc )
|
count=$(echo $count + 1 | bc )
|
||||||
directions[$count]=$temp
|
directions[$count]=$temp
|
||||||
|
@ -124,9 +124,27 @@ getDirections()
|
||||||
temp="$temp $direct"
|
temp="$temp $direct"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
#for distance in $tempDistances
|
#for distance in $tempDistances
|
||||||
directions[0]=$firstDirection
|
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()
|
printDirections()
|
||||||
|
@ -154,8 +172,30 @@ printDirections()
|
||||||
echo
|
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
|
getConfiguredPython || exit 1
|
||||||
getConfiguredClient || exit 1
|
getConfiguredClient || exit 1
|
||||||
checkInternet || exit 1
|
checkInternet || exit 1
|
||||||
getDirections Denver Boulder || exit 1
|
getDirections Denver Boulder || exit 1
|
||||||
printDirections Denver Boulder || exit 1
|
printDirections Denver Boulder || exit 1
|
||||||
|
getDirectionsMap Denver Boulder || exit 1
|
||||||
|
getStaticMap Paramus || exit 1
|
||||||
|
|
Loading…
Reference in New Issue