2222###########################################################################
2323
2424from modules .OsmoseTranslation import T_
25- from .Analyser_Merge import Analyser_Merge_Point , Source , CSV , Load_XY , Conflate , Select , Mapping
25+ from .Analyser_Merge import (
26+ Analyser_Merge_Point ,
27+ Source ,
28+ CSV ,
29+ Load_XY ,
30+ Conflate ,
31+ Select ,
32+ Mapping ,
33+ )
2634
2735
2836class Analyser_Merge_Charging_station_FR (Analyser_Merge_Point ):
29-
3037 WIKIDATA_MAP = {
3138 "ionity" : "Q42717773" ,
3239 "bouygues" : "Q3046208" ,
@@ -38,71 +45,206 @@ class Analyser_Merge_Charging_station_FR(Analyser_Merge_Point):
3845 "Izivia" : "Q86671322" ,
3946 }
4047
48+ # puisssance max de borne en kW connue
49+ limit_kw_known = 401
50+
51+ def keepMaxValueIfEnum (str ):
52+ # si la valeur contient un ; on sépare et on prend la plus haute valeur
53+ if ";" in str :
54+ boom = str .split (";" )
55+ max = 0
56+ for p in boom :
57+ p = int (p )
58+ if p > max :
59+ max = p
60+
61+ if max > 0 :
62+ str = max
63+ return str
64+
65+ def getPuissanceNominaleInKw (self , puissance_nominale ):
66+ # deviner un nombre en kw dans la puissance nominale,
67+ # les valeurs de plus de 401 sont à diviser par mille,
68+ # il faut aussi évacuer le leftpad de 0
69+ if puissance_nominale is None :
70+ return None
71+ puissance_nominale = str (puissance_nominale )
72+
73+ if puissance_nominale is None :
74+ return None
75+ # Convertir en chaîne et supprimer les zéros à gauche
76+ puissance_str = str (puissance_nominale ).lstrip ("0" )
77+ if not puissance_str :
78+ return 0
79+
80+ puissance_str = self .keepMaxValueIfEnum (puissance_str )
81+ # Reconvertir en entier
82+ puissance_nominale = int (puissance_str )
83+ if puissance_nominale > limit_kw_known :
84+ return str (puissance_nominale / 1000 ) + " kW"
85+ else :
86+ return str (puissance_nominale ) + " kW"
87+
4188 def __init__ (self , config , logger = None ):
4289 Analyser_Merge_Point .__init__ (self , config , logger )
4390 doc = dict (
44- detail = T_ (
45- '''A car charging station may be here but is not mapped. The list of the
46- charging stations comes from a database published by Etalab. This database
47- brings together information published by the various local authorities and
48- networks in France.''' ),
49- fix = T_ (
50- '''See [the
51- mapping](https://wiki.openstreetmap.org/wiki/France/data.gouv.fr/Bornes_de_Recharge_pour_V%C3%A9hicules_%C3%89lectriques)
52- on the wiki. Add a node or add tags if already existing.''' ),
53- trap = T_ (
54- '''The initial information corresponds to recharging pools and devices and not to
55- stations, so some values are worth checking in the field. For instance, an open data point
56- with `capacity=6` can sometimes match to 3 charging station with `capacity=2`''' ))
57- self .def_class_missing_official (item = 8410 , id = 1 , level = 3 , tags = ['merge' , 'fix:imagery' , 'fix:survey' , 'fix:picture' ],
58- title = T_ ('Car charging station not integrated' ), ** doc )
59- self .def_class_possible_merge (item = 8411 , id = 3 , level = 3 , tags = ['merge' , 'fix:imagery' , 'fix:survey' , 'fix:picture' ],
60- title = T_ ('Car charging station, integration suggestion' ), ** doc )
61- self .def_class_update_official (item = 8412 , id = 4 , level = 3 , tags = ['merge' , 'fix:imagery' , 'fix:survey' , 'fix:picture' ],
62- title = T_ ('Car charging station update' ), ** doc )
91+ detail = T_ (
92+ """A car charging station may be here but is not mapped. The list of the
93+ charging stations comes from a database published by Etalab. This database
94+ brings together information published by the various local authorities and
95+ networks in France."""
96+ ),
97+ fix = T_ (
98+ """See [the
99+ mapping](https://wiki.openstreetmap.org/wiki/France/data.gouv.fr/Bornes_de_Recharge_pour_V%C3%A9hicules_%C3%89lectriques)
100+ on the wiki. Add a node or add tags if already existing."""
101+ ),
102+ trap = T_ (
103+ """The initial information corresponds to recharging pools and devices and not to
104+ stations, so some values are worth checking in the field. For instance, an open data point
105+ with `capacity=6` can sometimes match to 3 charging station with `capacity=2`"""
106+ ),
107+ )
108+ self .def_class_missing_official (
109+ item = 8410 ,
110+ id = 1 ,
111+ level = 3 ,
112+ tags = ["merge" , "fix:imagery" , "fix:survey" , "fix:picture" ],
113+ title = T_ ("Car charging station not integrated" ),
114+ ** doc
115+ )
116+ self .def_class_possible_merge (
117+ item = 8411 ,
118+ id = 3 ,
119+ level = 3 ,
120+ tags = ["merge" , "fix:imagery" , "fix:survey" , "fix:picture" ],
121+ title = T_ ("Car charging station, integration suggestion" ),
122+ ** doc
123+ )
124+ self .def_class_update_official (
125+ item = 8412 ,
126+ id = 4 ,
127+ level = 3 ,
128+ tags = ["merge" , "fix:imagery" , "fix:survey" , "fix:picture" ],
129+ title = T_ ("Car charging station update" ),
130+ ** doc
131+ )
63132
64133 self .init (
65134 "https://transport.data.gouv.fr/datasets/fichier-consolide-des-bornes-de-recharge-pour-vehicules-electriques/" ,
66135 "Stations de recharge pour véhicules électriques" ,
67- CSV (Source (attribution = "data.gouv.fr:Etalab" , millesime = "05/2022" ,
68- fileUrl = "https://raw.githubusercontent.com/Jungle-Bus/ref-EU-EVSE/gh-pages/opendata_stations.csv" )),
136+ CSV (
137+ Source (
138+ attribution = "data.gouv.fr:Etalab" ,
139+ millesime = "05/2022" ,
140+ fileUrl = "https://raw.githubusercontent.com/Jungle-Bus/ref-EU-EVSE/gh-pages/opendata_stations.csv" ,
141+ )
142+ ),
69143 Load_XY ("Xlongitude" , "Ylatitude" ),
70144 Conflate (
71145 select = Select (
72- types = ["nodes" , "ways" ],
73- tags = { "amenity" : "charging_station" } ),
146+ types = ["nodes" , "ways" ], tags = { "amenity" : "charging_station" }
147+ ),
74148 conflationDistance = 100 ,
75149 osmRef = "ref:EU:EVSE" ,
76150 mapping = Mapping (
77- static1 = {
78- "amenity" : "charging_station" ,
79- "motorcar" : "yes" },
151+ static1 = {"amenity" : "charging_station" , "motorcar" : "yes" },
80152 static2 = {"source" : self .source },
81153 mapping1 = {
82154 "operator" : "nom_operateur" ,
83155 "network" : "nom_enseigne" ,
84156 "owner" : "nom_amenageur" ,
85- "ref:EU:EVSE" : "id_station_itinerance"
157+ "ref:EU:EVSE" : "id_station_itinerance" ,
86158 },
87159 mapping2 = {
160+ "charging_station:output" : lambda fields : self .getPuissanceNominaleInKw (
161+ fields ["puissance_nominale" ]
162+ ),
88163 "operator:phone" : "telephone_operateur" ,
89164 "operator:email" : "contact_operateur" ,
90165 "start_date" : "date_mise_en_service" ,
91166 "capacity" : "nbre_pdc" ,
92- "bicycle" : lambda fields : "yes" if fields ["station_deux_roues" ] == "true" else None ,
93- "motorcycle" : lambda fields : "yes" if fields ["station_deux_roues" ] == "true" else None ,
94- "moped" : lambda fields : "yes" if fields ["station_deux_roues" ] == "true" else None ,
95- "motorcar" : lambda fields : "no" if fields ["station_deux_roues" ] == "true" else "yes" ,
167+ "bicycle" : lambda fields : (
168+ "yes" if fields ["station_deux_roues" ] == "true" else None
169+ ),
170+ "motorcycle" : lambda fields : (
171+ "yes" if fields ["station_deux_roues" ] == "true" else None
172+ ),
173+ "moped" : lambda fields : (
174+ "yes" if fields ["station_deux_roues" ] == "true" else None
175+ ),
176+ "motorcar" : lambda fields : (
177+ "no" if fields ["station_deux_roues" ] == "true" else "yes"
178+ ),
96179 "opening_hours" : "horaires_grouped" ,
97- "fee" : lambda fields : "yes" if fields ["gratuit_grouped" ] == "false" else ("no" if fields ["gratuit_grouped" ] == "true" else None ),
98- "authentication:none" : lambda fields : "yes" if fields ["paiement_acte_grouped" ] == "true" else None ,
99- "payment:credit_cards" : lambda fields : "yes" if fields ["paiement_cb_grouped" ] == "true" else ("no" if fields ["paiement_cb_grouped" ] == "false" else None ),
100- "reservation" : lambda fields : "yes" if fields ["reservation_grouped" ] == "true" else None ,
101- "wheelchair" : lambda fields : "yes" if fields ["accessibilite_pmr_grouped" ] == "Accessible mais non réservé PMR" else ("no" if fields ["accessibilite_pmr_grouped" ] == "Non accessible" else None ),
102- "socket:typee" : lambda fields : fields ["nb_EF_grouped" ] if fields ["nb_EF_grouped" ] != "0" else None ,
103- "socket:type2" : lambda fields : fields ["nb_T2_grouped" ] if fields ["nb_T2_grouped" ] != "0" else None ,
104- "socket:type2_combo" : lambda fields : fields ["nb_combo_ccs_grouped" ] if fields ["nb_combo_ccs_grouped" ] != "0" else None ,
105- "socket:chademo" : lambda fields : fields ["nb_chademo_grouped" ] if fields ["nb_chademo_grouped" ] != "0" else None ,
106- "wikimedia:network" : lambda fields : self .WIKIDATA_MAP .get (fields ["nom_enseigne" ].lower (), None ) if fields ["nom_enseigne" ] != "0" else None ,
180+ "fee" : lambda fields : (
181+ "yes"
182+ if fields ["gratuit_grouped" ] == "false"
183+ else ("no" if fields ["gratuit_grouped" ] == "true" else None )
184+ ),
185+ "authentication:none" : lambda fields : (
186+ "yes" if fields ["paiement_acte_grouped" ] == "true" else None
187+ ),
188+ "payment:credit_cards" : lambda fields : (
189+ "yes"
190+ if fields ["paiement_cb_grouped" ] == "true"
191+ else (
192+ "no"
193+ if fields ["paiement_cb_grouped" ] == "false"
194+ else None
195+ )
196+ ),
197+ "reservation" : lambda fields : (
198+ "yes" if fields ["reservation_grouped" ] == "true" else None
199+ ),
200+ "wheelchair" : lambda fields : (
201+ "yes"
202+ if fields ["accessibilite_pmr_grouped" ]
203+ == "Accessible mais non réservé PMR"
204+ else (
205+ "no"
206+ if fields ["accessibilite_pmr_grouped" ]
207+ == "Non accessible"
208+ else None
209+ )
210+ ),
211+ "socket:typee" : lambda fields : (
212+ fields ["nb_EF_grouped" ]
213+ if fields ["nb_EF_grouped" ] != "0"
214+ else None
215+ ),
216+ "socket:type2" : lambda fields : (
217+ fields ["nb_T2_grouped" ]
218+ if fields ["nb_T2_grouped" ] != "0"
219+ else None
220+ ),
221+ "socket:type2_combo" : lambda fields : (
222+ fields ["nb_combo_ccs_grouped" ]
223+ if fields ["nb_combo_ccs_grouped" ] != "0"
224+ else None
225+ ),
226+ "socket:chademo" : lambda fields : (
227+ fields ["nb_chademo_grouped" ]
228+ if fields ["nb_chademo_grouped" ] != "0"
229+ else None
230+ ),
231+ "wikimedia:network" : lambda fields : (
232+ self .WIKIDATA_MAP .get (fields ["nom_enseigne" ].lower (), None )
233+ if fields ["nom_enseigne" ] != "0"
234+ else None
235+ ),
236+ },
237+ text = lambda tags , fields : {
238+ "en" : "{0}, {1}, {2}" .format (
239+ fields ["nom_station" ],
240+ fields ["adresse_station" ],
241+ (
242+ fields ["observations" ]
243+ if fields ["observations" ] != "null"
244+ else "-"
245+ ),
246+ )
107247 },
108- text = lambda tags , fields : {"en" : "{0}, {1}, {2}" .format (fields ["nom_station" ], fields ["adresse_station" ], fields ["observations" ] if fields ["observations" ] != "null" else "-" )})))
248+ ),
249+ ),
250+ )
0 commit comments