-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·61 lines (51 loc) · 1.81 KB
/
run.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
#!/usr/bin/env bash
folder=$1
url=$2
projection="d3.geoMercator().center([13.5, 56.2]).scale(4900)"
# This is needed in case someone runs the script from a different directory
# than the script directory so we don't delete random files.
# https://stackoverflow.com/questions/59895/how-can-i-get-the-source-directory-of-a-bash-script-from-within-the-script-itsel
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
tmpDir="$SCRIPT_DIR/tmp/"
outDir="$SCRIPT_DIR/out/"
(cd $SCRIPT_DIR; npm install)
# Clean directories
#rm $tmpDir*
rm -rf $outDir$folder
if [ ! -f "${outDir}" ]
then
mkdir $outDir
fi
if [ ! -f "${tmpDir}" ]
then
mkdir $tmpDir
fi
# Download GML from WFS
if [ ! -f "${tmpDir}${folder}.gml" ]
then
ogr2ogr -f GML "${tmpDir}${folder}.gml" "WFS:$url"
fi
cp $tmpDir"${folder}.gml" ${outDir}
cp $tmpDir"${folder}.xsd" ${outDir}
function process () {
key=${1,}
folder=${2}
mkdir -p "${outDir}${folder}/${key}"
mkdir -p "${tmpDir}${folder}/${key}"
ogr2ogr -f GeoJSON -lco RFC7946=YES -t_srs EPSG:4326 -s_srs EPSG:25832 "${outDir}${folder}/${key}/${key}.json" "${tmpDir}dagi.gml" "dagi_${key^}"
npx geoproject "$projection" < "${outDir}${folder}/${key}/${key}.json" > "${tmpDir}${folder}/${key}/${key}.json" && \
npx geo2svg -w 650 -h 500 < "${tmpDir}${folder}/${key}/${key}.json" > "${outDir}${folder}/${key}/${key}.svg"
}
process "Afstemningsomraade" $folder
process "Kommuneinddeling" $folder
process "Landsdel" $folder
process "Menighedsraadsafstemningsomraade" $folder
process "Opstillingskreds" $folder
process "Politikreds" $folder
process "Postnummerinddeling" $folder
process "Regionsinddeling" $folder
process "Retskreds" $folder
process "Samlepostnummer" $folder
process "Sogneinddeling" $folder
process "Storkreds" $folder
process "SupplerendeBynavn" $folder