Rtree实现多维空间搜索-创新互联
好的,现在有这么一个需求。你所开发的应用的数据库中有全市所有饭店的经纬度坐标,现在你在某地定位了一个坐标,应用如何给你找出最近的饭店。多维空间搜索,使用RTree。这里只推荐已有的实现了RTree的jar包。

maven项目,可下载jar包,并且这是一个简单的例子:https://github.com/aled/jsi-examples
在线API:http://jsi.sourceforge.net/apidocs/index.html
下面附上自己很low的测试代码:
net.sf.jsi.examples;
gnu.trove.procedure.TIntProcedure;
net.sf.jsi.Point;
net.sf.jsi.Rectangle;
net.sf.jsi.SpatialIndex;
net.sf.jsi.rtree.RTree;
TestRTree {
run() {
Point point = Point(, );
Rectangle[] rectangle = Rectangle[];
rectangle[] = Rectangle(, , , );
rectangle[] = Rectangle(, , , );
rectangle[] = Rectangle(-, -, -, -);
rectangle[] = Rectangle(-, -, -, -);
SpatialIndex si = RTree();
si.init();
(i = ; i < rectangle.; i++) {
si.add(rectangle[i], i);
}
si.nearestN(point, TIntProcedure() {
execute(i) {
System..println(+ i + + [i] + + [i].distance());
;
}
}, , Float.);
}
main(String[] args) {
TestRTree().run();
}
}另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
文章题目:Rtree实现多维空间搜索-创新互联
分享URL:http://lzwzjz.cn/article/coehco.html


咨询
建站咨询
