簡単な質問があります
Java netbeans を使用して R ツリーのコードを実行したい (テスト用)
今、私はRツリーのこのライブラリを見つけましたhttps://sourceforge.net/projects/jsi/
ライブラリを追加できました。しかし、その後何?? クエリと挿入を実際に実行する方法..など??
誰でもそれで私を助けてくれませんか。私は初心者です
助けてください
皆さんありがとう
簡単な質問があります
Java netbeans を使用して R ツリーのコードを実行したい (テスト用)
今、私はRツリーのこのライブラリを見つけましたhttps://sourceforge.net/projects/jsi/
ライブラリを追加できました。しかし、その後何?? クエリと挿入を実際に実行する方法..など??
誰でもそれで私を助けてくれませんか。私は初心者です
助けてください
皆さんありがとう
これがNearestN.javaファイルのスニペットです。Contains.javaもあります
package net.sourceforge.jsi.examples;
import org.slf4j.*;
import com.infomatiq.jsi.*;
import gnu.trove.*;
import com.infomatiq.jsi.Rectangle;
import com.infomatiq.jsi.rtree.RTree;
public class NearestN {
private static final Logger log = LoggerFactory.getLogger(NearestN.class);
public static void main(String[] args) {
new NearestN().run();
}
private class NullProc implements TIntProcedure {
public boolean execute(int i) {
return true;
}
}
private void run() {
int rowCount = 1000;
int columnCount = 1000;
int count = rowCount * columnCount;
long start, end;
log.info("Creating " + count + " rectangles");
final Rectangle[] rects = new Rectangle[count];
int id = 0;
for (int row = 0; row < rowCount; row++)
for (int column = 0; column < rowCount; column++) {
rects[id++] = new Rectangle(row, column, row+0.5f, column+0.5f); //
}
log.info("Indexing " + count + " rectangles");
start = System.currentTimeMillis();
SpatialIndex si = new RTree();
si.init(null);
for (id=0; id < count; id++) {
si.add(rects[id], id);
}
final Point p = new Point(36.3f, 84.3f);
log.info("Querying for the nearest 3 rectangles to " + p);
si.nearestN(p, new TIntProcedure() {
public boolean execute(int i) {
log.info("Rectangle " + i + " " + rects[i] + ", distance=" + rects[i].distance(p));
return true;
}
}, 3, Float.MAX_VALUE);
}
それがあなたを少し助けることができることを願っています。
moskito-x によって投稿されたコードは、github でホストされている jsi-examples リポジトリからのものです。
次のコマンドでサンプルを実行できるはずです (Linux の場合)。
git clone https://github.com/aled/jsi-examples.git
cd jsi-examples
mvn package
cd target
unzip jsi-examples-1.0.0-SNAPSHOT-jar-with-dependencies.jar
java -cp .:./classes net.sourceforge.jsi.examples.Contains
ソースコードは、うまくいけば自明であるべきです。
アレッド。