1
2
3
4 package org.opentrafficsim.water.demand;
5
6 import org.locationtech.jts.geom.Coordinate;
7 import org.locationtech.jts.geom.MultiPolygon;
8 import org.locationtech.jts.geom.Point;
9 import org.opentrafficsim.water.AbstractNamed;
10 import org.opentrafficsim.water.RepeatableRandomStream;
11
12 import nl.tudelft.simulation.jstats.streams.StreamInterface;
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 public class Region extends AbstractNamed implements Comparable<Region>
30 {
31
32 private static final long serialVersionUID = 1L;
33
34
35 private Region superRegion;
36
37
38 private double inhabitants;
39
40
41 private double jobs;
42
43
44 private Coordinate center;
45
46
47 private MultiPolygon area;
48
49
50 private double exportTonTEU;
51
52
53 private double importTonTEU;
54
55
56 private double exportEmptyFactor;
57
58
59 private double importEmptyFactor;
60
61
62 private double currentImportTEUperYear = 0;
63
64
65 private double currentExportTEUperYear = 0;
66
67
68 private static StreamInterface randomStream = null;
69
70
71
72
73
74
75 public Region(final String name, final Region superRegion, final Coordinate center)
76 {
77 super(name);
78 this.superRegion = superRegion;
79 this.center = center;
80
81 randomStream = RepeatableRandomStream.create(this.getName());
82 }
83
84
85
86
87 public final Region getSuperRegion()
88 {
89 return this.superRegion;
90 }
91
92
93
94
95 public final void setJobs(final double jobs)
96 {
97 this.jobs = jobs;
98 }
99
100
101
102
103 public final double getJobs()
104 {
105 return (this.jobs > 0) ? this.jobs : 1;
106 }
107
108
109
110
111 public final Coordinate getCenter()
112 {
113 return this.center;
114 }
115
116
117
118
119 public final double getInhabitants()
120 {
121 return this.inhabitants;
122 }
123
124
125
126
127 protected final void setInhabitants(final double inhabitants)
128 {
129 this.inhabitants = inhabitants;
130 }
131
132
133
134
135 public final double getExportTonTEU()
136 {
137 return this.exportTonTEU;
138 }
139
140
141
142
143 public final void setExportTonTEU(final double exportTonTEU)
144 {
145 this.exportTonTEU = exportTonTEU;
146 }
147
148
149
150
151 public final double getImportTonTEU()
152 {
153 return this.importTonTEU;
154 }
155
156
157
158
159 public final void setImportTonTEU(final double importTonTEU)
160 {
161 this.importTonTEU = importTonTEU;
162 }
163
164
165
166
167 public final double getExportEmptyFactor()
168 {
169 return this.exportEmptyFactor;
170 }
171
172
173
174
175 public final void setExportEmptyFactor(final double exportEmptyFactor)
176 {
177 this.exportEmptyFactor = exportEmptyFactor;
178 }
179
180
181
182
183 public final double getImportEmptyFactor()
184 {
185 return this.importEmptyFactor;
186 }
187
188
189
190
191 public final void setImportEmptyFactor(final double importEmptyFactor)
192 {
193 this.importEmptyFactor = importEmptyFactor;
194 }
195
196
197
198
199 public final double getCurrentExportTEUperYear()
200 {
201 return this.currentExportTEUperYear;
202 }
203
204
205
206
207 public final void setCurrentExportTEUperYear(final double newExportTEUPerYear)
208 {
209 this.currentExportTEUperYear = newExportTEUPerYear;
210 }
211
212
213
214
215 public final void addCurrentExportTEUperYear(final double newExportTEUPerYear)
216 {
217 this.currentExportTEUperYear += newExportTEUPerYear;
218 }
219
220
221
222
223 public final double getCurrentImportTEUperYear()
224 {
225 return this.currentImportTEUperYear;
226 }
227
228
229
230
231 public final void setCurrentImportTEUperYear(final double newImportTEUPerYear)
232 {
233 this.currentImportTEUperYear = newImportTEUPerYear;
234 }
235
236
237
238
239 public final void addCurrentImportTEUperYear(final double newImportTEUPerYear)
240 {
241 this.currentImportTEUperYear += newImportTEUPerYear;
242 }
243
244
245
246
247 public final MultiPolygon getArea()
248 {
249 return this.area;
250 }
251
252
253
254
255 public final void setArea(final MultiPolygon area)
256 {
257 this.area = area;
258 }
259
260
261
262
263
264 public final boolean isInArea(final Point p)
265 {
266 return this.area.contains(p);
267 }
268
269
270 @Override
271 public final int compareTo(final Region other)
272 {
273 return this.getName().compareTo(other.getName());
274 }
275
276
277 @Override
278 @SuppressWarnings("checkstyle:designforextension")
279 public String toString()
280 {
281 return "Region " + this.getName();
282 }
283
284 }