Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/math/GridCell.java @ 517:96a1e92e7ed2
If the number of data points to generate a "Horizontalschnitt"
is above a given threshold, they are culled against an 5% extented
bounding box of the interpolation area.
gnv-artifacts/trunk@611 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sat, 23 Jan 2010 17:42:04 +0000 |
parents | d9d933e06875 |
children | 4e347624ee7c |
comparison
equal
deleted
inserted
replaced
516:4f2a18abc780 | 517:96a1e92e7ed2 |
---|---|
14 | 14 |
15 import java.util.ArrayList; | 15 import java.util.ArrayList; |
16 import java.util.HashMap; | 16 import java.util.HashMap; |
17 import java.util.List; | 17 import java.util.List; |
18 | 18 |
19 import org.apache.log4j.Logger; | |
20 | |
19 /** | 21 /** |
20 * @author Sascha L. Teichmann (sascha.teichmann@intevation.de) | 22 * @author Sascha L. Teichmann (sascha.teichmann@intevation.de) |
21 */ | 23 */ |
22 public class GridCell | 24 public class GridCell |
23 implements Serializable | 25 implements Serializable |
24 { | 26 { |
27 private static Logger log = Logger.getLogger(GridCell.class); | |
28 | |
25 public static final class CellFinder | 29 public static final class CellFinder |
26 implements ItemVisitor | 30 implements ItemVisitor |
27 { | 31 { |
28 public GridCell found; | 32 public GridCell found; |
29 | 33 |
83 } | 87 } |
84 | 88 |
85 public static List<GridCell> pointsToGridCells( | 89 public static List<GridCell> pointsToGridCells( |
86 List<? extends Point2d> points | 90 List<? extends Point2d> points |
87 ) { | 91 ) { |
92 return pointsToGridCells(points, null); | |
93 } | |
94 | |
95 public static List<GridCell> pointsToGridCells( | |
96 List<? extends Point2d> points, | |
97 Envelope relevantArea | |
98 ) { | |
88 int minI = Integer.MAX_VALUE; | 99 int minI = Integer.MAX_VALUE; |
89 int maxI = Integer.MIN_VALUE; | 100 int maxI = Integer.MIN_VALUE; |
90 int minJ = Integer.MAX_VALUE; | 101 int minJ = Integer.MAX_VALUE; |
91 int maxJ = Integer.MIN_VALUE; | 102 int maxJ = Integer.MIN_VALUE; |
92 | 103 |
93 HashMap<Integer, HashMap<Integer, Point2d>> rows = | 104 HashMap<Integer, HashMap<Integer, Point2d>> rows = |
94 new HashMap<Integer, HashMap<Integer, Point2d>>(); | 105 new HashMap<Integer, HashMap<Integer, Point2d>>(); |
95 | 106 |
107 int culled = 0; | |
108 | |
96 for (Point2d p: points) { | 109 for (Point2d p: points) { |
110 | |
111 if (relevantArea != null && !relevantArea.contains(p.x, p.y)) { | |
112 ++culled; | |
113 continue; | |
114 } | |
97 | 115 |
98 if (p.i < minI) minI = p.i; | 116 if (p.i < minI) minI = p.i; |
99 if (p.i > maxI) maxI = p.i; | 117 if (p.i > maxI) maxI = p.i; |
100 if (p.j < minJ) minJ = p.j; | 118 if (p.j < minJ) minJ = p.j; |
101 if (p.j > maxJ) maxJ = p.j; | 119 if (p.j > maxJ) maxJ = p.j; |
105 if (row == null) { | 123 if (row == null) { |
106 rows.put(p.i, row = new HashMap<Integer, Point2d>()); | 124 rows.put(p.i, row = new HashMap<Integer, Point2d>()); |
107 } | 125 } |
108 | 126 |
109 row.put(p.j, p); | 127 row.put(p.j, p); |
128 } | |
129 | |
130 if (log.isDebugEnabled()) { | |
131 log.debug("culled points: " + culled); | |
110 } | 132 } |
111 | 133 |
112 ArrayList<GridCell> cells = new ArrayList<GridCell>(points.size()); | 134 ArrayList<GridCell> cells = new ArrayList<GridCell>(points.size()); |
113 | 135 |
114 for (int i = minI + 1; i <= maxI; ++i) { | 136 for (int i = minI + 1; i <= maxI; ++i) { |