# HG changeset patch # User Ingo Weinzierl # Date 1271926476 0 # Node ID b5f4b6073cdeecec70812a9908d4532fa6c3912a # Parent 4bcf7bf4bfb7d5607e702f17ced7aa7ab0ee2f45 Calculate the depth in an odv export of a 'Profilschnitt' properly (issue217). gnv-artifacts/trunk@968 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 4bcf7bf4bfb7 -r b5f4b6073cde gnv-artifacts/ChangeLog --- a/gnv-artifacts/ChangeLog Wed Apr 21 13:38:26 2010 +0000 +++ b/gnv-artifacts/ChangeLog Thu Apr 22 08:54:36 2010 +0000 @@ -1,3 +1,14 @@ +2010-04-22 Ingo Weinzierl + + Issue217 + + * src/main/java/de/intevation/gnv/state/profile/verticalcrosssection/VerticalCrossSectionOutputState.java: + Added the cell width of the interpolation to the constructor call of the + odv export. + + * src/main/java/de/intevation/gnv/exports/VerticalCrossODVExport.java: + Corrected the depth calculation. + 2010-04-21 Ingo Weinzierl Issue228 diff -r 4bcf7bf4bfb7 -r b5f4b6073cde gnv-artifacts/src/main/java/de/intevation/gnv/exports/VerticalCrossODVExport.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/exports/VerticalCrossODVExport.java Wed Apr 21 13:38:26 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/exports/VerticalCrossODVExport.java Thu Apr 22 08:54:36 2010 +0000 @@ -66,6 +66,11 @@ protected double cellHeight; /** + * + */ + protected double cellWidth; + + /** * The raster array storing the values for a specific coordinate in a * specific depth. */ @@ -92,6 +97,7 @@ public VerticalCrossODVExport( Coordinate[] coordinates, double cellHeight, + double cellWidth, double[] raster, String time, int width, @@ -99,6 +105,7 @@ { this.coordinates = coordinates; this.cellHeight = cellHeight; + this.cellWidth = cellWidth; this.raster = raster; this.width = width; this.height = height; @@ -129,7 +136,7 @@ writer.writeNext(profile.getHeader()); - writeData(writer, time, coordinates, cellHeight, raster); + writeData(writer, time, coordinates, cellHeight, cellWidth, raster); writer.close(); } @@ -139,12 +146,15 @@ String time, Coordinate[] coordinates, double cellHeight, + double cellWidth, double[] raster) { if (logger.isDebugEnabled()) { logger.debug("+++++++ ODV Export information ++++++++++"); logger.debug("+ raster width: " + width); logger.debug("+ raster height: " + height); + logger.debug("+ cell height: " + cellHeight); + logger.debug("+ cell width: " + cellWidth); logger.debug("+ items in raster: " + raster.length); logger.debug("+ number of coordinates: " + coordinates.length); logger.debug("+++++++++++++++++++++++++++++++++++++++++"); @@ -159,7 +169,8 @@ logger.error(pe, pe); } - String[] row = new String[10]; + double maxDepth = 0; + String[] row = new String[10]; for (int i = 0; i < width; i++) { row[0] = "GNVExport"; row[1] = "Station_" + i; @@ -169,8 +180,9 @@ row[5] = Double.toString(coordinates[i].y); row[6] = "0"; - for (int j = 0; j < height; j++) { - if (j == 1) { + double depth = cellHeight * 0.5d; + for (int j = i; j < raster.length; j += width, depth += cellHeight) { + if (j == (i+width)) { row[0] = ""; row[1] = ""; row[2] = ""; @@ -180,21 +192,23 @@ row[6] = ""; } - // row[2] = Double.toString(depths[j]); - // - row[7] = Double.toString(j * cellHeight + cellHeight / 2d); + double value = raster[j]; + + row[7] = Double.toString(depth); row[8] = "1"; - double value = raster[i+(j*height)]; + row[9] = Double.toString(value); + + maxDepth = maxDepth >= depth ? maxDepth : depth; if (Double.isNaN(value)) { break; } - row[9] = Double.toString(value); - writer.writeNext(row); } } + + logger.info("Detected max depth: " + maxDepth); } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : diff -r 4bcf7bf4bfb7 -r b5f4b6073cde gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/verticalcrosssection/VerticalCrossSectionOutputState.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/verticalcrosssection/VerticalCrossSectionOutputState.java Wed Apr 21 13:38:26 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/verticalcrosssection/VerticalCrossSectionOutputState.java Thu Apr 22 08:54:36 2010 +0000 @@ -727,6 +727,7 @@ Export export = new VerticalCrossODVExport( interpol.getCoordinates(), interpol.getCellHeight(), + interpol.getCellWidth(), interpol.getRaster(), date, interpol.getWidth(),