Mercurial > dive4elements > gnv-client
changeset 852:b5f4b6073cde
Calculate the depth in an odv export of a 'Profilschnitt' properly (issue217).
gnv-artifacts/trunk@968 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 22 Apr 2010 08:54:36 +0000 |
parents | 4bcf7bf4bfb7 |
children | 164d102b0af5 |
files | gnv-artifacts/ChangeLog gnv-artifacts/src/main/java/de/intevation/gnv/exports/VerticalCrossODVExport.java gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/verticalcrosssection/VerticalCrossSectionOutputState.java |
diffstat | 3 files changed, 36 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- 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 <ingo.weinzierl@intevation.de> + + 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 <ingo.weinzierl@intevation.de> Issue228
--- 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 :
--- 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(),