-
Notifications
You must be signed in to change notification settings - Fork 0
/
2_mission_kml.sh
90 lines (72 loc) · 4.19 KB
/
2_mission_kml.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
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
#!/bin/bash
# LECTURE DU FICHIER DE CONFIGURATION
. './config.env'
# REPERTOIRE DE TRAVAIL
cd $REPER
echo $REPER
folder_mission=$REPER'/2_mission/'$id_mission
# SUPPRESSION DE LA MISSION
rm -r $folder_mission
# CREATION DES REPERTOIRES
mkdir $folder_mission
mkdir $folder_mission'/img_jp2'
mkdir $folder_mission'/img_jpg'
mkdir $folder_mission'/img_jpg_crop'
mkdir $folder_mission'/kml'
mkdir $folder_mission'/couverture'
mkdir $folder_mission'/couverture_bbox'
mkdir $folder_mission'/csv_attributs'
mkdir $folder_mission'/csv_liste_img'
mkdir $folder_mission'/csv_exif'
# TELECHARGER LE FICHIER DE LA MISSION
curl "https://wxs.ign.fr/$key/dematkml/DEMAT.PVA/$id_mission/t.kml" > $folder_mission'/kml/'$id_mission'.kml'
# PERMET DE TELECHARGER LES FICHIERS KML DES MISSIONS DECOUPEES POUR UN NIVEAU N+1
xmllint -o $folder_mission'/kml/'$id_mission'.kml' -format $folder_mission'/kml/'$id_mission'.kml'
href=($(awk -F"[><]" '/<\/Link>/{a="";next} /<Link>/{a=1;next} a && /<href>/{print $3}' $folder_mission'/kml/'$id_mission'.kml'))
for k in ${!href[*]}
do
echo "${href[$k]}"
echo $href
curl "https://wxs.ign.fr/$key/dematkml/DEMAT.PVA/$id_mission/${href[$k]}" > $folder_mission'/kml/'$id_mission'_'${href[$k]:0:1}'.kml'
# PERMET DE TELECHARGER LES FICHIERS KML DES MISSIONS DECOUPEES POUR UN NIVEAU N+2
xmllint -o $folder_mission'/kml/'$id_mission'_'${href[$k]:0:1}'.kml' -format $folder_mission'/kml/'$id_mission'_'${href[$k]:0:1}'.kml'
href2=($(awk -F"[><]" '/<\/Link>/{a="";next} /<Link>/{a=1;next} a && /<href>/{print $3}' $folder_mission'/kml/'$id_mission'_'${href[$k]:0:1}'.kml'))
for t in ${!href2[*]}
do
echo ${href[$k]:0:1}'/'"${href2[$t]}"
echo $href2
curl "https://wxs.ign.fr/$key/dematkml/DEMAT.PVA/$id_mission/${href[$k]:0:1}/${href2[$t]}" > $folder_mission'/kml/'$id_mission'_'${href[$k]:0:1}'_'${href2[$t]:0:1}'.kml'
# PERMET DE TELECHARGER LES FICHIERS KML DES MISSIONS DECOUPEES POUR UN NIVEAU N+3
xmllint -o $folder_mission'/kml/'$id_mission'_'${href[$k]:0:1}'_'${href2[$t]:0:1}'.kml' -format $folder_mission'/kml/'$id_mission'_'${href[$k]:0:1}'_'${href2[$t]:0:1}'.kml'
href3=($(awk -F"[><]" '/<\/Link>/{a="";next} /<Link>/{a=1;next} a && /<href>/{print $3}' $folder_mission'/kml/'$id_mission'_'${href[$k]:0:1}'_'${href2[$t]:0:1}'.kml'))
for y in ${!href3[*]}
do
echo ${href[$k]:0:1}'/'${href2[$t]:0:1}'/'"${href3[$y]}"
echo $href3
curl "https://wxs.ign.fr/$key/dematkml/DEMAT.PVA/$id_mission/${href[$k]:0:1}/${href2[$t]:0:1}/${href3[$y]}" > $folder_mission'/kml/'$id_mission'_'${href[$k]:0:1}'_'${href2[$t]:0:1}'_'${href3[$y]:0:1}'.kml'
# PERMET DE TELECHARGER LES FICHIERS KML DES MISSIONS DECOUPEES POUR UN NIVEAU N+4
xmllint -o $folder_mission'/kml/'$id_mission'_'${href[$k]:0:1}'_'${href2[$t]:0:1}'_'${href3[$y]:0:1}'.kml' -format $folder_mission'/kml/'$id_mission'_'${href[$k]:0:1}'_'${href2[$t]:0:1}'_'${href3[$y]:0:1}'.kml'
href4=($(awk -F"[><]" '/<\/Link>/{a="";next} /<Link>/{a=1;next} a && /<href>/{print $3}' $folder_mission'/kml/'$id_mission'_'${href[$k]:0:1}'_'${href2[$t]:0:1}'_'${href3[$y]:0:1}'.kml'))
for u in ${!href4[*]}
do
echo ${href[$k]:0:1}'/'${href2[$t]:0:1}'/'${href3[$y]:0:1}'/'"${href4[$u]}"
echo $href4
curl "https://wxs.ign.fr/$key/dematkml/DEMAT.PVA/$id_mission/${href[$k]:0:1}/${href2[$t]:0:1}/${href3[$y]:0:1}/${href4[$u]}" > $folder_mission'/kml/'$id_mission'_'${href[$k]:0:1}'_'${href2[$t]:0:1}'_'${href3[$y]:0:1}'_'${href4[$u]:0:1}'.kml'
xmllint -o $folder_mission'/kml/'$id_mission'_'${href[$k]:0:1}'_'${href2[$t]:0:1}'_'${href3[$y]:0:1}'_'${href4[$u]:0:1}'.kml' -format $folder_mission'/kml/'$id_mission'_'${href[$k]:0:1}'_'${href2[$t]:0:1}'_'${href3[$y]:0:1}'_'${href4[$u]:0:1}'.kml'
done
done
done
done
# COUVERTURE DES PRISES DE VUE DE LA MISSION
file=$folder_mission'/couverture/'$id_mission'.shp'
for i in $(ls $folder_mission'/kml/'*'.kml')
do
if [ -f "$file" ]
then
echo "merge $i"
ogr2ogr -f 'ESRI Shapefile' -append $file $i
else
echo "creating merge $i"
ogr2ogr -f 'ESRI Shapefile' --config SHAPE_ENCODING $ENCODAGE -lco SPATIAL_INDEX=YES -lco ENCODING=$ENCODAGE $file $i -nlt POLYGON
fi
done