forked from molo1134/splat-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_overlay.sh
More file actions
executable file
·161 lines (128 loc) · 3.87 KB
/
create_overlay.sh
File metadata and controls
executable file
·161 lines (128 loc) · 3.87 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#/bin/bash
# Creates an overlay for use with openstreetmap
#
#
# created in 2016 by HB3YMB
# inspired by https://github.com/molo1134/splat-scripts/
# tested on arch linux with
# GDAL 2.0.2, released 2016/01/26
#check for used software
SPLATSCRIPT="./splat-radio.sh"
CONVERT="convert"
MKDIR="mkdir"
GDAL_TRANSLATE="gdal_translate"
GDAL_TILE="gdal2tiles.py"
USE_HIGHRES=false
# Check if all prerequisites are installed
if [ ! -x `which $SPLATSCRIPT` ]; then
echo "error: not found in path: $SPLAT"
exit 1
fi
if [ ! -x `which $GDAL_TRANSLATE` ]; then
echo "error: not found in path: gdal_translate"
exit 1
fi
if [ ! -x `which $GDAL_TILE` ]; then
echo "error: not found in path: $GDAL_TILE"
exit 1
fi
if [ ! -x `which $CONVERT` ]; then
echo "error: not found in path: convert"
exit 1
fi
if [ ! -x `which $MKDIR` ]; then
echo "error: not found in path: mkdir"
exit 1
fi
function helptext {
cat <<EOF
Usage: $0 -c CONFIGFILE
-c CONFIGFILE
The file with your configuration, see README.md
EOF
}
#Extract commandline options, see helptext for explanation
while getopts ":c:hr" opt; do
case $opt in
r)
USE_HIGHRES=true
SPLAT_CMD=$SPLAT_HD
echo "Rendering high-res with splat-hd, -r option set"
;;
c)
echo "Using configuration file: ${OPTARG}"
CONFIGFILE=$OPTARG
;;
h)
helptext
exit 1
;;
\?)
echo "Invalid option: -$OPTARG" >&2
helptext
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
helptext
exit 1
;;
esac
done
#check for configfile, load if given
if [ ! -z "$CONFIGFILE" ] && [ -r $CONFIGFILE ]; then
echo "read in configfile"
source $CONFIGFILE
else
echo "No configfile given, exiting now"
helptext
exit 1
fi
#vars
#PPMFILE="./$NAME-map-hd.ppm"
PNGSOLID=$NAME-map.png
PNGTRANS="./$NAME-map-hd-tr.png"
SCALEFILE="./$NAME-scale.png"
GEOTIFF="./$NAME-map-hd.geotiff"
GEOVRT="./$NAME-map-hd.vrt"
TILEFOLDER="./$NAME-geotiles"
GEODATE="EPSG:4326"
ZOOMLEVELS="7-14"
#all,google,openlayers,none
WEBVIEWER="all"
#render the splat image with white background
# TODO change the ./splat-radio.sh to do this
$SPLATSCRIPT -c $CONFIGFILE -R 20 -b -r
#$SPLAT -t hol.qth -d ./maps/ -L 2 -metric -R 25 -sc -ngs -erp $ERP -o $PPMFILE
#prepare image
#$CONVERT $PPMFILE $PNGSOLID
$CONVERT -gravity South -crop x30+0+0 $PNGSOLID $SCALEFILE
$CONVERT $PNGSOLID -transparent white $PNGTRANS
#crop scale from image
$CONVERT -crop +0-30 $PNGTRANS $PNGTRANS
#do some oversampling to create softer images
# TODO make flag to enable oversampling
# this is 'cheating' but creates nicer images
echo "Upscale image for smoother result"
#$CONVERT $PNGTRANS -resize 200% -gaussian 10 $PNGTRANS
#create a georeferenced geotiff out of the image
# not sure if gdal-hd images are always 1 degree in height, maybe calculate out of imagesize
# not sure if gdal-hd images are always 2 degrees in width, maybe calculate out of imagesize
LATINT=${LAT%.*}
LONINT=${LON%.*}
$GDAL_TRANSLATE -of GTiff -a_ullr $LONINT $((LATINT+1)) $((LONINT+2)) $LATINT -a_srs EPSG:4326 $PNGTRANS $GEOTIFF
# $GDAL_TRANSLATE -of Gtiff -a_ullr 7 48 9 47 -a_srs EPSG:4326 hol.png test.tif
#create the maptiles out of the geotiff
$MKDIR -p $TILEFOLDER
#maybe add -expand rgba
$GDAL_TRANSLATE -a_srs $GEODATE -of vrt -expand rgba $GEOTIFF $GEOVRT
# TODO some strange bug if adding true geodate
#gdalwarp -of GTiff -s_srs EPSG:4326 -t_srs EPSG:3857 $GEOVRT temp.geotiff
$GDAL_TILE -s $GEODATE -z $ZOOMLEVELS -t "$NAME--$CALL" -w $WEBVIEWER $GEOVRT $TILEFOLDER
#echo $GDAL_TILE -s "WGS84" -z "$ZOOMLEVELS" -t "$NAME" -w "$WEBVIEWER" $GEOVRT $TILEFOLDER
#s "$GEODATE"-z "$ZOOMLEVELS" -t "$NAME" -w "$WEBVIEWER"
#remove unused files
# TODO RELEASE rm $PPMFILE $PNGSOLID $GEOVRT
#deleting maybe useful files, (TODO make flag)
# TODO RELEASE rm $PNGTRANS $GEOTIFF
#goodbye and thanks for all the fish :)