Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/math/Interpolation3D.java @ 445:f42ed4f10b79
Fixed some bugs and create "Profilschnitt" polygons via configuration.
gnv-artifacts/trunk@493 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 30 Dec 2009 23:02:10 +0000 |
parents | 0eed5749fd63 |
children | f5a041000357 |
comparison
equal
deleted
inserted
replaced
444:85f48e287fb3 | 445:f42ed4f10b79 |
---|---|
1 package de.intevation.gnv.math; | 1 package de.intevation.gnv.math; |
2 | 2 |
3 import java.util.List; | 3 import java.util.List; |
4 import java.util.Arrays; | 4 import java.util.Arrays; |
5 import java.util.ArrayList; | |
5 import java.util.Collections; | 6 import java.util.Collections; |
7 | |
8 import java.io.Serializable; | |
9 | |
10 import java.awt.Dimension; | |
6 | 11 |
7 import com.vividsolutions.jts.geom.Coordinate; | 12 import com.vividsolutions.jts.geom.Coordinate; |
8 import com.vividsolutions.jts.geom.Envelope; | 13 import com.vividsolutions.jts.geom.Envelope; |
9 | 14 |
10 import com.vividsolutions.jts.index.quadtree.Quadtree; | 15 import com.vividsolutions.jts.index.quadtree.Quadtree; |
11 | 16 |
12 import org.apache.log4j.Logger; | 17 import org.apache.log4j.Logger; |
13 | 18 |
19 /** | |
20 * @author Sascha L. Teichmann (sascha.teichmann@intevation.de) | |
21 */ | |
14 public class Interpolation3D | 22 public class Interpolation3D |
23 implements Serializable | |
15 { | 24 { |
16 private static Logger log = Logger.getLogger(Interpolation3D.class); | 25 private static Logger log = Logger.getLogger(Interpolation3D.class); |
17 | 26 |
18 public static final int DEFAULT_WIDTH = 1024; | 27 public static final int DEFAULT_WIDTH = 1024; |
19 public static final int DEFAULT_HEIGHT = 768; | 28 public static final int DEFAULT_HEIGHT = 768; |
24 protected double [] raster; | 33 protected double [] raster; |
25 protected double [] depths; | 34 protected double [] depths; |
26 | 35 |
27 public Interpolation3D() { | 36 public Interpolation3D() { |
28 this(DEFAULT_WIDTH, DEFAULT_HEIGHT); | 37 this(DEFAULT_WIDTH, DEFAULT_HEIGHT); |
38 } | |
39 | |
40 public Interpolation3D(Dimension size) { | |
41 this(size.width, size.height); | |
29 } | 42 } |
30 | 43 |
31 public Interpolation3D(int width, int height) { | 44 public Interpolation3D(int width, int height) { |
32 this.width = width; | 45 this.width = width; |
33 this.height = height; | 46 this.height = height; |
45 return raster; | 58 return raster; |
46 } | 59 } |
47 | 60 |
48 public double [] getDepths() { | 61 public double [] getDepths() { |
49 return depths; | 62 return depths; |
63 } | |
64 | |
65 public double getMaxDepth() { | |
66 double maxDepth = Double.MAX_VALUE; | |
67 for (int i = depths!=null?depths.length-1:0; i >= 0; --i) { | |
68 if (!Double.isNaN(depths[i]) && depths[i] < maxDepth) { | |
69 maxDepth = depths[i]; | |
70 } | |
71 } | |
72 return maxDepth; | |
50 } | 73 } |
51 | 74 |
52 public boolean interpolate( | 75 public boolean interpolate( |
53 List<? extends Coordinate> path, | 76 List<? extends Coordinate> path, |
54 List<? extends XYColumn> points, | 77 List<? extends XYColumn> points, |
112 if (maxDepth == Double.MAX_VALUE) { | 135 if (maxDepth == Double.MAX_VALUE) { |
113 log.warn("no depth found -> no interpolation"); | 136 log.warn("no depth found -> no interpolation"); |
114 return false; | 137 return false; |
115 } | 138 } |
116 | 139 |
140 double cellHeight = Math.abs(maxDepth)/height; | |
141 | |
117 if (debug) { | 142 if (debug) { |
118 log.debug("max depth found: " + maxDepth); | 143 log.debug("max depth found: " + maxDepth); |
119 } | |
120 | |
121 double cellHeight = Math.abs(maxDepth)/height; | |
122 | |
123 if (debug) { | |
124 log.debug("cell size: " + cellWidth + " x " + cellHeight); | 144 log.debug("cell size: " + cellWidth + " x " + cellHeight); |
125 } | 145 } |
126 | 146 |
127 double [] raster = new double[width*height]; | 147 double [] raster = new double[width*height]; |
128 Arrays.fill(raster, Double.NaN); | 148 Arrays.fill(raster, Double.NaN); |