精华内容
下载资源
问答
  • RTREE
    2022-08-05 13:34:29

    package com.github.davidmoten.rtree;

    import static org.junit.Assert.assertEquals;

    import java.util.List;

    import org.junit.Test;

    import com.github.davidmoten.grumpy.core.Position;
    import com.github.davidmoten.rtree.geometry.Geometries;
    import com.github.davidmoten.rtree.geometry.Point;
    import com.github.davidmoten.rtree.geometry.Rectangle;

    import rx.Observable;
    import rx.functions.Func1;

    public class LatLongExampleTest {

        private static final Point sydney = Geometries.point(151.2094, -33.86);
        private static final Point canberra = Geometries.point(149.1244, -35.3075);
        private static final Point brisbane = Geometries.point(153.0278, -27.4679);
        private static final Point bungendore = Geometries.point(149.4500, -35.2500);

        @Test
        public void testLatLongExample() {

            // This is to demonstrate how to use rtree to to do distance searches
            // with Lat Long points

            // Let's find all cities within 300km of Canberra

            RTree<String, Point> tree = RTree.star().create();
            tree = tree.add("Sydney", sydney);
            tree = tree.add("Brisbane", brisbane);

            // Now search for all locations within 300km of Canberra
            final double distanceKm = 300;
            List<Entry<String, Point>> list = search(tree, canberra, distanceKm)
                    // get the result
                    .toList().toBlocking().single();

            // should have returned Sydney only
            assertEquals(1, list.size());
            assertEquals("Sydney", list.get(0).value());
        }

        public static <T> Observable<Entry<T, Point>> search(RTree<T, Point> tree, Point lonLat,
                final double distanceKm) {
            // First we need to calculate an enclosing lat long rectangle for this
            // distance then we refine on the exact distance
            final Position from = Position.create(lonLat.y(), lonLat.x());
            Rectangle bounds = createBounds(from, distanceKm);

            return tree
                    // do the first search using the bounds
                    .search(bounds)
                    // refine using the exact distance
                    .filter(new Func1<Entry<T, Point>, Boolean>() {
                        @Override
                        public Boolean call(Entry<T, Point> entry) {
                            Point p = entry.geometry();
                            Position position = Position.create(p.y(), p.x());
                            return from.getDistanceToKm(position) < distanceKm;
                        }
                    });
        }

        @Test
        public void testSearchLatLongCircles() {
            RTree<GeoCircleValue<String>, Rectangle> tree = RTree.star().create();
            // create circles around these major towns
            GeoCircleValue<String> sydneyCircle = createGeoCircleValue(sydney, 100, "Sydney");
            GeoCircleValue<String> canberraCircle = createGeoCircleValue(canberra, 50, "Canberra");
            GeoCircleValue<String> brisbaneCircle = createGeoCircleValue(brisbane, 200, "Brisbane");

            // add the circles to the RTree using the bounding box of the circle as
            // the geometry
            tree = add(tree, sydneyCircle);
            tree = add(tree, canberraCircle);
            tree = add(tree, brisbaneCircle);

            // now find the circles that contain bungendore (which is 30km from
            // Canberra)
            final Point location = bungendore;
            String result = tree.search(location)
                    // filter on the exact distance from the centre of the GeoCircle
                    .filter(new Func1<Entry<GeoCircleValue<String>, Rectangle>, Boolean>() {
                        Position from = Position.create(location.y(), location.x());

                        @Override
                        public Boolean call(Entry<GeoCircleValue<String>, Rectangle> entry) {
                            Position centre = Position.create(entry.value().lat, entry.value().lon);
                            return from.getDistanceToKm(centre) < entry.value().radiusKm;
                        }
                    })
                    // do the search (only expect one value)
                    .toBlocking().single()
                    // get the name of the GoeCircleValue returned
                    .value().value;
            assertEquals("Canberra", result);
        }

        private static Rectangle createBounds(final Position from, final double distanceKm) {
            // this calculates a pretty accurate bounding box. Depending on the
            // performance you require you wouldn't have to be this accurate because
            // accuracy is enforced later
            Position north = from.predict(distanceKm, 0);
            Position south = from.predict(distanceKm, 180);
            Position east = from.predict(distanceKm, 90);
            Position west = from.predict(distanceKm, 270);

            return Geometries.rectangle(west.getLon(), south.getLat(), east.getLon(), north.getLat());
        }

        private static <T> GeoCircleValue<T> createGeoCircleValue(Point point, double radiusKm,
                T value) {
            return new GeoCircleValue<T>((float) point.y(), (float) point.x(), radiusKm, value);
        }

        private static <T> RTree<GeoCircleValue<T>, Rectangle> add(
                RTree<GeoCircleValue<T>, Rectangle> tree, GeoCircleValue<T> c) {
            return tree.add(c, createBounds(Position.create(c.lat, c.lon), c.radiusKm));
        }

        private static class GeoCircleValue<T> {

            GeoCircleValue(float lat, float lon, double radiusKm, T value) {
                this.lat = lat;
                this.lon = lon;
                this.radiusKm = radiusKm;
                this.value = value;
            }

            float lat;
            float lon;
            double radiusKm;
            T value;
        }
    }

    更多相关内容
  • rtree2d:RTree2D是带有STR(排序-递归-递归)打包的2D不可变R树,用于超快最近和交叉查询
  • rtree:不变的RTree实现

    2021-05-16 11:38:54
    不变的RTree实现 这基于矩形作为空间值。 以下示例显示了它的工作方式: // based on petomat/geom import de . petomat . geom . _ // define our custom element type to be inserted into the rtree case ...
  • dalaba-rtree 基于坐标点选择的R-Tree实现,使用hilbertcurve打包xy坐标 Demos Point selelct of DOMElements Installing R-Tree依赖基础dalaba框架. 应首先加载dalaba.js,HTML的script在打包后的dist目录中引用...
  • rtred:Go的RTree实现

    2021-05-23 05:19:03
    Go的RTree实现 该软件包为Go提供了内存中的R-Tree实现,可用作空间数据结构。 它支持1-20维,并且可以在同一棵树中互换存储和搜索多维。作者1983年加州大学伯克利分校的Antonin Guttman和Michael Stonebraker提出了...
  • RTree.rar,RTree,Point.java,Rectangle.java,RTDirNode.java,RTree.java,RTDataNode.java,RTNode.java
  • RTree-开源

    2021-04-27 06:33:44
    基于磁盘的生产质量RTree,基于Guttman的二次分割算法,具有以下功能:具有脏写的缓冲,索引联接,树种子,窗口和NN查询,运行时STR打包功能,完全线程安全。
  • shuffle源码rtree-3d 注意:这个项目不是在积极开发中。 有关 n 维 R 树的信息,请参阅。 java中的三维R-Tree。 受时空查询的启发 节点可以序列化到磁盘或网络存储。 特别感兴趣的是将大型静态数据集序列化为顶级树...
  • rtree:Go的R树实现

    2021-05-13 13:30:17
    RTree// insert a pointtr . Insert ([ 2 ] float64 { - 112.0078 , 33.4373 }, [ 2 ] float64 { - 112.0078 , 33.4373 }, "PHX" )// insert a recttr . Insert ([ 2 ] float64 { 10 , 10 }, [ 2 ] float64 { 20 , ...
  • 彻底弄懂RTree索引

    2021-03-14 14:54:09
    包括R树的增删改查以及固有特性,包含例子讲解
  • 精通RTree RTree是支持为任意范围搜索构建边界矩形树的索引。 RTree对于地理空间数据非常有效,但可以扩展以支持任何适合范围搜索的数据。 会话RTree是Java中RTree的超维(2D,3D,4D,nD)实现。 转换RTree以与传统...
  • Rtree-0.9.4-cp36-cp36m-win_amd64.whl
  • Rtree-0.9.7-pp37-pypy37_pp73-win_amd64
  • # include " rtree.h "struct city { char *name; double lat; double lon;};struct city phx = { . name = " Phoenix " , . lat = 33.448 , . lon = - 112.073 };struct city enn = { . name = " Ennis " , . lat =...
  • C#RTree项目旨在维护RTree空间索引算法的C#版本。 从https://sourceforge.net/projects/jsi移植
  • rtree-master.zip,rtree-master,rtree.gemspec,Rakefile,test,rleaf_test.rb,shape_test.rb,test_helper.rb,bounding_box_test.rb,rnode_test.rb,LICENSE,Gemfile,Gemfile.lock,.ruby-version,.gitignore,lib,rtree....
  • Java RTree项目旨在维护RTree空间索引算法的Java版本。 有关更多信息,请参见http://jsi.sourceforge.net;有关最新开发代码,请参见http://github.com/aled/jsi。
  • python离线安装包,亲测可用
  • Rtree-0.8.3-cp34-cp34m-win32

    2021-08-19 18:52:42
    Rtree-0.8.3-cp34-cp34m-win32
  • Rtree的简单介绍,主要详细的介绍了rtree的创建过程。
  • RTree-master.zip,RTree-master,SpatialIndexStructures,SpatialIndexStructures.csproj,bin,Debug,RTree.dll,RTree.pdb,SpatialIndexStructures.pdb,SpatialIndexStructures.dll,packages.config,obj,Debug,...
  • Rtree-0.9.7-cp36-cp36m-win32

    2021-08-19 18:53:04
    Rtree-0.9.7-cp36-cp36m-win32
  • 一个比较好理解的javartree的实现
  • RTree-master.zip,RTree-master,.gitignore,configure,assgn4_r_data.txt,Makefile,objects,DUMMY,rtree.cpp,assgn4_r_querysample.txt,LICENSE,config.h,data.tar.gz,README.md,stats.sh,QUESTION.pdf,leaves,DUMMY...
  • Rtree-0.9.7-cp310-cp310-win32
  • Rtree-0.9.7-cp37-cp37m-win32

    2021-08-19 18:53:10
    Rtree-0.9.7-cp37-cp37m-win32
  • TM-RTree:用于范围查询的通用移动对象的索引
  • rtree-cuda CUDA R树构建去做将级别内核调用合并为单个内核kernel() { while(more-levels) { c_create_level() } } 使用共享内存添加 c 结构(从历史中),以进行比较
  • 在visual2008平台上,实现的hilbertR树
  • Rtree-0.9.7-cp310-cp310-win_amd64

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 5,103
精华内容 2,041
关键字:

RTREE