annotate gnv-artifacts/src/main/java/de/intevation/gnv/utils/IndexBuffer.java @ 349:555483213f78

Added buffer creator in index (i, j) space. gnv-artifacts/trunk@419 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 14 Dec 2009 14:36:43 +0000
parents
children b1f5f2a8840f
rev   line source
349
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1 package de.intevation.gnv.utils;
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
2
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
3 import java.awt.geom.Point2D;
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
4
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
5 import java.awt.Point;
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
6
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
7 import java.util.List;
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
8
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
9 /**
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10 * Create buffers around integer pairs (i_1..n), j_1..n).
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
11 *
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12 * @author Sascha L. Teichmann (sascha.teichmann@intevation.de)
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13 */
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
14 public class IndexBuffer
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
15 {
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
16 public static final double EPSILON = 1e-6d;
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
17 public static final double OFFSET = 1.0d;
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
18
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
19 public static final String I_COLUMN = "IPOSITION";
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
20 public static final String J_COLUMN = "JPOSITION";
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
21
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22 public static final class Segment {
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
23
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
24 private Segment next;
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
25
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
26 private Point2D.Double n;
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27 private double d1;
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28 private double d2;
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30 private int iMin;
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
31 private int iMax;
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
32
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33 private int jMin;
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34 private int jMax;
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
35
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
36 public Segment(Point a, Point b, Segment next) {
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
37
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
38 this.next = next;
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
39
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40 iMin = Math.min(a.x, b.x)-1;
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41 iMax = Math.max(a.x, b.x)+1;
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
42
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
43 jMin = Math.min(a.y, b.y)-1;
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44 jMax = Math.max(a.y, b.y)+1;
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
46 if (a.x > b.x) {
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
47 Point p = a; a = b; b = p;
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
48 }
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
49
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
50 Point2D.Double p1, p2, p3;
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
51
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
52 if (a.y < b.y) {
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
53 p1 = new Point2D.Double(a.x - OFFSET, a.y + 1 + OFFSET);
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
54 p2 = new Point2D.Double(b.x - OFFSET, b.y + 1 + OFFSET);
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
55 p3 = new Point2D.Double(a.x + 1 + OFFSET, a.y - OFFSET);
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
56 }
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
57 else {
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
58 p1 = new Point2D.Double(a.x + 1 + OFFSET, a.y + 1 + OFFSET);
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
59 p2 = new Point2D.Double(b.x + 1 + OFFSET, b.y + 1 + OFFSET);
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
60 p3 = new Point2D.Double(b.x - OFFSET, b.y - OFFSET);
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
61 }
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
62
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
63 n = normalize(orthogonal(sub(p1, p2)));
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
64
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
65 d1 = dot(n, p1);
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
66 d2 = dot(n, p3);
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
67
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
68 if (d1 > d2) {
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
69 double d = d1;
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
70 d1 = d2;
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
71 d2 = d;
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
72 }
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
73 }
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
74
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
75 public boolean check(int i, int j) {
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
76 if (i < iMin || i > iMax || j < jMin || j > jMax) {
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
77 return false;
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
78 }
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
79 double v = dot(n, i, j);
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
80 return v >= d1 && v <= d2;
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
81 }
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
82
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
83 public void toWhereClause(StringBuilder sb, String iColumn, String jColumn) {
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
84 sb.append('(')
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
85 .append(iColumn).append(" >= ").append(iMin).append(" AND ")
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
86 .append(iColumn).append(" <= ").append(iMax).append(" AND ")
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
87 .append(jColumn).append(" >= ").append(jMin).append(" AND ")
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
88 .append(jColumn).append(" <= ").append(jMax).append(" AND (")
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
89 .append(n.x).append('*').append(iColumn).append(" + ")
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
90 .append(n.y).append('*').append(jColumn)
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
91 .append(") BETWEEN ").append(d1).append(" AND ").append(d2).append(')');
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
92 }
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
93 } // class Segment
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
94
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
95 protected Segment head;
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
96
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
97 protected String iColumn;
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
98 protected String jColumn;
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
99
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
100 public IndexBuffer(List<? extends Point> points) {
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
101 this(points, I_COLUMN, J_COLUMN);
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
102 }
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
103
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
104 public IndexBuffer(List<? extends Point> points, String iColumn, String jColumn) {
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
105 this.iColumn = iColumn;
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
106 this.jColumn = jColumn;
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
107
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
108 for (int i = 1, N = points.size(); i < N; ++i) {
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
109 Point p1 = (Point)points.get(i-1);
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
110 Point p2 = (Point)points.get(i);
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
111 head = new Segment(p1, p2, head);
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
112 }
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
113 }
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
114
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
115 public boolean check(int i, int j) {
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
116
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
117 Segment current = head;
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
118 while (current != null) {
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
119 if (current.check(i, j)) {
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
120 return true;
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
121 }
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
122 current = current.next;
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
123 }
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
124 return false;
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
125 }
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
126
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
127 public String toWhereClause() {
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
128
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
129 StringBuilder sb = new StringBuilder();
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
130
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
131 Segment current = head;
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
132
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
133 while (current != null) {
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
134 if (current != head) {
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
135 sb.append(" OR ");
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
136 }
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
137 current.toWhereClause(sb, iColumn, jColumn);
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
138 current = current.next;
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
139 }
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
140
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
141 return sb.toString();
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
142 }
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
143
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
144 public static Point2D.Double sub(Point2D.Double p1, Point2D.Double p2) {
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
145 return new Point2D.Double(p1.x - p2.x, p1.y - p2.y);
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
146 }
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
147
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
148 public static final double dot(Point2D.Double p1, Point2D.Double p2) {
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
149 return p1.x*p2.x + p1.y*p2.y;
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
150 }
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
151
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
152 public static final double dot(Point2D.Double p1, double x, double y) {
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
153 return p1.x*x + p1.y*y;
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
154 }
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
155
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
156 public static final Point2D.Double scale(Point2D.Double p, double s) {
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
157 return new Point2D.Double(s*p.x, s*p.y);
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
158 }
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
159
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
160 public static final Point2D.Double normalize(Point2D.Double p) {
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
161 double len2 = Math.sqrt(dot(p, p));
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
162 return len2 > EPSILON ? scale(p, 1d/len2) : p;
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
163 }
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
164
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
165 public static final Point2D.Double orthogonal(Point2D.Double p) {
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
166 return new Point2D.Double(p.y, -p.x);
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
167 }
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
168 }
555483213f78 Added buffer creator in index (i, j) space.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
169 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:

http://dive4elements.wald.intevation.org