comparison gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/horizontal/HorizontalProfileMeshCrossOutputState.java @ 418:6eae1efb5fc3

Horizontales Schnittprofil: Added some code to prevent needless null inserts if interpolating over large gaps. gnv-artifacts/trunk@466 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 21 Dec 2009 14:41:18 +0000
parents 04a242c67fe6
children c6a287398379
comparison
equal deleted inserted replaced
417:9697675ede21 418:6eae1efb5fc3
317 if (oa == null || ob == null) { 317 if (oa == null || ob == null) {
318 return true; 318 return true;
319 } 319 }
320 320
321 if (!oa.equals(ob)) { 321 if (!oa.equals(ob)) {
322 log.debug("+++++++++++++++ differs ++++++++++++++"); 322 if (log.isDebugEnabled()) {
323 log.debug(" " + oa + " != " + ob); 323 log.debug("+++++++++++++++ differs ++++++++++++++");
324 log.debug(" " + oa + " != " + ob);
325 }
324 return true; 326 return true;
325 } 327 }
326 } 328 }
327 return false; 329 return false;
328 } 330 }
339 private ArrayList<Point2d> points; 341 private ArrayList<Point2d> points;
340 private List<Coordinate> path; 342 private List<Coordinate> path;
341 private Collection<Result> output; 343 private Collection<Result> output;
342 private Result prototyp; 344 private Result prototyp;
343 private ResultDescriptor descriptor; 345 private ResultDescriptor descriptor;
346 private boolean lastWasSuccess;
344 347
345 public SectionHandler() { 348 public SectionHandler() {
346 } 349 }
347 350
348 public SectionHandler( 351 public SectionHandler(
351 ResultDescriptor descriptor 354 ResultDescriptor descriptor
352 ) { 355 ) {
353 this.path = path; 356 this.path = path;
354 this.output = output; 357 this.output = output;
355 this.descriptor = descriptor; 358 this.descriptor = descriptor;
356 points = new ArrayList<Point2d>(); 359 points = new ArrayList<Point2d>();
360 lastWasSuccess = true;
357 } 361 }
358 362
359 public void finish() { 363 public void finish() {
360 if (!points.isEmpty()) { 364 if (!points.isEmpty()) {
361 double distance = toKM( 365 double distance = toKM(
373 this); 377 this);
374 } 378 }
375 379
376 points.clear(); 380 points.clear();
377 } 381 }
382 lastWasSuccess = true;
378 } 383 }
379 384
380 public void setPrototyp(Result prototyp) { 385 public void setPrototyp(Result prototyp) {
381 this.prototyp = prototyp; 386 this.prototyp = prototyp;
382 } 387 }
407 } 412 }
408 if (colname.equals("SHAPE")) { 413 if (colname.equals("SHAPE")) {
409 result.addColumnValue(j, toWKT(coordinate)); 414 result.addColumnValue(j, toWKT(coordinate));
410 } 415 }
411 else if (colname.equals("YORDINATE")) { 416 else if (colname.equals("YORDINATE")) {
412 result.addColumnValue(j, success 417 if (success) {
413 ? Double.valueOf(coordinate.z) 418 result.addColumnValue(j, Double.valueOf(coordinate.z));
414 : null); 419 }
420 else if (lastWasSuccess) {
421 // only insert null if last was valid.
422 // This prevents flooding the result set with nulls
423 // if interpolating over a large gap.
424 result.addColumnValue(j, null);
425 }
415 } 426 }
416 else { 427 else {
417 result.addColumnValue(j, prototyp.getObject(i)); 428 result.addColumnValue(j, prototyp.getObject(i));
418 } 429 }
419 ++j; 430 ++j;
420 } 431 }
421 output.add(result); 432 output.add(result);
433 lastWasSuccess = success;
422 } 434 }
423 } // class SectionHandler 435 } // class SectionHandler
424 436
425 public static final double NAUTICAL_MILE = 1852.216d; 437 public static final double NAUTICAL_MILE = 1852.216d;
426 public static final double KILOMETER = 1000d; 438 public static final double KILOMETER = 1000d;

http://dive4elements.wald.intevation.org