@@ -123,6 +123,12 @@ protected PointQuadNode(AxisAlignedBoundingBox aabb) {
123
123
super (aabb );
124
124
}
125
125
126
+ /**
127
+ * {@inheritDoc}
128
+ *
129
+ * returns True if inserted.
130
+ * returns False if not in bounds of tree OR tree already contains point.
131
+ */
126
132
@ Override
127
133
protected boolean insert (XY p ) {
128
134
// Ignore objects which do not belong in this quad tree
@@ -271,12 +277,12 @@ public void insert(float x, float y, float height, float width) {
271
277
*/
272
278
@ Override
273
279
public List <B > queryRange (float x , float y , float height , float width ) {
274
- List <B > pointsInRange = new LinkedList <B >();
275
- if (root ==null ) return (List <B >)pointsInRange ;
280
+ List <B > geometricObjectsInRange = new LinkedList <B >();
281
+ if (root ==null ) return (List <B >)geometricObjectsInRange ;
276
282
XYPoint xyPoint = new XYPoint (x ,y );
277
283
AxisAlignedBoundingBox range = new AxisAlignedBoundingBox (xyPoint ,height ,width );
278
- root .queryRange (range ,pointsInRange );
279
- return (List <B >)pointsInRange ;
284
+ root .queryRange (range ,geometricObjectsInRange );
285
+ return (List <B >)geometricObjectsInRange ;
280
286
}
281
287
282
288
/**
@@ -297,11 +303,14 @@ protected RectangleQuadNode(AxisAlignedBoundingBox aabb) {
297
303
298
304
/**
299
305
* {@inheritDoc}
306
+ *
307
+ * returns True if inserted or already contains.
300
308
*/
301
309
@ Override
302
310
protected boolean insert (AABB b ) {
303
311
// Ignore objects which do not belong in this quad tree
304
- if (!aabb .intersectsBox (b ) || aabbs .contains (b )) return false ; // object cannot be added
312
+ if (!aabb .intersectsBox (b )) return false ; // object cannot be added
313
+ if (aabbs .contains (b )) return true ; // already exists
305
314
306
315
// If this is the biggest bounding box which completely contains the aabb.
307
316
float nextLevelsHeight = aabb .height /2 ;
0 commit comments