2018-11-13 15:31:53 +00:00
|
|
|
#! /bin/bash
|
2018-11-21 20:17:10 +00:00
|
|
|
# Copyright (C) 2018 Merspieler, merspieler _at_ airmail.cc
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
|
2019-02-28 22:23:19 +00:00
|
|
|
first=1
|
2018-11-13 15:31:53 +00:00
|
|
|
while [[ $# -gt 0 ]]
|
|
|
|
do
|
|
|
|
key="$1"
|
|
|
|
|
|
|
|
case $key in
|
2018-11-13 17:31:24 +00:00
|
|
|
-t|--threads)
|
|
|
|
man_thread="$2"
|
|
|
|
shift # past argument
|
|
|
|
shift # past value
|
|
|
|
;;
|
|
|
|
|
2018-11-13 15:31:53 +00:00
|
|
|
-h|--help)
|
2019-02-28 22:23:19 +00:00
|
|
|
echo "usage: build <project> [OPTIONS]"
|
2018-11-13 15:31:53 +00:00
|
|
|
echo "Builds the tiles with osm2city"
|
|
|
|
echo ""
|
|
|
|
echo "OPTIONS"
|
|
|
|
echo " -h, --help Shows this help and exit"
|
2018-11-13 17:31:24 +00:00
|
|
|
echo " -t, --threads Number of threads used for building"
|
|
|
|
echo " This will overwrite the value from the general-settings file"
|
2018-11-13 15:31:53 +00:00
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
2019-02-28 22:23:19 +00:00
|
|
|
if [ $first == "1" ]; then
|
|
|
|
project="$key"
|
|
|
|
shift #past project
|
|
|
|
first=0
|
|
|
|
else
|
|
|
|
echo "Unknown option $key"
|
|
|
|
exit 1
|
|
|
|
fi
|
2018-11-13 15:31:53 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ -z "$project" ]; then
|
2019-02-28 22:23:19 +00:00
|
|
|
echo "No project was given. See build -h for details"
|
2018-11-13 15:31:53 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2018-11-17 20:32:37 +00:00
|
|
|
if [ ! -f "projects/$project/params.ini" ]; then
|
2018-11-13 17:31:24 +00:00
|
|
|
echo "Project does not exsist. Please run ./create-project to create one"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2018-11-13 15:31:53 +00:00
|
|
|
|
2019-02-28 22:23:19 +00:00
|
|
|
source venv/bin/activate > /dev/null 2>&1
|
2018-11-13 15:31:53 +00:00
|
|
|
if [ $? == 1 ]; then
|
|
|
|
echo "Couldn't find the venv. Please run './create-venv' to create one"
|
2018-11-13 17:31:24 +00:00
|
|
|
exit 1
|
2018-11-13 15:31:53 +00:00
|
|
|
fi
|
2019-02-28 22:23:19 +00:00
|
|
|
source projects/$project/settings > /dev/null 2>&1
|
2018-11-13 15:31:53 +00:00
|
|
|
if [ $? == 1 ]; then
|
|
|
|
echo "Couldn't find the settings file for the given project."
|
|
|
|
echo "Please check if the project exsists and contains the 'settings' file."
|
|
|
|
echo "To create a new project run './create-project'"
|
2018-11-13 17:31:24 +00:00
|
|
|
exit 1
|
2018-11-13 15:31:53 +00:00
|
|
|
fi
|
2019-02-28 22:23:19 +00:00
|
|
|
source general-settings > /dev/null 2>&1
|
2018-11-13 15:31:53 +00:00
|
|
|
if [ $? == 1 ]; then
|
2018-11-17 20:32:37 +00:00
|
|
|
echo "Couldn't find the general settings. Please run ./install first."
|
2018-11-13 15:31:53 +00:00
|
|
|
fi
|
|
|
|
|
2018-11-13 17:31:24 +00:00
|
|
|
if [ ! -z "$man_thread" ]; then
|
|
|
|
threads=$man_thread
|
2018-11-13 15:31:53 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# change to the project dir and build
|
|
|
|
cd projects/$project
|
|
|
|
time ( python3 ../../osm2city/build_tiles.py -f params.ini -b "$bounds" -p "$threads" 2>&1 ) 2> exec-time
|
|
|
|
cat exec-time | grep "real" | sed "s/real\t\([0-9]*\)m\([0-9]*\).*/Building $project took \1 minutes and \2 seconds./"
|