2018-11-13 18:21:07 +00:00
|
|
|
#! /bin/bash
|
2018-11-24 15:23:45 +00:00
|
|
|
# Copyright (C) 2018 Merspieler, merspieler _at_ airmail.cc
|
2018-11-21 20:17:10 +00:00
|
|
|
#
|
|
|
|
# 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.
|
2018-11-13 18:21:07 +00:00
|
|
|
|
2019-02-28 22:23:19 +00:00
|
|
|
first=1
|
2018-11-13 18:21:07 +00:00
|
|
|
while [[ $# -gt 0 ]]
|
|
|
|
do
|
|
|
|
key="$1"
|
|
|
|
|
|
|
|
case $key in
|
|
|
|
-h|--help)
|
2019-02-28 22:23:19 +00:00
|
|
|
echo "usage: create-project <project> [OPTIONS]"
|
2018-11-13 18:21:07 +00:00
|
|
|
echo "Creates a new project with all necesary files."
|
|
|
|
echo ""
|
|
|
|
echo "OPTIONS"
|
|
|
|
echo " -h, --help Shows this help and exit"
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
2019-02-28 22:23:19 +00:00
|
|
|
if [ $first == "1" ]; then
|
|
|
|
project="$1"
|
|
|
|
shift # past project
|
|
|
|
first=0
|
|
|
|
else
|
|
|
|
echo "Unknown option $key"
|
|
|
|
exit 1
|
|
|
|
fi
|
2018-11-13 18:21:07 +00:00
|
|
|
;;
|
|
|
|
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
|
|
|
|
|
2018-11-17 20:34:18 +00:00
|
|
|
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
|
2018-11-17 22:55:50 +00:00
|
|
|
cat .databases | grep -e "$db_name" > /dev/null
|
2018-11-17 20:34:18 +00:00
|
|
|
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
|
|
|
|
|
2018-11-13 18:21:07 +00:00
|
|
|
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"
|
2018-11-17 20:34:18 +00:00
|
|
|
echo "DB_NAME = '$db_name'" >> "projects/$project/params.ini"
|
2018-11-13 18:21:07 +00:00
|
|
|
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"
|
|
|
|
|
2018-11-17 22:53:25 +00:00
|
|
|
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
|
2018-11-13 18:21:07 +00:00
|
|
|
|
2018-11-17 22:53:25 +00:00
|
|
|
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
|