#!/bin/bash
QUERY="mysql -u ssrn -pLife1234 ssrn -e "
good_params=2
until [ ! -z $STATE_NAME ] &&
	[ $R_LATITUDE  ] &&
	[ $L_LATITUDE ] &&
	[ $R_LONGITUDE ] &&
	[ $L_LONGITUDE ] && [ $good_params -eq 0 ]
do

echo "Please type the OMC server state name and coordinates as follows: (with commas)"
echo "***********************************************************************************"
echo "coordinates ranges are 18 to 75 in lower/upper latitude and -165 to -55 in left/right longitude."
echo "Right limit longitude value needs to be in a higher value than the left value."
echo "Upper limit latitude value needs to be in a lower value than the right value."
echo "Longitude coordinates values must be enter as negative number "
echo "If the coordinates that you have entered are not in the USA coordinates range, "
echo "Florida state coordinates will be used."
echo "***********************************************************************************"
echo "STATE NAME, LEFT UPPER LATITUDE, LEFT UPPER LONGITUDE, RIGHT LOWER LATITUDE, RIGHT LOWER LONGITUDE"


read ANS

echo $ANS > /tmp/some_file

VAR=(`cat /tmp/some_file | tr ',' ' ' `)

STATE_NAME=${VAR[0]}
L_LATITUDE=${VAR[1]} #UPPER
L_LONGITUDE=${VAR[2]}
R_LATITUDE=${VAR[3]} #LOWER
R_LONGITUDE=${VAR[4]}



$QUERY "UPDATE state SET state_name='$STATE_NAME' , r_latitude=$R_LATITUDE , l_latitude=$L_LATITUDE , r_longitude=$R_LONGITUDE , l_longitude=$L_LONGITUDE WHERE state_id=1 ;" #2>>/tmp/some_err
good_params=$?
done




rm -f /tmp/some_err


