org.khelekore.prtree.NearestNeighbour Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of georewrite Show documentation
Show all versions of georewrite Show documentation
重写geoserver发送到h2的sql,以实现自定义数据源
package org.khelekore.prtree;
import java.util.PriorityQueue;
import java.util.ArrayList;
import java.util.List;
import org.khelekore.prtree.DistanceResult;
import org.khelekore.prtree.NodeFilter;
class NearestNeighbour {
private final MBRConverter converter;
private final NodeFilter filter;
private final int maxHits;
private final Node root;
private final DistanceCalculator dc;
private final PointND p;
public NearestNeighbour (MBRConverter converter,
NodeFilter filter,
int maxHits,
Node root,
DistanceCalculator dc,
PointND p) {
this.converter = converter;
this.filter = filter;
this.maxHits = maxHits;
this.root = root;
this.dc = dc;
this.p = p;
}
/**
* @return the nearest neighbour
*/
public List> find () {
List> ret = new ArrayList<> (maxHits);
MinDistComparator> nc =
new MinDistComparator<> (converter, p);
PriorityQueue> queue = new PriorityQueue<> (20, nc);
queue.add (root);
while (!queue.isEmpty ()) {
Node n = queue.remove ();
n.nnExpand (dc, filter, ret, maxHits, queue, nc);
}
return ret;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy