forked from osm-fr/osmose-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalyser_merge_radio_support_FR.py
354 lines (330 loc) · 12.6 KB
/
analyser_merge_radio_support_FR.py
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#########################################################################
# #
# Copyrights Jérôme Amagat 2019 #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
#########################################################################
from io import open
from modules.OsmoseTranslation import T_
from .Analyser_Merge import (
CSV,
Analyser_Merge_Point,
Conflate,
Load_XY,
Mapping,
Select,
SourceDataGouv,
)
class _Analyser_Merge_Radio_Support_FR(Analyser_Merge_Point):
def __init__(
self, config, logger, clas, NAT_IDs, title, tags_select, tags_generate
):
Analyser_Merge_Point.__init__(self, config, logger)
self.def_class_missing_official(
item=8390,
id=1 + 10 * clas,
level=3,
tags=["merge", "fix:survey", "fix:imagery"],
title=T_("Radio support ({0}) not integrated", title),
)
self.def_class_possible_merge(
item=8391,
id=3 + 10 * clas,
level=3,
tags=["merge", "fix:chair"],
title=T_("Radio support ({0}), integration suggestion", title),
)
self.def_class_update_official(
item=8392,
id=4 + 10 * clas,
level=3,
tags=["merge", "fix:chair"],
title=T_("Radio support ({0}) update", title),
)
self.communeNameIndexedByInsee = {}
with open("dictionaries/FR/BddCommunes", "r", encoding="utf-8") as f:
for x in f:
x = x.split("\t")
code_insee = x[0]
name_insee = x[1].strip()
self.communeNameIndexedByInsee[code_insee] = name_insee
self.init(
"https://www.data.gouv.fr/fr/datasets/donnees-sur-les-installations-radioelectriques-de-plus-de-5-watts-1/",
"Données sur les installations radioélectriques de plus de 5 watts",
CSV(
SourceDataGouv(
attribution="data.gouv.fr:ANFR",
dataset="551d4ff3c751df55da0cd89f",
resource="b1d8a2a0-a68f-45a4-9b06-94b13ecb22ec",
zip="SUP_SUPPORT.txt",
encoding="ISO-8859-15",
),
separator=";",
quote="$",
),
Load_XY(
(
"CASE \"COR_CD_EW_LON\" WHEN 'W' THEN -1*(to_number(\"COR_NB_DG_LON\", '99') + to_number(\"COR_NB_MN_LON\", '99') / 60 \
+ to_number(\"COR_NB_SC_LON\", '99') / 3600) WHEN 'E' THEN to_number(\"COR_NB_DG_LON\", '99') + to_number(\"COR_NB_MN_LON\", '99') / 60 \
+ to_number(\"COR_NB_SC_LON\", '99') / 3600 END",
),
(
"CASE \"COR_CD_NS_LAT\" WHEN 'S' THEN -1*(to_number(\"COR_NB_DG_LAT\", '99') + to_number(\"COR_NB_MN_LAT\", '99') / 60 \
+ to_number(\"COR_NB_SC_LAT\", '99') / 3600) WHEN 'N' THEN to_number(\"COR_NB_DG_LAT\", '99') \
+ to_number(\"COR_NB_MN_LAT\", '99') / 60 + to_number(\"COR_NB_SC_LAT\", '99') / 3600 END",
),
select={"NAT_ID": NAT_IDs},
unique=("SUP_ID",),
),
Conflate(
select=Select(types=["nodes", "ways"], tags=tags_select),
conflationDistance=50,
osmRef="ref:FR:ANFR",
mapping=Mapping(
static1=tags_generate,
static2={"source": self.source},
mapping1={
"ref:FR:ANFR": "SUP_ID",
"operator": lambda fields: (
self.owner[int(fields["TPO_ID"])]
if fields["TPO_ID"] and int(fields["TPO_ID"]) in self.owner
else None
),
"height": lambda fields: (
fields["SUP_NM_HAUT"].replace(",", ".")
if fields["SUP_NM_HAUT"]
else None
),
},
text=lambda tags, fields: {
"en": "{0}, address: {1}, {2}{3}".format(
(
lambda x: (
self.Tour_Mat_Pylone[fields["NAT_ID"]]
if x == "Tour, mât et pylône"
else x
)
)(title),
", ".join(
filter(
lambda x: x != "None",
[
fields["ADR_LB_LIEU"],
fields["ADR_LB_ADD1"],
fields["ADR_LB_ADD2"],
fields["ADR_LB_ADD3"],
fields["ADR_NM_CP"],
],
)
),
(
lambda x: (
self.communeNameIndexedByInsee[x]
if x in self.communeNameIndexedByInsee
else x
)
)(fields["COM_CD_INSEE"]),
(
lambda x: (
(", operator: " + self.other_owner[int(x)])
if x and x != "None" and int(x) in self.other_owner
else ""
)
)(fields["TPO_ID"]),
)
},
),
),
)
# number: column TPO_ID in SUP_SUPPORT.txt and value: SUP_PROPRIETAIRE.txt
owner = {
1: "ANFR",
4: "Bouygues",
10: "CROSS",
16: "Orange Services Fixes",
19: "La Poste",
21: "Orange",
24: "SNCF Réseau",
25: "RTE",
27: "SFR",
31: "Société réunionnaise du radiotéléphone",
32: "TDF",
33: "Towercast",
35: "Voies navigables de France",
36: "Altitude Telecom",
37: "Antalis",
38: "One Cast",
39: "Gendarmerie nationale",
40: "Tikiphone",
41: "France Caraibes Mobiles",
42: "IFW-Free",
43: "Lagardère Active Média",
44: "Outremer Telecom",
45: "RATP",
47: "Office des Postes et Telecom",
49: "Bolloré",
48: "Neuf Cegetel",
50: "Completel",
51: "Digicel",
52: "Eutelsat",
53: "Expertmedia",
54: "Mediaserv",
55: "Belgacom",
56: "Airbus",
57: "Guyane Numérique",
58: "Dauphin Telecom",
59: "Itas Tim",
60: "Réunion Numérique",
62: "SNCF",
64: "Pacific Mobile Telecom",
63: "Viti",
61: "Globecast",
69: "Zeop",
68: "Cellnex",
67: "Service des Postes et Telecom",
65: "ATC France",
66: "Telco OI",
}
other_owner = {
2: "Association",
3: "Aviation Civile",
5: "CCI,Ch Metiers,Port Aut,Aérop",
6: "Conseil Départemental",
7: "Conseil Régional",
8: "Coopérative Agricole, Vinicole",
9: "Copropriété, Syndic, SCI",
11: "DDE",
12: "Autres",
13: "EDF ou GDF",
14: "Etablissement de soins",
15: "Etat, Ministère",
17: "Syndicat des eaux, Adduction",
18: "Intérieur",
20: "Météo",
22: "Particulier",
23: "Phares et balises",
26: "SDIS, secours, incendie",
28: "Société HLM",
29: "Société Privée SA",
30: "Sociétés d'Autoroutes",
34: "Commune, communauté de commune",
46: "Titulaire programme Radio/TV",
}
Tour_Mat_Pylone = {
"11": "Mât béton",
"12": "Mât métallique",
"21": "Pylône",
"22": "Pylône autoportant",
"23": "Pylône autostable",
"24": "Pylône haubané",
"25": "Pylône treillis",
"26": "Pylône tubulaire",
"42": "Mât",
"48": "pylône arbre",
}
class Analyser_Merge_Tour_Mat_Pylone(_Analyser_Merge_Radio_Support_FR):
def __init__(self, config, logger=None):
_Analyser_Merge_Radio_Support_FR.__init__(
self,
config,
logger,
0,
["11", "12", "21", "22", "23", "24", "25", "26", "42", "48"],
"Tour, mât et pylône",
[
{"man_made": "tower", "tower:type": "communication"},
{"man_made": "mast", "tower:type": "communication"},
{"man_made": "communications_tower"},
],
{"man_made": "mast", "tower:type": "communication"},
)
class Analyser_Merge_Tour_Hertzienne(_Analyser_Merge_Radio_Support_FR):
def __init__(self, config, logger=None):
_Analyser_Merge_Radio_Support_FR.__init__(
self,
config,
logger,
1,
"33",
"Tour hertzienne",
[
{"man_made": "tower", "tower:type": "communication"},
{"man_made": "mast", "tower:type": "communication"},
{"man_made": "communications_tower"},
],
{"man_made": "communications_tower"},
)
class Analyser_Merge_Tour_Controle(_Analyser_Merge_Radio_Support_FR):
def __init__(self, config, logger=None):
_Analyser_Merge_Radio_Support_FR.__init__(
self,
config,
logger,
2,
"44",
"Tour de contrôle",
{"man_made": "tower", "service": "aircraft_control"},
{"man_made": "tower", "service": "aircraft_control"},
)
class Analyser_Merge_Chateau_Eau(_Analyser_Merge_Radio_Support_FR):
def __init__(self, config, logger=None):
_Analyser_Merge_Radio_Support_FR.__init__(
self,
config,
logger,
3,
"4",
"Château d'eau ou réservoir",
{"man_made": "water_tower"},
{"man_made": "water_tower"},
)
class Analyser_Merge_Silo(_Analyser_Merge_Radio_Support_FR):
def __init__(self, config, logger=None):
_Analyser_Merge_Radio_Support_FR.__init__(
self,
config,
logger,
4,
"31",
"Silo",
{"man_made": "silo"},
{"man_made": "silo"},
)
class Analyser_Merge_Phare(_Analyser_Merge_Radio_Support_FR):
def __init__(self, config, logger=None):
_Analyser_Merge_Radio_Support_FR.__init__(
self,
config,
logger,
5,
"41",
"Phare",
{"man_made": "lighthouse"},
{"man_made": "lighthouse"},
)
class Analyser_Merge_Eolienne(_Analyser_Merge_Radio_Support_FR):
def __init__(self, config, logger=None):
_Analyser_Merge_Radio_Support_FR.__init__(
self,
config,
logger,
6,
"52",
"Éolienne",
{"power": "generator", "generator:source": "wind"},
{"power": "generator", "generator:source": "wind"},
)