forked from asciipip/TopOSM
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_xml
More file actions
executable file
·33 lines (24 loc) · 846 Bytes
/
generate_xml
File metadata and controls
executable file
·33 lines (24 loc) · 846 Bytes
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
#!/bin/bash
# Generates the mapnik xml files and includes from
# their respective templates.
# Variable declarations on the form ${VAR} are substituted with
# the value of the corresponding enviroment variable VAR.
# awk program to substitute environment variables
AWKFILTER='{while(match($0,"[$]{[^}]*}")){var=substr($0,RSTART+2,RLENGTH -3);gsub("[$]{"var"}",ENVIRON[var])}}1'
if [[ -z $TOPOSM_ENV_SET ]]; then
echo "Error: TopOSM environment not set."
exit 1
fi
# process includes
for SRC in `ls include/*.templ`; do
echo "Processing $SRC..."
DST=`dirname $SRC`/`basename $SRC .templ`
cat "$SRC" | awk "$AWKFILTER" > "$DST"
done
# process style xml files
for SRC in `ls templates/*.templ`; do
echo "Processing $SRC..."
DST=`basename $SRC .templ`
cat "$SRC" | awk "$AWKFILTER" > "$DST"
done
echo "Done."