Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/collections/AttributeWriter.java @ 6957:67e01d9c0519
AttributeWriter: Slightly improved variable naming and comments.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Tue, 03 Sep 2013 10:31:26 +0200 |
parents | d4a3031448d3 |
children | d2bf655bd278 |
comparison
equal
deleted
inserted
replaced
6956:33f3cc375a23 | 6957:67e01d9c0519 |
---|---|
258 // Fill/correct "gaps" (e.g. position 1,2,5 are taken, after gap filling | 258 // Fill/correct "gaps" (e.g. position 1,2,5 are taken, after gap filling |
259 // expect positions 1,2,3 [5->3]) | 259 // expect positions 1,2,3 [5->3]) |
260 // Preparations to be able to detect gaps. | 260 // Preparations to be able to detect gaps. |
261 Map<Integer, ManagedFacet> mfmap = | 261 Map<Integer, ManagedFacet> mfmap = |
262 new HashMap<Integer, ManagedFacet>(); | 262 new HashMap<Integer, ManagedFacet>(); |
263 int max = 0; | 263 int numFacets = 0; |
264 for (ManagedFacet mf: currentFacets) { | 264 for (ManagedFacet mf: currentFacets) { |
265 int pos = mf.getPosition(); | 265 int pos = mf.getPosition(); |
266 mfmap.put(Integer.valueOf(pos), mf); | 266 mfmap.put(Integer.valueOf(pos), mf); |
267 if (pos > max) max = pos; | 267 if (pos > numFacets) numFacets = pos; |
268 } | 268 } |
269 | 269 |
270 // Finally do gap correction. | 270 // TODO issue1458: debug what happens |
271 if (max != currentFacets.size()) { | 271 |
272 // Finally do gap correction | |
273 // (note that posistions start at 1, not at zero). | |
274 if (numFacets != currentFacets.size()) { | |
272 int gap = 0; | 275 int gap = 0; |
273 for (int i = 1; i <= max; i++) { | 276 for (int i = 1; i <= numFacets; i++) { |
274 ManagedFacet mf = mfmap.get(Integer.valueOf(i)); | 277 ManagedFacet mf = mfmap.get(Integer.valueOf(i)); |
275 if (mf == null) { | 278 if (mf == null) { |
276 gap++; | 279 gap++; |
277 continue; | 280 continue; |
278 } | 281 } |
279 mf.setPosition(mf.getPosition() - gap); | 282 mf.setPosition(mf.getPosition() - gap); |
280 } | 283 } |
281 } | 284 } |
282 | 285 |
283 // Now add all facets. | 286 // Now add all facets. |
284 for (ManagedFacet oldMF: currentFacets) { | 287 for (ManagedFacet facet: currentFacets) { |
285 attribute.addFacet(outputName, oldMF); | 288 attribute.addFacet(outputName, facet); |
286 } | 289 } |
287 | 290 |
288 return !currentFacets.isEmpty(); | 291 return !currentFacets.isEmpty(); |
289 } | 292 } |
290 | 293 |