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,204 @@ class Analyser_Merge_Charging_station_FR(Analyser_Merge_Point):
3845 "Izivia" : "Q86671322" ,
3946 }
4047
48+ def keepMaxValueIfEnum (str ):
49+ # si la valeur contient un ; on sépare et on prend la plus haute valeur
50+ if ";" in str :
51+ boom = str .split (";" )
52+ max = 0
53+ for p in boom :
54+ p = int (p )
55+ if p > max :
56+ max = p
57+
58+ if max > 0 :
59+ str = max
60+ return str
61+
62+ def getPuissanceNominaleInKw (self , puissance_nominale ):
63+ # deviner un nombre en kw dans la puissance nominale,
64+ # les valeurs de plus de 401 sont à diviser par mille,
65+ # il faut aussi évacuer le leftpad de 0
66+ if puissance_nominale is None :
67+ return None
68+ puissance_nominale = str (puissance_nominale )
69+
70+ if puissance_nominale is None :
71+ return None
72+ # Convertir en chaîne et supprimer les zéros à gauche
73+ puissance_str = str (puissance_nominale ).lstrip ("0" )
74+ if not puissance_str :
75+ return 0
76+
77+ puissance_str = self .keepMaxValueIfEnum (puissance_str )
78+ # Reconvertir en entier
79+ puissance_nominale = int (puissance_str )
80+ # puisssance max de borne en kW connue
81+ if puissance_nominale > 401 :
82+ return str (puissance_nominale / 1000 ) + " kW"
83+ else :
84+ return str (puissance_nominale ) + " kW"
85+
4186 def __init__ (self , config , logger = None ):
4287 Analyser_Merge_Point .__init__ (self , config , logger )
4388 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 )
89+ detail = T_ (
90+ """A car charging station may be here but is not mapped. The list of the
91+ charging stations comes from a database published by Etalab. This database
92+ brings together information published by the various local authorities and
93+ networks in France."""
94+ ),
95+ fix = T_ (
96+ """See [the
97+ mapping](https://wiki.openstreetmap.org/wiki/France/data.gouv.fr/Bornes_de_Recharge_pour_V%C3%A9hicules_%C3%89lectriques)
98+ on the wiki. Add a node or add tags if already existing."""
99+ ),
100+ trap = T_ (
101+ """The initial information corresponds to recharging pools and devices and not to
102+ stations, so some values are worth checking in the field. For instance, an open data point
103+ with `capacity=6` can sometimes match to 3 charging station with `capacity=2`"""
104+ ),
105+ )
106+ self .def_class_missing_official (
107+ item = 8410 ,
108+ id = 1 ,
109+ level = 3 ,
110+ tags = ["merge" , "fix:imagery" , "fix:survey" , "fix:picture" ],
111+ title = T_ ("Car charging station not integrated" ),
112+ ** doc
113+ )
114+ self .def_class_possible_merge (
115+ item = 8411 ,
116+ id = 3 ,
117+ level = 3 ,
118+ tags = ["merge" , "fix:imagery" , "fix:survey" , "fix:picture" ],
119+ title = T_ ("Car charging station, integration suggestion" ),
120+ ** doc
121+ )
122+ self .def_class_update_official (
123+ item = 8412 ,
124+ id = 4 ,
125+ level = 3 ,
126+ tags = ["merge" , "fix:imagery" , "fix:survey" , "fix:picture" ],
127+ title = T_ ("Car charging station update" ),
128+ ** doc
129+ )
63130
64131 self .init (
65132 "https://transport.data.gouv.fr/datasets/fichier-consolide-des-bornes-de-recharge-pour-vehicules-electriques/" ,
66133 "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" )),
134+ CSV (
135+ Source (
136+ attribution = "data.gouv.fr:Etalab" ,
137+ millesime = "05/2022" ,
138+ fileUrl = "https://raw.githubusercontent.com/Jungle-Bus/ref-EU-EVSE/gh-pages/opendata_stations.csv" ,
139+ )
140+ ),
69141 Load_XY ("Xlongitude" , "Ylatitude" ),
70142 Conflate (
71143 select = Select (
72- types = ["nodes" , "ways" ],
73- tags = { "amenity" : "charging_station" } ),
144+ types = ["nodes" , "ways" ], tags = { "amenity" : "charging_station" }
145+ ),
74146 conflationDistance = 100 ,
75147 osmRef = "ref:EU:EVSE" ,
76148 mapping = Mapping (
77- static1 = {
78- "amenity" : "charging_station" ,
79- "motorcar" : "yes" },
149+ static1 = {"amenity" : "charging_station" , "motorcar" : "yes" },
80150 static2 = {"source" : self .source },
81151 mapping1 = {
82152 "operator" : "nom_operateur" ,
83153 "network" : "nom_enseigne" ,
84154 "owner" : "nom_amenageur" ,
85- "ref:EU:EVSE" : "id_station_itinerance"
155+ "ref:EU:EVSE" : "id_station_itinerance" ,
86156 },
87157 mapping2 = {
158+ "charging_station:output" : lambda fields : self .getPuissanceNominaleInKw (
159+ fields ["puissance_nominale" ]
160+ ),
88161 "operator:phone" : "telephone_operateur" ,
89162 "operator:email" : "contact_operateur" ,
90163 "start_date" : "date_mise_en_service" ,
91164 "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" ,
165+ "bicycle" : lambda fields : (
166+ "yes" if fields ["station_deux_roues" ] == "true" else None
167+ ),
168+ "motorcycle" : lambda fields : (
169+ "yes" if fields ["station_deux_roues" ] == "true" else None
170+ ),
171+ "moped" : lambda fields : (
172+ "yes" if fields ["station_deux_roues" ] == "true" else None
173+ ),
174+ "motorcar" : lambda fields : (
175+ "no" if fields ["station_deux_roues" ] == "true" else "yes"
176+ ),
96177 "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 ,
178+ "fee" : lambda fields : (
179+ "yes"
180+ if fields ["gratuit_grouped" ] == "false"
181+ else ("no" if fields ["gratuit_grouped" ] == "true" else None )
182+ ),
183+ "authentication:none" : lambda fields : (
184+ "yes" if fields ["paiement_acte_grouped" ] == "true" else None
185+ ),
186+ "payment:credit_cards" : lambda fields : (
187+ "yes"
188+ if fields ["paiement_cb_grouped" ] == "true"
189+ else (
190+ "no"
191+ if fields ["paiement_cb_grouped" ] == "false"
192+ else None
193+ )
194+ ),
195+ "reservation" : lambda fields : (
196+ "yes" if fields ["reservation_grouped" ] == "true" else None
197+ ),
198+ "wheelchair" : lambda fields : (
199+ "yes"
200+ if fields ["accessibilite_pmr_grouped" ]
201+ == "Accessible mais non réservé PMR"
202+ else (
203+ "no"
204+ if fields ["accessibilite_pmr_grouped" ]
205+ == "Non accessible"
206+ else None
207+ )
208+ ),
209+ "socket:typee" : lambda fields : (
210+ fields ["nb_EF_grouped" ]
211+ if fields ["nb_EF_grouped" ] != "0"
212+ else None
213+ ),
214+ "socket:type2" : lambda fields : (
215+ fields ["nb_T2_grouped" ]
216+ if fields ["nb_T2_grouped" ] != "0"
217+ else None
218+ ),
219+ "socket:type2_combo" : lambda fields : (
220+ fields ["nb_combo_ccs_grouped" ]
221+ if fields ["nb_combo_ccs_grouped" ] != "0"
222+ else None
223+ ),
224+ "socket:chademo" : lambda fields : (
225+ fields ["nb_chademo_grouped" ]
226+ if fields ["nb_chademo_grouped" ] != "0"
227+ else None
228+ ),
229+ "wikimedia:network" : lambda fields : (
230+ self .WIKIDATA_MAP .get (fields ["nom_enseigne" ].lower (), None )
231+ if fields ["nom_enseigne" ] != "0"
232+ else None
233+ ),
234+ },
235+ text = lambda tags , fields : {
236+ "en" : "{0}, {1}, {2}" .format (
237+ fields ["nom_station" ],
238+ fields ["adresse_station" ],
239+ (
240+ fields ["observations" ]
241+ if fields ["observations" ] != "null"
242+ else "-"
243+ ),
244+ )
107245 },
108- text = lambda tags , fields : {"en" : "{0}, {1}, {2}" .format (fields ["nom_station" ], fields ["adresse_station" ], fields ["observations" ] if fields ["observations" ] != "null" else "-" )})))
246+ ),
247+ ),
248+ )
0 commit comments