-
Notifications
You must be signed in to change notification settings - Fork 0
/
01_OSM2IGEOADMIN_SHP.sh
151 lines (136 loc) · 6.25 KB
/
01_OSM2IGEOADMIN_SHP.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
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
start=$(date '+%s')
if [ "$#" -ge 1 ]; then
if [ "$1" = "FRANCE" ];
then
a_pays=$1
else
IFS= read -p "PAYS : " p_pays
if [ "$p_pays" = "FRANCE" ];
then
export a_pays=$p_pays
else
echo "Erreur de paramètre"
exit 0
fi
fi
else
IFS= read -p "PAYS : " p_pays
if [ "$p_pays" = "FRANCE" ];
then
export a_pays=$p_pays
else
echo "Erreur de paramètre"
exit 0
fi
fi
#-------------------------------------------------------------------------------
if [ "$#" -ge 2 ]; then
if [ "$2" = "2154" ] || [ "$2" = "4326" ];
then
c_epsg=$2
else
IFS= read -p "EPSG : " p_epsg
if [ "$p_epsg" = "2154" ] || [ "$p_epsg" = "4326" ];
then
export c_epsg=$p_epsg
else
echo "Erreur de paramètre"
exit 0
fi
fi
else
IFS= read -p "EPSG : " p_epsg
if [ "$p_epsg" = "2154" ] || [ "$p_epsg" = "4326" ];
then
export c_epsg=$p_epsg
else
echo "Erreur de paramètre"
exit 0
fi
fi
#-------------------------------------------------------------------------------
#Variables
export REPER=/home/osm2igeoadmin
export PAYS=$a_pays
cd $REPER/data_in/$PAYS/
for file in $a_pays.pbf
do
#Variables
export OUT_EPSG=$c_epsg
export LINK_OGR=ogr2ogr
export DATA_IN=data_in/$PAYS/${file}
export ENCODAGE=UTF-8
export DATE_T=$(date '+%Y%m')
export DATE_OLD=$(date -d "-1 month" +%Y%m)
#-------------------------------------------------------------------------------
#EPSG
if [ "$c_epsg" = "4326" ]
then
export EMPRISE='-180 -90 180 90'
export NZ='_WGS84_4326'
fi
if [ "$c_epsg" = "2154" ]
then
export EMPRISE='-9.62 41.18 10.30 51.54'
export NZ='_L93_2154'
fi
cd $REPER
mkdir data_temp/$PAYS
mkdir data_temp/$PAYS/$OUT_EPSG
cd data_temp/$PAYS/$OUT_EPSG
rm -rfv *
cd $REPER
#----------------------------------------------------------------------------------
#ADMIN
sh scripts/ARRONDISSEMENT_FRANCE_SHP.sh | tee data_temp/$PAYS/$OUT_EPSG/ARRONDISSEMENT.txt
sh scripts/DEPARTEMENT_FRANCE_SHP.sh | tee data_temp/$PAYS/$OUT_EPSG/DEPARTEMENT.txt
sh scripts/REGION_FRANCE_SHP.sh | tee data_temp/$PAYS/$OUT_EPSG/REGION.txt
sh scripts/EPCI_FRANCE_SHP.sh | tee data_temp/$PAYS/$OUT_EPSG/EPCI.txt
cp scripts/CHEF_LIEU_FRANCE_SELECT.vrt data_temp/$PAYS/$OUT_EPSG'/CHEF_LIEU_SELECT.vrt'
sh scripts/CHEF_LIEU_FRANCE_boundary.sh | tee data_temp/$PAYS/$OUT_EPSG/CHEF_LIEU_boundary.txt
sh scripts/CHEF_LIEU_FRANCE_point.sh | tee data_temp/$PAYS/$OUT_EPSG/CHEF_LIEU_point.txt
sh scripts/CHEF_LIEU_FRANCE_SHP.sh | tee data_temp/$PAYS/$OUT_EPSG/CHEF_LIEU.txt
rm data_temp/$PAYS/$OUT_EPSG/CHEF_LIEU_boundary.*
rm data_temp/$PAYS/$OUT_EPSG/CHEF_LIEU_point.*
rm data_temp/$PAYS/$OUT_EPSG'/CHEF_LIEU_SELECT.vrt'
sh scripts/COMMUNE_FRANCE_SHP.sh | tee data_temp/$PAYS/$OUT_EPSG/COMMUNE.txt
#----------------------------------------------------------------------------------
#SORTIE SHP
rm -r data_out/$PAYS/$DATE_T'_OSM2IGEOADMIN_'${file%%.*}'_SHP'$NZ -v
mkdir data_out/$PAYS -v
mkdir data_out/$PAYS/$DATE_T'_OSM2IGEOADMIN_'${file%%.*}'_SHP'$NZ -v
cp -r data_temp/$PAYS/$OUT_EPSG/* data_out/$PAYS/$DATE_T'_OSM2IGEOADMIN_'${file%%.*}'_SHP'$NZ/
rm -r data_out/$PAYS/$DATE_T'_OSM2IGEOADMIN_'${file%%.*}'_SHP'$NZ/*.txt
#----------------------------------------------------------------------------------
cp attachement/Z_PROJET_OSM2IGEOADMIN_SHP.qgs data_out/$PAYS/$DATE_T'_OSM2IGEOADMIN_'${file%%.*}'_SHP'$NZ/Z_PROJET_OSM2IGEOADMIN.qgs
cp attachement/Z_Licence.txt data_out/$PAYS/$DATE_T'_OSM2IGEOADMIN_'${file%%.*}'_SHP'$NZ/Z_Licence.txt
#----------------------------------------------------------------------------------
#SORTIE MODIFICATION DU PROJET SHP
if [ "$c_epsg" = "4326" ]
then
sed -i -e "s/<proj4>+proj=lcc +lat_1=49 +lat_2=44 +lat_0=46.5 +lon_0=3 +x_0=700000 +y_0=6600000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs<\/proj4>/<proj4>+proj=longlat +datum=WGS84 +no_defs<\/proj4>/g" data_out/$PAYS/$DATE_T'_OSM2IGEOADMIN_'${file%%.*}'_SHP'$NZ/Z_PROJET_OSM2IGEOADMIN.qgs
sed -i -e "s/<srsid>145<\/srsid>/<srsid>3452<\/srsid>/g" data_out/$PAYS/$DATE_T'_OSM2IGEOADMIN_'${file%%.*}'_SHP'$NZ/Z_PROJET_OSM2IGEOADMIN.qgs
sed -i -e "s/<srid>2154<\/srid>/<srid>4326<\/srid>/g" data_out/$PAYS/$DATE_T'_OSM2IGEOADMIN_'${file%%.*}'_SHP'$NZ/Z_PROJET_OSM2IGEOADMIN.qgs
sed -i -e "s/<authid>EPSG:2154<\/authid>/<authid>EPSG:4326<\/authid>/g" data_out/$PAYS/$DATE_T'_OSM2IGEOADMIN_'${file%%.*}'_SHP'$NZ/Z_PROJET_OSM2IGEOADMIN.qgs
sed -i -e "s/<description>RGF93 \/ Lambert-93<\/description>/<description>WGS 84<\/description>/g" data_out/$PAYS/$DATE_T'_OSM2IGEOADMIN_'${file%%.*}'_SHP'$NZ/Z_PROJET_OSM2IGEOADMIN.qgs
sed -i -e "s/<projectionacronym>lcc<\/projectionacronym>/<projectionacronym>longlat<\/projectionacronym>/g" data_out/$PAYS/$DATE_T'_OSM2IGEOADMIN_'${file%%.*}'_SHP'$NZ/Z_PROJET_OSM2IGEOADMIN.qgs
sed -i -e "s/<ellipsoidacronym>GRS80<\/ellipsoidacronym>/<ellipsoidacronym>WGS84<\/ellipsoidacronym>/g" data_out/$PAYS/$DATE_T'_OSM2IGEOADMIN_'${file%%.*}'_SHP'$NZ/Z_PROJET_OSM2IGEOADMIN.qgs
sed -i -e "s/<geographicflag>false<\/geographicflag>/<geographicflag>true<\/geographicflag>/g" data_out/$PAYS/$DATE_T'_OSM2IGEOADMIN_'${file%%.*}'_SHP'$NZ/Z_PROJET_OSM2IGEOADMIN.qgs
fi
#----------------------------------------------------------------------------------
#ZIP
cd $REPER/data_out/$PAYS
zip -r $DATE_T'_OSM2IGEOADMIN_'${file%%.*}'_SHP'$NZ.zip $DATE_T'_OSM2IGEOADMIN_'${file%%.*}'_SHP'$NZ
rm -r $DATE_T'_OSM2IGEOADMIN_'${file%%.*}'_SHP'$NZ
curl -s -T $REPER/data_out/$PAYS/$DATE_T'_OSM2IGEOADMIN_'${file%%.*}'_SHP'$NZ.zip ftp://ftp-xxxxxxx/$PAYS/ --user "IDENTIFIANT:PASSWORD"
curl -s -u "IDENTIFIANT:PASSWORD" "ftp://ftp-xxxxxxx/$PAYS/" -Q "-DELE $DATE_OLD'_OSM2IGEOADMIN_'${file%%.*}_SHP$NZ.zip"
rm -r $DATE_T'_OSM2IGEOADMIN_'${file%%.*}'_SHP'$NZ.zip
done
#----------------------------------------------------------------------------------
#Suppression des fichiers temporaires
cd $REPER
cd data_temp/$PAYS/$OUT_EPSG/
rm -rfv *
#----------------------------------------------------------------------------------
end=$(date '+%s')
echo "DUREE: $((($end-$start) / 3600))hrs $(((($end-$start) / 60) % 60))min $((($end-$start) % 60))sec"