|
4 | 4 | ###########################################################################
|
5 | 5 | ## ##
|
6 | 6 | ## Copyrights Noémie Lehuby 2020 ##
|
| 7 | +## Baptiste Lemoine 2023 ## |
7 | 8 | ## ##
|
8 | 9 | ## This program is free software: you can redistribute it and/or modify ##
|
9 | 10 | ## it under the terms of the GNU General Public License as published by ##
|
|
21 | 22 | ###########################################################################
|
22 | 23 |
|
23 | 24 | from modules.OsmoseTranslation import T_
|
24 |
| -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 | +) |
25 | 34 |
|
26 | 35 |
|
27 | 36 | class Analyser_Merge_Charging_station_FR(Analyser_Merge_Point):
|
| 37 | + WIKIDATA_MAP = { |
| 38 | + "ionity": "Q42717773", |
| 39 | + "bouygues": "Q3046208", |
| 40 | + "freshmile": "Q111209120", |
| 41 | + "lidl": "Q115764851", |
| 42 | + "Electra": "Q128592938", |
| 43 | + "TotalEnergies Charging Services": "Q154037", |
| 44 | + "Last Mile Solutions": "Q109733858", |
| 45 | + "Izivia": "Q86671322", |
| 46 | + } |
| 47 | + |
| 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 | + |
28 | 88 | def __init__(self, config, logger=None):
|
29 | 89 | Analyser_Merge_Point.__init__(self, config, logger)
|
30 | 90 | doc = dict(
|
31 |
| - detail = T_( |
32 |
| -'''A car charging station may be here but is not mapped. The list of the |
33 |
| -charging stations comes from a database published by Etalab. This database |
34 |
| -brings together information published by the various local authorities and |
35 |
| -networks in France.'''), |
36 |
| - fix = T_( |
37 |
| -'''See [the |
38 |
| -mapping](https://wiki.openstreetmap.org/wiki/France/data.gouv.fr/Bornes_de_Recharge_pour_V%C3%A9hicules_%C3%89lectriques) |
39 |
| -on the wiki. Add a node or add tags if already existing.'''), |
40 |
| - trap = T_( |
41 |
| -'''The initial information corresponds to recharging pools and devices and not to |
42 |
| -stations, so some values are worth checking in the field. For instance, an open data point |
43 |
| -with `capacity=6` can sometimes match to 3 charging station with `capacity=2`''')) |
44 |
| - self.def_class_missing_official(item = 8410, id = 1, level = 3, tags = ['merge', 'fix:imagery', 'fix:survey', 'fix:picture'], |
45 |
| - title = T_('Car charging station not integrated'), **doc) |
46 |
| - self.def_class_possible_merge(item = 8411, id = 3, level = 3, tags = ['merge', 'fix:imagery', 'fix:survey', 'fix:picture'], |
47 |
| - title = T_('Car charging station, integration suggestion'), **doc) |
48 |
| - self.def_class_update_official(item = 8412, id = 4, level = 3, tags = ['merge', 'fix:imagery', 'fix:survey', 'fix:picture'], |
49 |
| - 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 | + ) |
50 | 132 |
|
51 | 133 | self.init(
|
52 | 134 | "https://transport.data.gouv.fr/datasets/fichier-consolide-des-bornes-de-recharge-pour-vehicules-electriques/",
|
53 | 135 | "Stations de recharge pour véhicules électriques",
|
54 |
| - CSV(Source(attribution="data.gouv.fr:Etalab", millesime="05/2022", |
55 |
| - 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 | + ), |
56 | 143 | Load_XY("Xlongitude", "Ylatitude"),
|
57 | 144 | Conflate(
|
58 | 145 | select=Select(
|
59 |
| - types=["nodes", "ways"], |
60 |
| - tags={"amenity": "charging_station"}), |
| 146 | + types=["nodes", "ways"], tags={"amenity": "charging_station"} |
| 147 | + ), |
61 | 148 | conflationDistance=100,
|
62 | 149 | osmRef="ref:EU:EVSE",
|
63 | 150 | mapping=Mapping(
|
64 |
| - static1={ |
65 |
| - "amenity": "charging_station", |
66 |
| - "motorcar": "yes"}, |
| 151 | + static1={"amenity": "charging_station", "motorcar": "yes"}, |
67 | 152 | static2={"source": self.source},
|
68 | 153 | mapping1={
|
69 | 154 | "operator": "nom_operateur",
|
70 | 155 | "network": "nom_enseigne",
|
71 | 156 | "owner": "nom_amenageur",
|
72 |
| - "ref:EU:EVSE": "id_station_itinerance" |
| 157 | + "ref:EU:EVSE": "id_station_itinerance", |
73 | 158 | },
|
74 | 159 | mapping2={
|
75 |
| - "email": "contact_operateur", |
76 |
| - "phone": "telephone_operateur", |
| 160 | + "charging_station:output": lambda fields: self.getPuissanceNominaleInKw( |
| 161 | + fields["puissance_nominale"] |
| 162 | + ), |
| 163 | + "operator:phone": "telephone_operateur", |
| 164 | + "operator:email": "contact_operateur", |
| 165 | + "start_date": "date_mise_en_service", |
77 | 166 | "capacity": "nbre_pdc",
|
78 |
| - "bicycle": lambda fields: "yes" if fields["station_deux_roues"] == "true" else None, |
79 |
| - "motorcycle": lambda fields: "yes" if fields["station_deux_roues"] == "true" else None, |
80 |
| - "moped": lambda fields: "yes" if fields["station_deux_roues"] == "true" else None, |
81 |
| - "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 | + ), |
82 | 179 | "opening_hours": "horaires_grouped",
|
83 |
| - "fee": lambda fields: "yes" if fields["gratuit_grouped"] == "false" else ("no" if fields["gratuit_grouped"] == "true" else None), |
84 |
| - "authentication:none": lambda fields: "yes" if fields["paiement_acte_grouped"] == "true" else None, |
85 |
| - "payment:credit_cards": lambda fields: "yes" if fields["paiement_cb_grouped"] == "true" else ("no" if fields["paiement_cb_grouped"] == "false" else None), |
86 |
| - "reservation": lambda fields: "yes" if fields["reservation_grouped"] == "true" else None, |
87 |
| - "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), |
88 |
| - "socket:typee": lambda fields: fields["nb_EF_grouped"] if fields["nb_EF_grouped"] != "0" else None, |
89 |
| - "socket:type2": lambda fields: fields["nb_T2_grouped"] if fields["nb_T2_grouped"] != "0" else None, |
90 |
| - "socket:type2_combo": lambda fields: fields["nb_combo_ccs_grouped"] if fields["nb_combo_ccs_grouped"] != "0" else None, |
91 |
| - "socket:chademo": lambda fields: fields["nb_chademo_grouped"] if fields["nb_chademo_grouped"] != "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 | + ) |
92 | 247 | },
|
93 |
| - 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