@@ -3,6 +3,15 @@ export function toCSV(pointData) {
3
3
x : 'lat' ,
4
4
y : 'lng' ,
5
5
houseComment : 'kommentar' ,
6
+ entityAddress : 'adresse' ,
7
+ entityPLZ : 'plz' ,
8
+ entityType : 'type' ,
9
+ houseArea : 'fleach' ,
10
+ houseCosts : 'kosten' ,
11
+ houseMonument : 'denkmal' ,
12
+ houseName : 'name' ,
13
+ housePrio : 'prio' ,
14
+ houseSavingPotential : 'einsparpotenzial' ,
6
15
}
7
16
const verbrauchWant = [
8
17
'entityId' ,
@@ -21,37 +30,76 @@ export function toCSV(pointData) {
21
30
'renovationsSavingsMax' ,
22
31
'renovationsSavingsMin' ,
23
32
]
33
+ const sanierungWant = [
34
+ 'entityAddress' ,
35
+ // 'entityId',
36
+ 'entityPLZ' ,
37
+ 'entityType' ,
38
+ 'houseArea' ,
39
+ 'houseCosts' ,
40
+ 'houseMonument' ,
41
+ 'houseName' ,
42
+ 'housePrio' ,
43
+ 'houseSavingPotential' ,
44
+ ]
45
+
24
46
let headersVerbrauch = ''
25
47
verbrauchWant . forEach ( ( head , i ) => {
26
48
headersVerbrauch += headerTranslation [ head ] ? headerTranslation [ head ] : head
27
49
headersVerbrauch += verbrauchWant . length - 1 == i ? '' : ','
28
50
} )
29
51
headersVerbrauch += '\n'
30
52
53
+ let headersSanierungen = ''
54
+ sanierungWant . forEach ( ( head , i ) => {
55
+ headersSanierungen += headerTranslation [ head ]
56
+ ? headerTranslation [ head ]
57
+ : head
58
+ headersSanierungen += sanierungWant . length - 1 == i ? '' : ','
59
+ } )
60
+ headersSanierungen += '\n'
61
+
31
62
let rowsVerbrauch = ''
32
63
pointData . features . forEach ( ( feat ) => {
64
+ console . log ( feat . properties . renovations )
33
65
verbrauchWant . forEach ( ( d , ii ) => {
34
66
rowsVerbrauch += Number ( feat . properties [ d ] )
35
67
? feat . properties [ d ]
36
68
: '"' + feat . properties [ d ] + '"'
37
69
const comma = verbrauchWant . length - 1 == ii ? '' : ','
38
70
rowsVerbrauch += comma
39
71
} )
40
-
41
72
rowsVerbrauch += '\n'
42
73
} )
43
74
75
+ let rowsSanierung = ''
76
+ pointData . features . forEach ( ( feat ) => {
77
+ feat . properties . renovations . forEach ( ( renovation , ii ) => {
78
+ sanierungWant . forEach ( ( d , ii ) => {
79
+ rowsSanierung += Number ( renovation [ d ] )
80
+ ? renovation [ d ]
81
+ : '"' + renovation [ d ] + '"'
82
+ const comma = sanierungWant . length - 1 == ii ? '' : ','
83
+ rowsSanierung += comma
84
+ } )
85
+ rowsSanierung += '\n'
86
+ } )
87
+ } )
88
+
44
89
let csvVerbrauch =
45
90
'data:text/csv;charset=utf-8,' + headersVerbrauch + rowsVerbrauch
46
91
92
+ let csvSanierung =
93
+ 'data:text/csv;charset=utf-8,' + headersSanierungen + rowsSanierung
94
+
47
95
var encodedUri = encodeURI ( csvVerbrauch )
48
96
var link = document . createElement ( 'a' )
49
97
link . setAttribute ( 'href' , encodedUri )
50
- link . setAttribute ( 'download' , 'odis-verbrauche .csv' )
98
+ link . setAttribute ( 'download' , 'odis-verbrauch .csv' )
51
99
document . body . appendChild ( link ) // Required for FF
52
100
link . click ( ) // This will download the data file named "my_data.csv".
53
101
54
- var encodedUri = encodeURI ( csvVerbrauch )
102
+ var encodedUri = encodeURI ( csvSanierung )
55
103
var link2 = document . createElement ( 'a' )
56
104
link2 . setAttribute ( 'href' , encodedUri )
57
105
link2 . setAttribute ( 'download' , 'odis-sanierungen.csv' )
0 commit comments