forked from osm-fr/osmose-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
analyser_merge_power_plant_FR.py
88 lines (82 loc) · 5.19 KB
/
analyser_merge_power_plant_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
#!/usr/bin/env python
#-*- coding: utf-8 -*-
###########################################################################
## ##
## Copyrights Frédéric Rodrigo 2017 ##
## ##
## 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 modules.OsmoseTranslation import T_
from .Analyser_Merge import Analyser_Merge, Source, CSV, Load, Mapping, Select, Generate
from .Analyser_Merge_Geocode_Addok_CSV import Geocode_Addok_CSV
from modules import Stablehash
class Analyser_Merge_Power_Plant_FR(Analyser_Merge):
def __init__(self, config, logger = None):
Analyser_Merge.__init__(self, config, logger)
self.def_class_missing_official(item = 8270, id = 1, level = 3, tags = ['merge', 'power'],
title = T_('Power plant not integrated, geocoded at municipality level'))
self.init(
u"https://opendata.reseaux-energies.fr/explore/dataset/registre-national-installation-production-stockage-electricite-agrege-311217",
u"Registre national des installations de production d'électricité et de stockage",
CSV(Geocode_Addok_CSV(Source(attribution = u"data.gouv.fr:RTE", millesime = "2019",
fileUrl = u"https://opendata.reseaux-energies.fr/explore/dataset/registre-national-installation-production-stockage-electricite-agrege-311217/download/?format=csv&timezone=Europe/Berlin&use_labels_for_header=true"),
columns = 'commune', citycode = 'codeINSEECommune', delimiter = ';', logger = logger),
separator = u";"),
Load("longitude", "latitude",
where = lambda res: res.get('puisMaxRac') and float(res["puisMaxRac"]) > 1000,
map = lambda res: dict(res, **{"_x": float(res["_x"]) + (Stablehash.stablehash(str(res)) % 200 - 100) * 0.00001, "_y": float(res["_y"]) + (Stablehash.stablehash(str(res)) % 212 - 106) * 0.00001})),
Mapping(
select = Select(
types = ["ways", "relations"],
tags = {"power": "plant"}),
conflationDistance = 5000,
generate = Generate(
static1 = {
"power": "plant"},
static2 = {"source": self.source},
mapping1 = {
# No voltage tga on power=plant
#"voltage": lambda fields: (int(fields["Tension raccordement"].split(' ')[0]) * 1000) if fields.get("Tension raccordement") and fields["Tension raccordement"] not in ["< 45 kV", "BT", "HTA"] else None,
"plant:source": lambda fields: self.filiere[fields["filiere"]][fields["combustible"]],
"plant:output:electricity": lambda fields: int(float(fields["puisMaxRac"]) * 1000)},
mapping2 = {
"start_date": lambda fields: None if not fields.get(u"dateMiseEnService") else fields[u"dateMiseEnService"][0:4] if fields[u"dateMiseEnService"].endswith('-01-01') or fields[u"dateMiseEnService"].endswith('-12-31') else fields[u"dateMiseEnService"]},
tag_keep_multiple_values = ["voltage"],
text = lambda tags, fields: T_("Power plant {0}", ', '.join(filter(lambda res: res and res != 'None', [fields["nomInstallation"], fields["commune"]]))) )))
filiere = {
u"Autre": {
None: "",
u"Gaz": "",
},
u"Bioénergies": {
None: "",
u"Biogaz de station d'épuration": "biogas",
u"Bois": "biomass",
u"Déchets ménagers": "waste", # For RTE waste is bio-power!
u"Déchets papeterie": "biomass",
u"Gaz": "biogas",
},
u"Energies Marines": {None: ""},
u"Eolien": {None: "wind"},
u"Géothermie": {None: "geothermal"},
u"Hydraulique": {None: "hydro"},
u"Nucléaire": {"Uranium": "nuclear"},
u"Solaire": {None: "solar"},
u"Thermique non renouvelable": {
None: "",
u"Charbon": "coal",
u"Fioul": "oil",
u"Gaz": "gas"},
}