-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDensity.pde
More file actions
147 lines (94 loc) · 2.91 KB
/
Copy pathDensity.pde
File metadata and controls
147 lines (94 loc) · 2.91 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/** Calculates statistical data
*/
class BuildingCounter extends ArrayList{
int[] buildingCounter;
String[] nameList = {
"Turm","Scheibe","Block","Patio","Reihe","Frei","Box","BoxKlein", "Andere"
};
// text position
float x = 10;
float y = 40;
PFont font;
PFont fontBig;
BuildingCounter(){
super();
buildingCounter = new int[nameList.length -1]; // dont count andere buildings
font = loadFont("DIN_1451_Mittelschrift-30.vlw");
fontBig = loadFont("DIN_1451_Mittelschrift-80.vlw");
}
int getIndexForName(String buildingName){
for (int i=0; i < nameList.length; i++){
if (nameList[i].equals(buildingName)){
return i;
}
}
return -1; // building name not found
}
void addBuilding(Building building, int buildDepth){
int index = getIndexForName(building.name);
if (index < 0) // return if building is of type andere
return;
if (index == 0){ // building is a tower
buildingCounter[index] += (1+( buildDepth /(building.fieldsY + 10)));
}
else {
buildingCounter[index] += buildDepth / building.fieldsY;
}
}
void removeBuilding(Building building, int buildDepth){
int index = getIndexForName(building.name);
if (index < 0) // return if building is of type andere
return;
if (index == 0){ // building is a tower
buildingCounter[index] -= (1+( buildDepth /(building.fieldsY + 10)));
}
else {
buildingCounter[index] -= buildDepth / building.fieldsY;
}
if (buildingCounter[index] < 0)
buildingCounter[index] =0;
}
void toConsole(){
for(int i=0; i < buildingCounter.length; i++){
print(nameList[i] + ": " + buildingCounter[i] + " ");
}
}
void display(){
fill(50);
textFont(font, 30);
float[] values = this.densityCalc();
text("BGF: "+values[0] + " m² Bebaute Fläche: " + values[1] + " m² GFZ: "+ values[2], x, y);
}
void pgDisplay(PGraphics pg){
pg.fill(50);
pg.textFont(font, 30);
float[] values = this.densityCalc();
pg.text("BGF: "+values[0] + " m² Bebaute Fläche: " + values[1] + " m² GFZ: "+ values[2], x, y);
}
void historyDisplay(PGraphics pg){
float[] values = this.densityCalc();
pg.fill(50);
pg.textFont(fontBig, 80);
float yy = y;
y += 80;
pg.text("GFZ: "+ values[2], x, y);
y = yy;
}
float[] densityCalc(){
int bgf =0;
int areabuilt = 0;
for(int i=0; i < buildingCounter.length; i++){
bgf += buildingCounter[i]*buildingPlans[i].bgf;
areabuilt += buildingCounter[i]*buildingPlans[i].groundArea;
// println("GA: "+buildingPlans[i].groundArea);
}
float gfz = bgf/52900.0;
gfz = round(gfz*100);
gfz/= 100;
float[] values = new float[3];
values[0] = bgf;
values[1] = areabuilt;
values[2] = gfz;
return values;
}
}