easy-osm2city/create-project

89 lines
2.5 KiB
Text
Raw Normal View History

#! /bin/bash
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 $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"
echo "What is the WESTside boundary of the area?"
read west
echo "What is the SOUTHside boundary of the area?"
read south
echo "What is the EASTside boundary of the area?"
read east
echo "What is the NORTHside boundary of the area?"
read north
# TODO write settings file and check if input is correct