Mercurial > dive4elements > gnv-client
annotate gnv-artifacts/src/main/java/de/intevation/gnv/math/GridCell.java @ 817:3f447e92024a
Added JavaDoc package descriptions.
gnv-artifacts/trunk@902 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 12 Apr 2010 09:37:30 +0000 |
parents | 22c18083225e |
children | f953c9a559d8 |
rev | line source |
---|---|
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.gnv.math; |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
593
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
3 import com.vividsolutions.jts.algorithm.CGAlgorithms; |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
4 |
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 import com.vividsolutions.jts.geom.Coordinate; |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 import com.vividsolutions.jts.geom.Envelope; |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 import com.vividsolutions.jts.geom.Geometry; |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 import com.vividsolutions.jts.geom.GeometryFactory; |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 import com.vividsolutions.jts.geom.LinearRing; |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 import com.vividsolutions.jts.geom.Point; |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 import com.vividsolutions.jts.geom.Polygon; |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 import com.vividsolutions.jts.index.ItemVisitor; |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 import java.io.Serializable; |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 import java.util.ArrayList; |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 import java.util.HashMap; |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 import java.util.List; |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 |
517
96a1e92e7ed2
If the number of data points to generate a "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
514
diff
changeset
|
21 import org.apache.log4j.Logger; |
96a1e92e7ed2
If the number of data points to generate a "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
514
diff
changeset
|
22 |
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 /** |
807
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
24 * Spans a rectangle of points to be used in spatial indexing. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
25 * |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
26 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a> |
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 */ |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 public class GridCell |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 implements Serializable |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 { |
517
96a1e92e7ed2
If the number of data points to generate a "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
514
diff
changeset
|
31 private static Logger log = Logger.getLogger(GridCell.class); |
96a1e92e7ed2
If the number of data points to generate a "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
514
diff
changeset
|
32 |
807
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
33 /** |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
34 * Callback for {@link com.vividsolutions.jts.index.SpatialIndex} |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
35 * to find a GridCell which contains a given point. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
36 */ |
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 public static final class CellFinder |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 implements ItemVisitor |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 { |
807
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
40 /** |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
41 * Stores the found GridCell. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
42 */ |
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 public GridCell found; |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 |
807
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
45 /** |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
46 * The query point. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
47 */ |
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 protected Point point; |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 |
807
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
50 /** |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
51 * Default constructor. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
52 */ |
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
53 public CellFinder() { |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 } |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
55 |
807
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
56 /** |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
57 * Prepares a spatial index lookup. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
58 * @param center The query point. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
59 */ |
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
60 public void prepare(Coordinate center) { |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
61 found = null; |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
62 point = GEOMETRY_FACTORY.createPoint(center); |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
63 } |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
64 |
807
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
65 /** |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
66 * Called by the spatial index as a 2nd order filter. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
67 * @param item The GridCell to test. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
68 */ |
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
69 public void visitItem(Object item) { |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
70 if (found == null) { |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
71 GridCell cell = (GridCell)item; |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
72 if (cell.contains(point)) { |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
73 found = cell; |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
74 } |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
75 } |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
76 } |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
77 } // class CellFinder |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
78 |
807
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
79 /** |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
80 * The first point. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
81 */ |
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
82 public Point2d p1; |
807
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
83 /** |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
84 * The second point. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
85 */ |
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
86 public Point2d p2; |
807
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
87 /** |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
88 * The third point. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
89 */ |
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
90 public Point2d p3; |
807
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
91 /** |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
92 * The fourth point. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
93 */ |
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
94 public Point2d p4; |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
95 |
807
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
96 /** |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
97 * Polygon created from the four points. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
98 */ |
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
99 protected Polygon polygon; |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
100 |
807
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
101 /** |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
102 * Geometry factory to create the query points and the polygons. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
103 */ |
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
104 public static final GeometryFactory GEOMETRY_FACTORY |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
105 = new GeometryFactory(); |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
106 |
807
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
107 /** |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
108 * Default constructor. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
109 */ |
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
110 public GridCell() { |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
111 } |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
112 |
807
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
113 /** |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
114 * Constructor to create a GridCell out of four given points.. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
115 * @param p1 The first point. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
116 * @param p2 The second point. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
117 * @param p3 The thrid point. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
118 * @param p4 The fourth point. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
119 */ |
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
120 public GridCell(Point2d p1, Point2d p2, Point2d p3, Point2d p4) { |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
121 this.p1 = p1; |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
122 this.p2 = p2; |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
123 this.p3 = p3; |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
124 this.p4 = p4; |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
125 createPolygon(); |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
126 } |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
127 |
807
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
128 /** |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
129 * Creates the polygon from the four points. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
130 */ |
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
131 protected void createPolygon() { |
593
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
132 Coordinate [] coords = new Coordinate [] { p1, p2, p3, p4, p1 }; |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
133 if (!CGAlgorithms.isCCW(coords)) { |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
134 for (int i = 0, j = coords.length-1; i < j; ++i, --j) { |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
135 Coordinate c = coords[i]; |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
136 coords[i] = coords[j]; |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
137 coords[j] = c; |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
138 } |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
139 } |
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
140 LinearRing shell = GEOMETRY_FACTORY |
593
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
141 .createLinearRing(coords); |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
142 |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
143 if (!shell.isValid()) { |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
144 log.warn("linear ring is not valid"); |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
145 } |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
146 |
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
147 polygon = GEOMETRY_FACTORY.createPolygon(shell, null); |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
148 } |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
149 |
807
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
150 /** |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
151 * Returns the envelope of the four point polygon. |
815
22c18083225e
Removed compiler warnings while JavaDoc generation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
807
diff
changeset
|
152 * @return the envelope. |
807
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
153 */ |
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
154 public Envelope getEnvelope() { |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
155 return polygon.getEnvelopeInternal(); |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
156 } |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
157 |
807
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
158 /** |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
159 * Test if a given point is inside this grid cell. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
160 * @param coord |
815
22c18083225e
Removed compiler warnings while JavaDoc generation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
807
diff
changeset
|
161 * @return true, if this grid cell contains the given point - otherwise |
22c18083225e
Removed compiler warnings while JavaDoc generation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
807
diff
changeset
|
162 * false. |
807
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
163 */ |
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
164 public boolean contains(Geometry coord) { |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
165 return polygon.contains(coord); |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
166 } |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
167 |
807
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
168 /** |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
169 * Converts a list of points to a list of grid cells. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
170 * @param points This list of points. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
171 * @return This list of grid cells. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
172 */ |
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
173 public static List<GridCell> pointsToGridCells( |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
174 List<? extends Point2d> points |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
175 ) { |
517
96a1e92e7ed2
If the number of data points to generate a "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
514
diff
changeset
|
176 return pointsToGridCells(points, null); |
96a1e92e7ed2
If the number of data points to generate a "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
514
diff
changeset
|
177 } |
96a1e92e7ed2
If the number of data points to generate a "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
514
diff
changeset
|
178 |
807
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
179 /** |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
180 * Converts a list of points to a list of grid cells. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
181 * Points that are not in a relevant area are ignored. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
182 * @param points The list of points. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
183 * @param relevantArea The relevant area. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
184 * @return The list of grid cells. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
185 */ |
517
96a1e92e7ed2
If the number of data points to generate a "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
514
diff
changeset
|
186 public static List<GridCell> pointsToGridCells( |
96a1e92e7ed2
If the number of data points to generate a "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
514
diff
changeset
|
187 List<? extends Point2d> points, |
96a1e92e7ed2
If the number of data points to generate a "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
514
diff
changeset
|
188 Envelope relevantArea |
96a1e92e7ed2
If the number of data points to generate a "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
514
diff
changeset
|
189 ) { |
593
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
190 return pointsToGridCells(points, relevantArea, 0); |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
191 } |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
192 |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
193 private static final int NEIGHBORS [][] = { |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
194 { -1, -1 }, // 0 |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
195 { -1, 0 }, // 1 |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
196 { -1, +1 }, // 2 |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
197 { 0, +1 }, // 3 |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
198 { +1, +1 }, // 4 |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
199 { +1, 0 }, // 5 |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
200 { +1, -1 }, // 6 |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
201 { 0, -1 } // 7 |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
202 }; |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
203 |
807
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
204 /** |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
205 * Generate points by extrapolating border points. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
206 * @param rows (i, j) indexed map of points. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
207 * @param minI min known i. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
208 * @param maxI max known i. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
209 * @param minJ min known j. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
210 * @param maxJ max known j. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
211 * @param rounds Deternine how many extra rings should be generated. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
212 * @param relevantArea The relevant area. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
213 * @return number of newly generated points. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
214 */ |
593
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
215 public static int extrapolate( |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
216 HashMap<Integer, HashMap<Integer, Point2d>> rows, |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
217 int minI, int maxI, |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
218 int minJ, int maxJ, |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
219 int rounds, |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
220 Envelope relevantArea |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
221 ) { |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
222 Point2d [] neighbors = new Point2d[NEIGHBORS.length]; |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
223 Point2d [] positions = new Point2d[NEIGHBORS.length]; |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
224 |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
225 int total = 0; |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
226 |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
227 ArrayList<ArrayList<IJKey>> prio = |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
228 new ArrayList<ArrayList<IJKey>>(NEIGHBORS.length); |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
229 |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
230 for (int i = 0; i < NEIGHBORS.length; ++i) { |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
231 prio.add(new ArrayList<IJKey>()); |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
232 } |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
233 |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
234 while (rounds-- > 0) { |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
235 for (int i = minI; i <= maxI; ++i) { |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
236 for (int j = minJ; j <= maxJ; ++j) { |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
237 Point2d p = get(rows, i, j); |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
238 if (p != null) { |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
239 continue; |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
240 } |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
241 |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
242 int count = 0; |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
243 |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
244 for (int k = 0; k < neighbors.length; ++k) { |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
245 neighbors[k] = positions[k] = null; |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
246 int dij [] = NEIGHBORS[k]; |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
247 Point2d n1 = get(rows, i+ dij[0], j+ dij[1]); |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
248 Point2d n2 = get(rows, i+2*dij[0], j+2*dij[1]); |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
249 if (n1 != null && n2 != null) { |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
250 ++count; |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
251 } |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
252 } |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
253 |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
254 if (count > 0) { |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
255 prio.get(count-1).add(new IJKey(i, j)); |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
256 } |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
257 } // for all columns |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
258 } // for all rows |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
259 |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
260 int N = 0; |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
261 |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
262 for (int l = NEIGHBORS.length-1; l >= 0; --l) { |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
263 ArrayList<IJKey> list = prio.get(l); |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
264 for (IJKey ij: list) { |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
265 int i = ij.i; |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
266 int j = ij.j; |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
267 for (int k = 0; k < neighbors.length; ++k) { |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
268 neighbors[k] = positions[k] = null; |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
269 int dij [] = NEIGHBORS[k]; |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
270 Point2d n1 = get(rows, i+ dij[0], j+ dij[1]); |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
271 Point2d n2 = get(rows, i+2*dij[0], j+2*dij[1]); |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
272 if (n1 != null && n2 != null) { |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
273 neighbors[k] = n1; |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
274 positions[k] = n1.extrapolate(-1d, n2); |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
275 } |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
276 } |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
277 |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
278 Point2d avg = Point2d.average(positions); |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
279 |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
280 if (avg != null && avg.near(positions) |
801
d766fe2d917a
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
780
diff
changeset
|
281 && (relevantArea == null |
d766fe2d917a
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
780
diff
changeset
|
282 || relevantArea.contains(avg.x, avg.y))) { |
593
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
283 avg.i = i; |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
284 avg.j = j; |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
285 avg.inverseDistanceWeighting(neighbors); |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
286 put(rows, avg, i, j); |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
287 } |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
288 } |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
289 N += list.size(); |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
290 list.clear(); |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
291 } |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
292 |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
293 if (N == 0) { |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
294 break; |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
295 } |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
296 total += N; |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
297 } // for all rounds |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
298 |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
299 return total; |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
300 } |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
301 |
807
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
302 /** |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
303 * Converts a list of points to a list of grid cells. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
304 * @param points The list of points. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
305 * @param relevantArea The relevant area. If a point is |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
306 * not inside this area it is ignored during the build process. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
307 * @param extrapolationRounds Number of extra point rings. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
308 * 0 = no extrpolation. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
309 * @return The list of grid cells. |
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
801
diff
changeset
|
310 */ |
593
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
311 public static List<GridCell> pointsToGridCells( |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
312 List<? extends Point2d> points, |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
313 Envelope relevantArea, |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
314 int extrapolationRounds |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
315 ) { |
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
316 int minI = Integer.MAX_VALUE; |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
317 int maxI = Integer.MIN_VALUE; |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
318 int minJ = Integer.MAX_VALUE; |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
319 int maxJ = Integer.MIN_VALUE; |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
320 |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
321 HashMap<Integer, HashMap<Integer, Point2d>> rows = |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
322 new HashMap<Integer, HashMap<Integer, Point2d>>(); |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
323 |
517
96a1e92e7ed2
If the number of data points to generate a "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
514
diff
changeset
|
324 int culled = 0; |
96a1e92e7ed2
If the number of data points to generate a "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
514
diff
changeset
|
325 |
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
326 for (Point2d p: points) { |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
327 |
517
96a1e92e7ed2
If the number of data points to generate a "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
514
diff
changeset
|
328 if (relevantArea != null && !relevantArea.contains(p.x, p.y)) { |
96a1e92e7ed2
If the number of data points to generate a "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
514
diff
changeset
|
329 ++culled; |
96a1e92e7ed2
If the number of data points to generate a "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
514
diff
changeset
|
330 continue; |
96a1e92e7ed2
If the number of data points to generate a "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
514
diff
changeset
|
331 } |
96a1e92e7ed2
If the number of data points to generate a "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
514
diff
changeset
|
332 |
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
333 if (p.i < minI) minI = p.i; |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
334 if (p.i > maxI) maxI = p.i; |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
335 if (p.j < minJ) minJ = p.j; |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
336 if (p.j > maxJ) maxJ = p.j; |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
337 |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
338 HashMap<Integer, Point2d> row = rows.get(p.i); |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
339 |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
340 if (row == null) { |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
341 rows.put(p.i, row = new HashMap<Integer, Point2d>()); |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
342 } |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
343 |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
344 row.put(p.j, p); |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
345 } |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
346 |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
347 ArrayList<GridCell> cells = new ArrayList<GridCell>(points.size()); |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
348 |
593
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
349 int extrapolated = extrapolate( |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
350 rows, |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
351 minI, maxI, |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
352 minJ, maxJ, |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
353 extrapolationRounds, |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
354 relevantArea); |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
355 |
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
356 for (int i = minI + 1; i <= maxI; ++i) { |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
357 HashMap<Integer, Point2d> row1 = rows.get(i-1); |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
358 HashMap<Integer, Point2d> row2 = rows.get(i); |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
359 |
593
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
360 if (row1 == null || row2 == null) { |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
361 continue; |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
362 } |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
363 |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
364 for (int j = minJ + 1; j < maxJ; ++j) { |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
365 Point2d p1 = row1.get(j-1); |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
366 Point2d p2 = row1.get(j); |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
367 Point2d p3 = row2.get(j); |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
368 Point2d p4 = row2.get(j-1); |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
369 |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
370 if (p1 != null && p2 != null && p3 != null && p4 != null) { |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
371 cells.add(new GridCell(p1, p2, p3, p4)); |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
372 } |
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
373 } |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
374 } // for all rows |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
375 |
519
4e347624ee7c
Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
517
diff
changeset
|
376 if (log.isDebugEnabled()) { |
4e347624ee7c
Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
517
diff
changeset
|
377 log.debug("culled points: " + culled); |
593
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
378 log.debug("extrapolated points: " + extrapolated); |
519
4e347624ee7c
Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
517
diff
changeset
|
379 log.debug("min/max i: " + minI + " / " + maxI); |
4e347624ee7c
Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
517
diff
changeset
|
380 log.debug("min/max j: " + minJ + " / " + maxJ); |
4e347624ee7c
Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
517
diff
changeset
|
381 log.debug("cells found: " + cells.size()); |
4e347624ee7c
Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
517
diff
changeset
|
382 } |
4e347624ee7c
Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
517
diff
changeset
|
383 |
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
384 return cells; |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
385 } |
593
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
386 |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
387 private static Point2d get( |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
388 HashMap<Integer, HashMap<Integer, Point2d>> rows, |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
389 int i, int j |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
390 ) { |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
391 HashMap<Integer, Point2d> row = rows.get(i); |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
392 return row != null ? row.get(j) : null; |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
393 } |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
394 |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
395 private static void put( |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
396 HashMap<Integer, HashMap<Integer, Point2d>> rows, |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
397 Point2d point, |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
398 int i, int j |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
399 ) { |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
400 Integer I = Integer.valueOf(i); |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
401 HashMap<Integer, Point2d> row = rows.get(I); |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
402 if (row == null) { |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
403 rows.put(I, row = new HashMap<Integer, Point2d>()); |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
404 } |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
405 row.put(j, point); |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
519
diff
changeset
|
406 } |
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
407 } |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
408 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |