1 package nl.mineleni.cbsviewer.servlet.gazetteer.lusclient;
2
3 import static nl.mineleni.cbsviewer.util.NumberConstants.OPENLS_ZOOMSCALE_GEMEENTE;
4 import static nl.mineleni.cbsviewer.util.NumberConstants.OPENLS_ZOOMSCALE_PLAATS;
5 import static nl.mineleni.cbsviewer.util.NumberConstants.OPENLS_ZOOMSCALE_PROVINCIE;
6 import static nl.mineleni.cbsviewer.util.NumberConstants.OPENLS_ZOOMSCALE_STANDAARD;
7
8 import org.slf4j.Logger;
9 import org.slf4j.LoggerFactory;
10
11
12
13
14
15
16 public class OpenLSClientAddress {
17
18
19
20 public static final String APPEND_GEMEENTE = " (gemeente)";
21
22
23
24
25 public static final String APPEND_PLAATS = " (plaats)";
26
27
28
29
30 public static final String APPEND_PROVINCIE = " (provincie)";
31
32
33 private static final Logger LOGGER = LoggerFactory
34 .getLogger(OpenLSClientAddress.class);
35
36 private String addressString = null;
37
38 private String countrySubdivision = "";
39
40 private String municipality = "";
41
42 private String municipalitySubdivision = "";
43
44 private String postalCode = "";
45
46 private String streetName = "";
47
48 private String streetNumber = "";
49
50 private String xCoord = "";
51
52 private String yCoord = "";
53
54
55
56
57 public OpenLSClientAddress() {
58 }
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80 public OpenLSClientAddress(final String xCoord, final String yCoord,
81 final String postalCode, final String streetName,
82 final String streetNumber, final String countrySubdivision,
83 final String municipality, final String municipalitySubdivision) {
84 this.xCoord = xCoord;
85 this.yCoord = yCoord;
86 this.postalCode = postalCode;
87 this.streetName = streetName;
88 this.streetNumber = streetNumber;
89 this.countrySubdivision = countrySubdivision;
90 this.municipality = municipality;
91 this.municipalitySubdivision = municipalitySubdivision;
92 }
93
94
95
96
97
98
99
100
101 public String getAddressString() {
102 if (this.addressString != null) { return this.addressString; }
103
104 final StringBuilder sb = new StringBuilder();
105 sb.append(this.streetName);
106 String spacer = sb.length() < 1 ? "" : " - ";
107
108 sb.append(sb.length() < 1 ? ""
109 : (!this.streetNumber.equals("") ? spacer + this.streetNumber
110 : ""));
111
112 sb.append(!this.postalCode.equals("") ? spacer + this.postalCode : "");
113
114 spacer = sb.length() < 1 ? "" : " - ";
115 sb.append(!this.municipalitySubdivision.equals("") ? spacer
116 + this.municipalitySubdivision + APPEND_PLAATS : "");
117
118 spacer = sb.toString().equals("") ? "" : " - ";
119 if (this.municipalitySubdivision.equals("")) {
120 sb.append(!this.municipality.equals("") ? spacer
121 + this.municipality + APPEND_GEMEENTE : "");
122 }
123
124 spacer = sb.length() < 1 ? "" : " - ";
125 if (this.municipality.equals("")) {
126 sb.append(!this.countrySubdivision.equals("") ? spacer
127 + this.countrySubdivision + APPEND_PROVINCIE : "");
128 }
129 this.addressString = sb.toString();
130 LOGGER.debug("Adres is: " + this.addressString);
131 return this.addressString;
132 }
133
134
135
136
137
138
139 public String getCountrySubdivision() {
140 return this.countrySubdivision;
141 }
142
143
144
145
146
147
148 public String getMunicipality() {
149 return this.municipality;
150 }
151
152
153
154
155
156
157 public String getMunicipalitySubdivision() {
158 return this.municipalitySubdivision;
159 }
160
161
162
163
164
165
166 public String getPostalCode() {
167 return this.postalCode;
168 }
169
170
171
172
173
174
175
176
177
178
179
180 public int getRadius() {
181
182 if (this.getAddressString().contains(APPEND_PLAATS)) {
183
184 return OPENLS_ZOOMSCALE_PLAATS.intValue();
185 } else if (this.getAddressString().contains(APPEND_GEMEENTE)) {
186
187 return OPENLS_ZOOMSCALE_GEMEENTE.intValue();
188 } else if (this.getAddressString().contains(APPEND_PROVINCIE)) {
189
190 return OPENLS_ZOOMSCALE_PROVINCIE.intValue();
191 } else {
192
193 return OPENLS_ZOOMSCALE_STANDAARD.intValue();
194 }
195 }
196
197
198
199
200
201
202 public String getStreetName() {
203 return this.streetName;
204 }
205
206
207
208
209
210
211 public String getStreetNumber() {
212 return this.streetNumber;
213 }
214
215
216
217
218
219
220 public String getxCoord() {
221 return this.xCoord;
222 }
223
224
225
226
227
228
229 public String getyCoord() {
230 return this.yCoord;
231 }
232
233
234
235
236
237
238 public boolean isValidClientAddress() {
239 if (this.xCoord.equals("")) { return false; }
240 if (this.yCoord.equals("")) { return false; }
241 if (this.postalCode.equals("") && this.streetName.equals("")
242 && this.countrySubdivision.equals("")
243 && this.municipality.equals("")
244 && this.municipalitySubdivision.equals("")) { return false; }
245 return true;
246 }
247
248
249
250
251
252
253
254 public void setCountrySubdivision(final String countrySubdivision) {
255 this.countrySubdivision = countrySubdivision;
256 }
257
258
259
260
261
262
263
264 public void setMunicipality(final String municipality) {
265 this.municipality = municipality;
266 }
267
268
269
270
271
272
273
274 public void setMunicipalitySubdivision(final String municipalitySubdivision) {
275 this.municipalitySubdivision = municipalitySubdivision;
276 }
277
278
279
280
281
282
283
284 public void setPostalCode(final String postalCode) {
285 this.postalCode = postalCode;
286 }
287
288
289
290
291
292
293
294 public void setStreetName(final String streetName) {
295 this.streetName = streetName;
296 }
297
298
299
300
301
302
303
304 public void setStreetNumber(final String streetNumber) {
305 this.streetNumber = streetNumber;
306 }
307
308
309
310
311
312
313
314 public void setxCoord(final String xcoord) {
315 this.xCoord = xcoord;
316 }
317
318
319
320
321
322
323
324 public void setyCoord(final String ycoord) {
325 this.yCoord = ycoord;
326 }
327
328
329
330
331
332
333
334 @Override
335 public String toString() {
336 return this.getAddressString();
337 }
338 }