-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_static_files.sh
81 lines (64 loc) · 2.63 KB
/
create_static_files.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
BASE=~/osm/scripts/python
DATA_DIR=${BASE}/data
OUTDIR=~/osm/html/osm
SHAPESDIR=~/osm/data/Shapes/Schongebiete
DATE=$(date +%F)
LOG=${BASE}/update.log.$$
FLOG=${BASE}/update.log
echo "$(date) starting update..." > ${LOG}
function error {
cat ${LOG} |sed 's/\r//g' | mailx -r [email protected] -s "Schongebiete Update Error" [email protected]
cat ${LOG} >> ${FLOG}
rm ${LOG}
exit
}
cd $BASE
source .venv/bin/activate
OVP_SLEEP=120
rm html-out/*
python ./OSMSchutzgebiete.py silent >> $LOG 2>&1
[ ! -f html-out/Schongebiete-Alpenrand-BY-Wege.html ] && error
cp html-out/Schongebiete-Alpenrand-BY-Wege.html $OUTDIR >> $LOG 2>&1
sleep $OVP_SLEEP
python ./OSMSchutzgebiete.py skipways silent >> $LOG 2>&1
cp html-out/Schongebiete-Alpenrand-BY.html $OUTDIR >> $LOG 2>&1
[ ! -f html-out/Schongebiete-Alpenrand-BY.html ] && error
rm -rf data/*
sleep $OVP_SLEEP
python ./OSMSchutzgebieteCheck.py silent >> $LOG 2>&1
[ ! -f data/SchongebieteTagFehler.geojson ] && error
cp data/SchongebieteTagFehler.geojson $OUTDIR >> $LOG 2>&1
sleep $OVP_SLEEP
python ./OSMSchutzgebiete2GeoJSON.py silent >> $LOG 2>&1
[ ! -f data/Schongebiete.geojson -o ! -r data/SchongebieteWays.geojson ] && error
cp data/Schongebiete.geojson $OUTDIR >> $LOG 2>&1
cp data/Schongebiete-ColorStyles.geojson $OUTDIR >> $LOG 2>&1
cp data/SchongebieteWays.geojson $OUTDIR >> $LOG 2>&1
cp data/statistics.json $OUTDIR/../schongebiete/data >> $LOG 2>&1
cp data/statistics.json statistics/statistics.${DATE}.json
# the following needs to correspond to the respective names/settings for the layer names (-nln) and dataseource in geoserver
ogr2ogr -f "PostgreSQL" PG:"dbname=schongebiete user=postgres" data/Schongebiete.geojson -nln geojson -overwrite >> $LOG 2>&1
[ $? -ne 0 ] && error
ogr2ogr -f "PostgreSQL" PG:"dbname=schongebiete user=postgres" data/SchongebieteWays.geojson -nln geojsonWays -overwrite >> $LOG 2>&1
[ $? -ne 0 ] && error
if [ ! -d data/Shapes ]; then
mkdir data/Shapes
fi
cd data/Shapes
ogr2ogr -f "ESRI Shapefile" Schongebiete.shp ../Schongebiete.geojson >> $LOG 2>&1
cp -f * $SHAPESDIR
cd $OUTDIR
ogr2ogr -f "KML" -a_srs "EPSG:4326" Schongebiete.kml Schongebiete.geojson > /dev/null 2>&1
geojsontoosm Schongebiete.geojson > Schongebiete.osm
date=$(date +'%d.%m.%Y %H:%M'|sed 's/\s/%20/g')
wget -q -O ~/osm/html/schongebiete/data/status.svg "https://img.shields.io/static/v1?label=updated&message=${date}&color=green"
cd $DATA_DIR
git diff Schongebiete.geojson >> ${LOG} 2>&1
git commit -m "${DATE}" . >> ${LOG} 2>&1
git push >> ${LOG} 2>&1
if [ -f ${LOG} ]; then
echo "$(date) finshed" >> ${LOG}
cat ${LOG} >> ${FLOG}
rm ${LOG}
fi