easy-osm2city/create-project

158 lines
3.9 KiB
Text
Raw Normal View History

#! /bin/bash
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-p|--project)
project="$2"
shift # past argument
shift # past value
;;
-h|--help)
echo "usage: create-project -p <project> [OPTIONS]"
echo "Creates a new project with all necesary files."
echo ""
echo "OPTIONS"
echo " -p, --project Mandatory, project name which you want to clear of chache files."
echo " -h, --help Shows this help and exit"
exit 0
;;
*)
echo "Unknown option $key"
exit 1
;;
esac
done
if [ -z "$project" ]; then
echo "Option -p <project> is mandatory"
exit 1
fi
if [ -f "projects/$project/params.ini" ]; then
echo "The project was already created"
exit 1
fi
source general-settings > /dev/null
if [ $? == 1 ]; then
echo "Couldn't find the general settings. Please run ./install first."
exit 1
fi
if [ ! -f ".databases" ]; then
echo "There are no databases created by easy-osm2city. Please create one by running ./create-db"
exit 1
fi
echo "Which database do you want to use?"
read db_name
cat .databases | grep -e "$db_name" > /dev/null
if [ $? == 1 ]; then
echo "Database doesn't exsist. Please choose a different database or create one by running"
echo "./create-db -d $db_name"
exit 1
fi
mkdir -p "projects/$project/scenery"
echo "PREFIX = '$project'" > "projects/$project/params.ini"
echo "PATH_TO_SCENERY = '$fg_scenery'" >> "projects/$project/params.ini"
echo "PATH_TO_OUTPUT = '$(pwd)/projects/$project/scenery'" >> "projects/$project/params.ini"
echo "PATH_TO_OSM2CITY_DATA = '$(pwd)/osm2city-data'" >> "projects/$project/params.ini"
echo "" >> "projects/$project/params.ini"
echo "NO_ELEV = False" >> "projects/$project/params.ini"
echo "FG_ELEV = '$fg_elev'" >> "projects/$project/params.ini"
echo "" >> "projects/$project/params.ini"
echo "DB_HOST = '$db_host'" >> "projects/$project/params.ini"
echo "DB_PORT = '$db_port'" >> "projects/$project/params.ini"
echo "DB_NAME = '$db_name'" >> "projects/$project/params.ini"
echo "DB_USER = '$db_user'" >> "projects/$project/params.ini"
echo "DB_USER_PASSWORD = '$db_passwd'" >> "projects/$project/params.ini"
echo "" >> "projects/$project/params.ini"
echo "POINTS_ON_LINE_DISTANCE_MAX = 20" >> "projects/$project/params.ini"
echo "HIGHWAY_TYPE_MIN = 3" >> "projects/$project/params.ini"
pass=0
while [ $pass == 0 ]
do
echo "What is the WESTside boundary of the area?"
read west
case $west in
''|*[!-0-9]*)
echo "Value is no number."
;;
*)
pass=1
;;
esac
done
pass=0
while [ $pass == 0 ]
do
echo "What is the SOUTHside boundary of the area?"
read south
case $south in
''|*[!-0-9]*)
echo "Value is no number."
;;
*)
pass=1
;;
esac
done
pass=0
while [ $pass == 0 ]
do
echo "What is the EASTside boundary of the area?"
read east
case $east in
''|*[!-0-9]*)
echo "Value is no number."
;;
*)
pass=1
;;
esac
done
pass=0
while [ $pass == 0 ]
do
echo "What is the NORTHside boundary of the area?"
read north
case $north in
''|*[!-0-9]*)
echo "Value is no number."
;;
*)
pass=1
;;
esac
done
if [ "$west" -lt "0" ]; then
echo "bounds=*${west}_${south}_${east}_${north}" > projects/$project/settings
else
echo "bounds=${west}_${south}_${east}_${north}" > projects/$project/settings
fi