Class IntervalRTreeBranchNode

 1 /*
 2  * Copyright (c) 2016 Vivid Solutions.
 3  *
 4  * All rights reserved. This program and the accompanying materials
 5  * are made available under the terms of the Eclipse Public License 2.0
 6  * and Eclipse Distribution License v. 1.0 which accompanies this distribution.
 7  * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v20.html
 8  * and the Eclipse Distribution License is available at
 9  *
10  * http://www.eclipse.org/org/documents/edl-v10.php.
11  */
12 package org.locationtech.jts.index.intervalrtree;
13  
14 import org.locationtech.jts.index.ItemVisitor;
15  
16 public class IntervalRTreeBranchNode 
17 extends IntervalRTreeNode
18 {
19     private IntervalRTreeNode node1;
20     private IntervalRTreeNode node2;
21     
22     public IntervalRTreeBranchNode(IntervalRTreeNode n1, IntervalRTreeNode n2)
23     {
24         node1 = n1;
25         node2 = n2;
26         buildExtent(node1, node2);
27     }
28     
29     private void buildExtent(IntervalRTreeNode n1, IntervalRTreeNode n2)
30     {
31         min = Math.min(n1.min, n2.min);
32         max = Math.max(n1.max, n2.max);
33     }
34     
35     public void query(double queryMin, double queryMax, ItemVisitor visitor)
36     {
37         if (! intersects(queryMin, queryMax)) {
38 //            System.out.println("Does NOT Overlap branch: " + this);
39             return;
40         }
41 //        System.out.println("Overlaps branch: " + this);
42         if (node1 != nullnode1.query(queryMin, queryMax, visitor);
43         if (node2 != nullnode2.query(queryMin, queryMax, visitor);
44     }
45     
46 }
47