About Rtree Creation
Closed this issue · 1 comments
Hello Sir/Mam,
I am working on RTree. I need it to find Skyline points. Please go through the following link :
Go to page number 471 in the above link.
I am writing following test code to check whether rtree is correctly working ,
package com.infomatiq.jsi;
import com.infomatiq.jsi.rtree.Node;
import com.infomatiq.jsi.rtree.RTree;
import gnu.trove.TIntProcedure;
import java.util.Properties;
public class Test {
public static void main(String[] args) {
RTree sp = new RTree();
Properties p = new Properties();
sp.setMaxNodeEntries(3);
sp.init(p);
sp.add(new Rectangle(1,9,0,0),1);
sp.add(new Rectangle(2,10,0,0),2);
sp.add(new Rectangle(4,8,0,0),3);
sp.add(new Rectangle(6,7,0,0),4);
sp.add(new Rectangle(9,10,0,0),5);
sp.add(new Rectangle(7,5,0,0),6);
sp.add(new Rectangle(5,6,0,0),7);
sp.add(new Rectangle(4,3,0,0),8);
sp.add(new Rectangle(3,2,0,0),9);
sp.add(new Rectangle(10,4,0,0),10);
sp.add(new Rectangle(9,1,0,0),11);
sp.add(new Rectangle(6,2,0,0),12);
sp.add(new Rectangle(8,3,0,0),13);
printTree(sp);
}
private static void printTree(RTree sp) {
printTree(sp, sp.getRootNodeId(), 0);
}
private static void printTree(RTree sp, int id, int level) {
Node n = sp.getNode(id);
if (n == null) {
return;
}
System.out.print("node [" + id + "] ");
n.print();
System.out.println("level " + n.getLevel() + " leaf " + n.getEntryCount());
for (int i = 0; i < n.getEntryCount(); i++) {
int idx = n.getId(i);
if (!n.isLeaf()) {
printTree(sp, idx, level + 1);
} else {
System.out.print("Leaf value------------------> entry [" + idx + "] ");
n.print(i);
}
}
}
}
---------------------------Print Method is InNode class ----------------------------
public void print(int entry)
{
System.out.println("" + entriesMinX[entry] + "," + entriesMinY[entry] + " " + entriesMaxX[entry] + "," +
entriesMaxY[entry])
}
--------------------------------------------------In Node class------------------------------------------------
public void print()
{
System.out.println(mbrMinX + "," + mbrMinY + " " + mbrMaxX + "," + mbrMaxY);
}
-----And Rectangle has to draw automatically by rtree code ------------------------
It dimension are below as per link pdf ::
sp.add(new Rectangle(1,5,9,10),1);
sp.add(new Rectangle(3,1,10,6),1);
sp.add(new Rectangle(1,8,4,10),2);
sp.add(new Rectangle(6,5,9,10),2);
sp.add(new Rectangle(3,2,5,6),2);
sp.add(new Rectangle(9,1,10,4),2);
sp.add(new Rectangle(6,2,8,3),2);
Now it is not giving correct output. As per the Pdf [In above link]. And also it is not giving a tree in correctly. Please guide me where I am wrong?.
Please contact me on bhushanladde02@gmail.com
I'll take a look if you can create a simple test case that shows the RTree is returning incorrect results. Unfortunately I don't have time to go reading academic papers.
Good luck figuring it out.
Aled.