-
Notifications
You must be signed in to change notification settings - Fork 1
/
parseCoast.sh
executable file
·34 lines (29 loc) · 1.24 KB
/
parseCoast.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
#!/bin/bash
fileName="$1"
id=$(echo $fileName | grep -o '[0-9]\{3,4\}' | head -1)
kartverketPrefix=$(echo $fileName | grep -o 'Basisdata_.*_N50')
folder="tmp/${id}_coast"
mkdir $folder
prefix="$folder/${id}_coast"
if [ ${#id} -lt 4 ]
then
id="0$id";
fi
idName=$(echo $fileName | grep -o $id'\_[^_]\+');
set -e
unzip -d $folder -uq $fileName "${kartverketPrefix}Arealdekke_SOSI.sos"
if $(file "$folder/${kartverketPrefix}Arealdekke_SOSI.sos" | grep -q 'UTF-8'); then
iconv -c -tISO-8859-10 "$folder/${kartverketPrefix}Arealdekke_SOSI.sos" > "$folder/${id}_N50_ArealdekkeISO.sos"
sed -i "s/UTF-8/ISO8859-10/" "$folder/${id}_N50_ArealdekkeISO.sos"
mv "$folder/${id}_N50_ArealdekkeISO.sos" "$folder/${kartverketPrefix}Arealdekke_SOSI.sos"
fi
sosi2osm "$folder/${kartverketPrefix}Arealdekke_SOSI.sos" src/kyst.lua > ${prefix}.osm
python src/waySimplifyer.py ${prefix}.osm ${prefix}.osm
python src/emptyRemover.py ${prefix}.osm ${prefix}.osm
python src/coastCorrector.py ${prefix}.osm ${prefix}.osm
python src/removeExcessiveNodes.py ${prefix}.osm ${prefix}.osm .1
python src/splitterOsm.py ${prefix}.osm ${prefix}_part --keepAdjacentWays
rm "$folder/${kartverketPrefix}Arealdekke_SOSI.sos"
zip -rq "Converted/${idName}.zip" $folder/
rm $folder/*
rmdir $folder