#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP#!/bin/bash
SCRIPT="Generate Maps"
WORKING_DIRECTORY=/workspace/Graphhopper_Files

OK_RESPONSE () {
    whiptail --title "$SCRIPT" --msgbox "$MESSAGE" 15 120
}

INFO_BOX () {
    TERM=ansi whiptail --title "$SCRIPT" --infobox "$MESSAGE" 15 120
}

YES_NO_RESPONSE () {
    whiptail --title "$SCRIPT" --yesno "$MESSAGE" 15 120
}


TEXT_INPUT () {
    OUTPUT=$(whiptail --title "$SCRIPT" --inputbox "$MESSAGE" 8 80 "$PLACEHOLDER"  3>&1 1>&2 2>&3)            
}

BUILD_MAP () {
    echo "NAME: $NAME"
    echo "COORDINATES: $COORDINATES"
    {
        echo 0
        mkdir ${WORKING_DIRECTORY}/${REGION}/${NAME}
        echo 5
        if OUTPUT=$(osmconvert ${WORKING_DIRECTORY}/${REGION}/${MAP} -b=${COORDINATES} -o=${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm 2>&1); then
            echo "An error occured during the first OSM convert (Part 1), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 45
        if OUTPUT=$(osmosis --read-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.osm --tf accept-ways highway=* --used-node --write-xml ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm 2>&1); then
            echo "An error occured in Osmosis (Part 2), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 90
        if OUTPUT=$(osmconvert --out-pbf ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}roads.osm > ${WORKING_DIRECTORY}/${REGION}/${NAME}/${NAME}.pbf 2>&1); then
            echo "An error occured during the second OSM convert (Part 3), Exiting."
            echo "$OUTPUT"
            exit 1
        fi
        echo 100
    } | whiptail --gauge "Please wait while the maps generate..." 6 50 0
}

# START OF SCRIPT
if ! OUTPUT=$(ls -1 /workspace/Graphhopper_Files 2>&1); then
    echo "Your directory structure is not correct, exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the name for this map."; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    NAME=$( echo $OUTPUT | awk '{print tolower($0)}' | sed 's/ /_/g')
else
    echo "The user did not enter a name. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the Region. (usa, europe)"; PLACEHOLDERR=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    REGION=$( echo $OUTPUT | awk '{print tolower($0)}')
    if [[ $REGION == "usa" ]]; then
        MAP="us-latest.osm.pbf"
    elif [[ $REGION == "usa" ]]; then
        MAP="europe-latest.osm.pbf"
    else
        echo "The user did not enter a valid region. Exiting"
        exit 1
    fi
else
    echo "The user did not enter a region. Exiting"
    exit 1
fi

OUTPUT=/dev/null
MESSAGE="Enter the coordinates for this map."; PLACEHOLDER=""; TEXT_INPUT
if [[ ! -z $OUTPUT ]]; then
    COORDINATES=$OUTPUT
else
    echo "The user did not enter the coordinates. Exiting"
    exit 1
fi

if [[ $(echo $COORDINATES | sed 's/,/\n/g' | wc -l) != 4 ]]; then
    echo "The user did not enter valid coordinates. Exiting"
    exit 1
fi

MESSAGE="Please confirm the following details.\n\nNAME: $NAME\nREGION: $REGION\nCOORDINATES: $COORDINATES";
if ! YES_NO_RESPONSE; then
    echo "User selected not to continue, exiting!"
    exit 1
fi

BUILD_MAP
