12
12
import org .apache .lucene .index .PointValues ;
13
13
14
14
/**
15
- * A {@link TriangleTreeReader.Visitor } implementation for {@link Component2D} geometries.
15
+ * A {@link TriangleTreeVisitor.TriangleTreeDecodedVisitor } implementation for {@link Component2D} geometries.
16
16
* It can solve spatial relationships against a serialize triangle tree.
17
17
*/
18
- public abstract class Component2DVisitor extends TriangleTreeReader . DecodedVisitor {
18
+ public abstract class Component2DVisitor extends TriangleTreeVisitor . TriangleTreeDecodedVisitor {
19
19
20
20
protected final Component2D component2D ;
21
21
@@ -31,23 +31,23 @@ private Component2DVisitor(Component2D component2D, CoordinateEncoder encoder) {
31
31
public abstract void reset ();
32
32
33
33
@ Override
34
- public boolean pushDecodedX (double minX ) {
34
+ protected boolean pushDecodedX (double minX ) {
35
35
return component2D .getMaxX () >= minX ;
36
36
}
37
37
38
38
@ Override
39
- public boolean pushDecodedY (double minY ) {
39
+ protected boolean pushDecodedY (double minY ) {
40
40
return component2D .getMaxY () >= minY ;
41
41
}
42
42
43
43
@ Override
44
- public boolean pushDecoded (double maxX , double maxY ) {
44
+ protected boolean pushDecoded (double maxX , double maxY ) {
45
45
return component2D .getMinX () <= maxX && component2D .getMinY () <= maxY ;
46
46
47
47
}
48
48
49
49
@ Override
50
- public boolean pushDecoded (double minX , double minY , double maxX , double maxY ) {
50
+ protected boolean pushDecoded (double minX , double minY , double maxX , double maxY ) {
51
51
return pushDecoded (component2D .relate (minX , maxX , minY , maxY ));
52
52
}
53
53
@@ -56,7 +56,7 @@ public boolean pushDecoded(double minX, double minY, double maxX, double maxY) {
56
56
*
57
57
* @return if true, the visitor keeps traversing the tree, else it stops.
58
58
* */
59
- abstract boolean pushDecoded (PointValues .Relation relation );
59
+ protected abstract boolean pushDecoded (PointValues .Relation relation );
60
60
61
61
/**
62
62
* Creates a visitor from the provided Component2D and spatial relationship. Visitors are re-usable by
@@ -95,17 +95,17 @@ public void reset() {
95
95
}
96
96
97
97
@ Override
98
- void visitDecodedPoint (double x , double y ) {
98
+ protected void visitDecodedPoint (double x , double y ) {
99
99
intersects = component2D .contains (x , y );
100
100
}
101
101
102
102
@ Override
103
- void visitDecodedLine (double aX , double aY , double bX , double bY , byte metadata ) {
103
+ protected void visitDecodedLine (double aX , double aY , double bX , double bY , byte metadata ) {
104
104
intersects = component2D .intersectsLine (aX , aY , bX , bY );
105
105
}
106
106
107
107
@ Override
108
- void visitDecodedTriangle (double aX , double aY , double bX , double bY , double cX , double cY , byte metadata ) {
108
+ protected void visitDecodedTriangle (double aX , double aY , double bX , double bY , double cX , double cY , byte metadata ) {
109
109
intersects = component2D .intersectsTriangle (aX , aY , bX , bY , cX , cY );
110
110
}
111
111
@@ -116,7 +116,7 @@ public boolean push() {
116
116
}
117
117
118
118
@ Override
119
- boolean pushDecoded (PointValues .Relation relation ) {
119
+ protected boolean pushDecoded (PointValues .Relation relation ) {
120
120
if (relation == PointValues .Relation .CELL_OUTSIDE_QUERY ) {
121
121
// shapes are disjoint, stop traversing the tree.
122
122
return false ;
@@ -156,17 +156,17 @@ public void reset() {
156
156
}
157
157
158
158
@ Override
159
- void visitDecodedPoint (double x , double y ) {
159
+ protected void visitDecodedPoint (double x , double y ) {
160
160
disjoint = component2D .contains (x , y ) == false ;
161
161
}
162
162
163
163
@ Override
164
- void visitDecodedLine (double aX , double aY , double bX , double bY , byte metadata ) {
164
+ protected void visitDecodedLine (double aX , double aY , double bX , double bY , byte metadata ) {
165
165
disjoint = component2D .intersectsLine (aX , aY , bX , bY ) == false ;
166
166
}
167
167
168
168
@ Override
169
- void visitDecodedTriangle (double aX , double aY , double bX , double bY , double cX , double cY , byte metadata ) {
169
+ protected void visitDecodedTriangle (double aX , double aY , double bX , double bY , double cX , double cY , byte metadata ) {
170
170
disjoint = component2D .intersectsTriangle (aX , aY , bX , bY , cX , cY ) == false ;
171
171
}
172
172
@@ -177,7 +177,7 @@ public boolean push() {
177
177
}
178
178
179
179
@ Override
180
- boolean pushDecoded (PointValues .Relation relation ) {
180
+ protected boolean pushDecoded (PointValues .Relation relation ) {
181
181
if (relation == PointValues .Relation .CELL_OUTSIDE_QUERY ) {
182
182
// shapes are disjoint, stop traversing the tree.
183
183
return false ;
@@ -217,17 +217,17 @@ public void reset() {
217
217
}
218
218
219
219
@ Override
220
- void visitDecodedPoint (double x , double y ) {
220
+ protected void visitDecodedPoint (double x , double y ) {
221
221
within = component2D .contains (x , y );
222
222
}
223
223
224
224
@ Override
225
- void visitDecodedLine (double aX , double aY , double bX , double bY , byte metadata ) {
225
+ protected void visitDecodedLine (double aX , double aY , double bX , double bY , byte metadata ) {
226
226
within = component2D .containsLine (aX , aY , bX , bY );
227
227
}
228
228
229
229
@ Override
230
- void visitDecodedTriangle (double aX , double aY , double bX , double bY , double cX , double cY , byte metadata ) {
230
+ protected void visitDecodedTriangle (double aX , double aY , double bX , double bY , double cX , double cY , byte metadata ) {
231
231
within = component2D .containsTriangle (aX , aY , bX , bY , cX , cY );
232
232
}
233
233
@@ -238,31 +238,31 @@ public boolean push() {
238
238
}
239
239
240
240
@ Override
241
- public boolean pushX ( int minX ) {
241
+ protected boolean pushDecodedX ( double minX ) {
242
242
// if any part of the tree is skipped, then the doc value is not within the shape,
243
243
// stop traversing the tree
244
- within = super .pushX (minX );
244
+ within = super .pushDecodedX (minX );
245
245
return within ;
246
246
}
247
247
248
248
@ Override
249
- public boolean pushY ( int minY ) {
249
+ protected boolean pushDecodedY ( double minY ) {
250
250
// if any part of the tree is skipped, then the doc value is not within the shape,
251
251
// stop traversing the tree
252
- within = super .pushY (minY );
252
+ within = super .pushDecodedY (minY );
253
253
return within ;
254
254
}
255
255
256
256
@ Override
257
- public boolean push ( int maxX , int maxY ) {
257
+ protected boolean pushDecoded ( double maxX , double maxY ) {
258
258
// if any part of the tree is skipped, then the doc value is not within the shape,
259
259
// stop traversing the tree
260
- within = super .push (maxX , maxY );
260
+ within = super .pushDecoded (maxX , maxY );
261
261
return within ;
262
262
}
263
263
264
264
@ Override
265
- boolean pushDecoded (PointValues .Relation relation ) {
265
+ protected boolean pushDecoded (PointValues .Relation relation ) {
266
266
if (relation == PointValues .Relation .CELL_OUTSIDE_QUERY ) {
267
267
// shapes are disjoint, stop traversing the tree.
268
268
within = false ;
@@ -297,7 +297,7 @@ public void reset() {
297
297
}
298
298
299
299
@ Override
300
- void visitDecodedPoint (double x , double y ) {
300
+ protected void visitDecodedPoint (double x , double y ) {
301
301
final Component2D .WithinRelation rel = component2D .withinPoint (x , y );
302
302
if (rel != Component2D .WithinRelation .DISJOINT ) {
303
303
// Only override relationship if different to DISJOINT
@@ -306,7 +306,7 @@ void visitDecodedPoint(double x, double y) {
306
306
}
307
307
308
308
@ Override
309
- void visitDecodedLine (double aX , double aY , double bX , double bY , byte metadata ) {
309
+ protected void visitDecodedLine (double aX , double aY , double bX , double bY , byte metadata ) {
310
310
final boolean ab = (metadata & 1 << 4 ) == 1 << 4 ;
311
311
final Component2D .WithinRelation rel = component2D .withinLine (aX , aY , ab , bX , bY );
312
312
if (rel != Component2D .WithinRelation .DISJOINT ) {
@@ -316,7 +316,7 @@ void visitDecodedLine(double aX, double aY, double bX, double bY, byte metadata)
316
316
}
317
317
318
318
@ Override
319
- void visitDecodedTriangle (double aX , double aY , double bX , double bY , double cX , double cY , byte metadata ) {
319
+ protected void visitDecodedTriangle (double aX , double aY , double bX , double bY , double cX , double cY , byte metadata ) {
320
320
final boolean ab = (metadata & 1 << 4 ) == 1 << 4 ;
321
321
final boolean bc = (metadata & 1 << 5 ) == 1 << 5 ;
322
322
final boolean ca = (metadata & 1 << 6 ) == 1 << 6 ;
@@ -334,7 +334,7 @@ public boolean push() {
334
334
}
335
335
336
336
@ Override
337
- boolean pushDecoded (PointValues .Relation relation ) {
337
+ protected boolean pushDecoded (PointValues .Relation relation ) {
338
338
// Only traverse the tree if the shapes intersects.
339
339
return relation == PointValues .Relation .CELL_CROSSES_QUERY ;
340
340
}
0 commit comments