Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/308.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java STRtree实现输出包含随机点_Java_R Tree_Jts - Fatal编程技术网

Java STRtree实现输出包含随机点

Java STRtree实现输出包含随机点,java,r-tree,jts,Java,R Tree,Jts,我正在使用JTS和Netbeans来实现STRtrees。我正在尝试为一组点(坐标)构建STRtree。这是我的密码: package example; import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.Envelope; import com.vividsolutions.jts.geom.GeometryFactory; import com.vividsolutions.jt

我正在使用JTS和Netbeans来实现STRtrees。我正在尝试为一组点(坐标)构建STRtree。这是我的密码:

package example;

import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Envelope;
import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.Point;
import com.vividsolutions.jts.index.ArrayListVisitor;
import com.vividsolutions.jts.index.strtree.STRtree;
import java.util.List;

public class Example {


public static void main(String[] args) {
    //Getting input from the user as points

    GeometryFactory gf = new GeometryFactory();
    Coordinate coord = new Coordinate( 1, 1 );
    Point point=gf.createPoint( coord );
     coord = new Coordinate( 3,2 );
    Point point2=gf.createPoint( coord );
    coord = new Coordinate( 2,4 );
    Point point3=gf.createPoint( coord );
     coord = new Coordinate( 4,1 );
    Point point4=gf.createPoint( coord );
     coord = new Coordinate( 5,2);
    Point point5=gf.createPoint( coord );
     coord = new Coordinate( 4,5);
    Point point6=gf.createPoint( coord );
    coord = new Coordinate( 3,6 );
    Point point7=gf.createPoint( coord );
     coord = new Coordinate( 1,6 );
    Point point8=gf.createPoint( coord );
     coord = new Coordinate( 6,2 );
    Point point9=gf.createPoint( coord );
     coord = new Coordinate( 7,1 );
    Point point10=gf.createPoint( coord );
    coord = new Coordinate( 6,4 );
    Point point11=gf.createPoint( coord );
     coord = new Coordinate( 9,2);
    Point point12=gf.createPoint( coord );
    coord = new Coordinate( 3,8);
    Point point13=gf.createPoint( coord );
     coord = new Coordinate( 1,7);
    Point point14=gf.createPoint( coord );
    coord = new Coordinate( 3,7 );
    Point point15=gf.createPoint( coord );
     coord = new Coordinate( 5,7 );
    Point point16=gf.createPoint( coord );
    //Building the str object
    STRtree strTree=new STRtree();
    //inserting the points into the tree
    strTree.insert(point.getEnvelopeInternal(), point);
    strTree.insert(point2.getEnvelopeInternal(), point2);
    strTree.insert(point3.getEnvelopeInternal(), point3);
     strTree.insert(point4.getEnvelopeInternal(), point4);
    strTree.insert(point5.getEnvelopeInternal(), point5);
    strTree.insert(point6.getEnvelopeInternal(), point6);
     strTree.insert(point7.getEnvelopeInternal(), point7);
    strTree.insert(point8.getEnvelopeInternal(), point8);
    strTree.insert(point9.getEnvelopeInternal(), point9);
     strTree.insert(point10.getEnvelopeInternal(), point10);
    strTree.insert(point11.getEnvelopeInternal(), point11);
    strTree.insert(point12.getEnvelopeInternal(), point12);
     strTree.insert(point13.getEnvelopeInternal(), point13);
    strTree.insert(point14.getEnvelopeInternal(), point14);
    strTree.insert(point15.getEnvelopeInternal(), point15);
    strTree.insert(point16.getEnvelopeInternal(), point16);
    //Building the tree
    strTree.build();
    Coordinate coord2 = new Coordinate( 0,0 );
    Coordinate coord3 = new Coordinate( 5,5);
     Envelope e1=new Envelope(coord2,coord3);
     List List1 = strTree.query(e1);
     System.out.println(List1);
}
}
代码符合并运行,但我希望这些点按此顺序排序(根->子->叶)。但我的输出包含包络区域中的随机点。哪里出错了?

R树存储叶节点中的所有点

您正在寻找的“订单”不存在;所有结果必须来自树叶


JTS API看起来非常昂贵。包裹在信封中的点中的坐标。你可能想看看ELKI,我发现它有很高的性能。与普遍的看法相反,我发现ELKI R-树(至少在STR批量加载时)在32维中仍然工作得很好(普遍的知识声称R-树最多只能工作10维)。

我只需要一棵二维树,以正确显示根、子树和叶子(如果这不可能,至少我的叶子被包围的顺序,坐标会被随机显示)。有没有其他软件我可以使用,或者你可以调整这个代码来获得我的输出?嗯,我不知道“你的输出”。因为一个R树不会有一个点作为根节点,没有一个R树会给你一个点作为根节点。