forked from stefanb/RabaSplitForOSM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepareSource.sh
executable file
·59 lines (45 loc) · 1.41 KB
/
prepareSource.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
#!/bin/bash
set -e
# set -x
echo "Starting RABA split at $(date)"
# default: http://stackoverflow.com/questions/16835145/how-to-get-last-day-of-last-month-in-unix
#date --date="yesterday" +"%d-%m-%y"
yyyy=`date -d "$(date +%Y-%m-01) -1 day" +"%Y"`
dd=`date -d "$(date +%Y-%m-01) -1 day" +"%d"`
#dd="02"
mm=`date -d "$(date +%Y-%m-01) -1 day" +"%m"`
#mm="08"
#set parameters:
#yyyy="2021"
#dd="31"
#mm="03"
#internal variables...
dateSource="${yyyy}_${mm}_${dd}"
dateCompact="${yyyy}${mm}${dd}"
echo "Processing RABA data for ${yyyy}-${mm}-${dd}"
#------ download:------
sourceZip="RABA_${dateSource}.zip"
if [ ! -f ${sourceZip} ]; then
echo "Downloading ${sourceZip}..."
wget https://rkg.gov.si/arhiv/RABA/${sourceZip}
fi
if [ ! -f ${sourceZip} ]; then
echo "Soure file ${sourceZip} is missing. Failed to download?"
exit 1
fi
#----- extract: -------
sourceFolder="RABA_${dateCompact}"
rm -rf ${sourceFolder}
mkdir $sourceFolder
cd ${sourceFolder}
unzip ../$sourceZip
cd ..
epsgName="RABA_${dateCompact}_EPSG4326"
rm -rf "${epsgName}"
ogr2ogr -s_srs "EPSG:3794" -t_srs "EPSG:4326" ${epsgName} ${sourceFolder} -nln ${epsgName} -progress
rm -rf "${sourceFolder}"
targetFolder="RabaSplits_latest_EPSG4326"
./makeSplitRange.sh 1 3640 ${yyyy} ${mm} ${dd} ${targetFolder}
rm -rf ${epsgName}
#ln -s /osm/raba/RabaSplitForOSM/$targetFolder /osm/raba/raba.openstreetmap.si/RabaSplits_latest_EPSG4326
echo "Finished on $(date)"