A SpatialPrefixTree which uses a quad tree in which an indexed term will be generated for each cell, 'A', 'B', 'C', 'D'.
Inheritance: SpatialPrefixTree
示例#1
0
 public QuadCell(QuadPrefixTree _enclosing, string token, SpatialRelation shapeRel
                 )
     : base(token)
 {
     this._enclosing = _enclosing;
     this.shapeRel   = shapeRel;
 }
示例#2
0
            protected internal override ICollection <Cell> GetSubCells()
            {
                QuadPrefixTree outerInstance = (QuadPrefixTree)this.m_outerInstance;
                IList <Cell>   cells         = new List <Cell>(4);

                cells.Add(new QuadCell(outerInstance, TokenString + "A"));
                cells.Add(new QuadCell(outerInstance, TokenString + "B"));
                cells.Add(new QuadCell(outerInstance, TokenString + "C"));
                cells.Add(new QuadCell(outerInstance, TokenString + "D"));
                return(cells);
            }
示例#3
0
            protected internal override ICollection <Cell> GetSubCells()
            {
                QuadPrefixTree outerInstance = (QuadPrefixTree)this.m_outerInstance;

                return(new List <Cell>(4)
                {
                    new QuadCell(outerInstance, TokenString + "A"),
                    new QuadCell(outerInstance, TokenString + "B"),
                    new QuadCell(outerInstance, TokenString + "C"),
                    new QuadCell(outerInstance, TokenString + "D")
                });
            }
示例#4
0
            private IRectangle MakeShape()
            {
                QuadPrefixTree outerInstance = (QuadPrefixTree)this.m_outerInstance;
                string         token         = TokenString;
                double         xmin          = outerInstance.xmin;
                double         ymin          = outerInstance.ymin;

                for (int i = 0; i < token.Length; i++)
                {
                    char c = token[i];
                    if ('A' == c || 'a' == c)
                    {
                        ymin += outerInstance.levelH[i];
                    }
                    else if ('B' == c || 'b' == c)
                    {
                        xmin += outerInstance.levelW[i];
                        ymin += outerInstance.levelH[i];
                    }
                    else if ('C' == c || 'c' == c)
                    {
                        // nothing really
                    }
                    else if ('D' == c || 'd' == c)
                    {
                        xmin += outerInstance.levelW[i];
                    }
                    else
                    {
                        throw new Exception("unexpected char: " + c);
                    }
                }
                int    len = token.Length;
                double width;
                double height;

                if (len > 0)
                {
                    width  = outerInstance.levelW[len - 1];
                    height = outerInstance.levelH[len - 1];
                }
                else
                {
                    width  = outerInstance.gridW;
                    height = outerInstance.gridH;
                }
                return(outerInstance.m_ctx.MakeRectangle(xmin, xmin + width, ymin, ymin + height));
            }
示例#5
0
            public IEnumerable<Param> ParamsProvider()
            {
                var ctorArgs = new List<Param>();

                SpatialContext ctx = SpatialContext.GEO;

                SpatialPrefixTree grid = new GeohashPrefixTree(ctx, 12);
                SpatialStrategy strategy = new RecursivePrefixTreeStrategy(grid, "recursive_geohash");
                ctorArgs.Add(new Param(strategy));

                grid = new QuadPrefixTree(ctx, 25);
                strategy = new RecursivePrefixTreeStrategy(grid, "recursive_quad");
                ctorArgs.Add(new Param(strategy));

                grid = new GeohashPrefixTree(ctx, 12);
                strategy = new TermQueryPrefixTreeStrategy(grid, "termquery_geohash");
                ctorArgs.Add(new Param(strategy));

                strategy = new PointVectorStrategy(ctx, "pointvector");
                ctorArgs.Add(new Param(strategy));

                return ctorArgs;
            }
示例#6
0
        //@ParametersFactory
        public static IList<Object[]> Parameters()
        {
            List<Object[]> ctorArgs = new List<object[]>();

            SpatialContext ctx = SpatialContext.GEO;
            SpatialPrefixTree grid;
            SpatialStrategy strategy;

            grid = new QuadPrefixTree(ctx, 25);
            strategy = new RecursivePrefixTreeStrategy(grid, "recursive_quad");
            ctorArgs.Add(new Object[] { new Param(strategy) });

            grid = new GeohashPrefixTree(ctx, 12);
            strategy = new TermQueryPrefixTreeStrategy(grid, "termquery_geohash");
            ctorArgs.Add(new Object[] { new Param(strategy) });

            strategy = new PointVectorStrategy(ctx, "pointvector");
            ctorArgs.Add(new Object[] { new Param(strategy) });

            strategy = new SerializedDVStrategy(ctx, "serialized");
            ctorArgs.Add(new Object[] { new Param(strategy) });

            return ctorArgs;
        }
示例#7
0
 public QuadCell(QuadPrefixTree outerInstance, string token)
     : base(outerInstance, token)
 {
 }
示例#8
0
 public QuadCell(QuadPrefixTree _enclosing, string token)
     : base(token)
 {
     this._enclosing = _enclosing;
 }
示例#9
0
 internal QuadCell(QuadPrefixTree _enclosing, byte[] bytes, int off, int len)
     : base(bytes, off, len)
 {
     this._enclosing = _enclosing;
 }
示例#10
0
 public QuadCell(QuadPrefixTree _enclosing, string token, SpatialRelation shapeRel
     )
     : base(token)
 {
     this._enclosing = _enclosing;
     this.shapeRel = shapeRel;
 }
示例#11
0
 public QuadCell(QuadPrefixTree _enclosing, string token)
     : base(token)
 {
     this._enclosing = _enclosing;
 }
示例#12
0
            protected internal override int GetLevelForDistance(double degrees)
            {
                var grid = new QuadPrefixTree(m_ctx, MAX_LEVELS_POSSIBLE);

                return(grid.GetLevelForDistance(degrees));
            }
示例#13
0
            protected internal override int GetLevelForDistance(double degrees)
            {
                var grid = new QuadPrefixTree(ctx, MaxLevelsPossible);

                return(grid.GetLevelForDistance(degrees));
            }
示例#14
0
 protected internal override int GetLevelForDistance(double degrees)
 {
     var grid = new QuadPrefixTree(ctx, MAX_LEVELS_POSSIBLE);
     return grid.GetLevelForDistance(degrees);
 }
 public QuadCell(String token, QuadPrefixTree enclosingInstance)
     : base(enclosingInstance, token)
 {
 }
示例#16
0
 internal QuadCell(QuadPrefixTree outerInstance, byte[] bytes, int off, int len)
     : base(outerInstance, bytes, off, len)
 {
 }
示例#17
0
 public QuadCell(QuadPrefixTree outerInstance, string token, SpatialRelation shapeRel)
     : base(outerInstance, token)
 {
     this.shapeRel = shapeRel;
 }
示例#18
0
 public QuadCell(QuadPrefixTree outerInstance, string token)
     : base(outerInstance, token)
 {
 }
示例#19
0
 public QuadCell(QuadPrefixTree outerInstance, string token, SpatialRelation shapeRel)
     : base(outerInstance, token)
 {
     this.m_shapeRel = shapeRel;
 }
示例#20
0
 public QuadCell(String token, SpatialRelation shapeRel, QuadPrefixTree enclosingInstance)
     : base(enclosingInstance, token)
 {
     this.shapeRel = shapeRel;
 }
示例#21
0
 internal QuadCell(QuadPrefixTree outerInstance, byte[] bytes, int off, int len)
     : base(outerInstance, bytes, off, len)
 {
 }
示例#22
0
 protected internal override int GetLevelForDistance(double degrees)
 {
     var grid = new QuadPrefixTree(ctx, MaxLevelsPossible);
     return grid.GetLevelForDistance(degrees);
 }
 public QuadCell(String token, SpatialRelation shapeRel, QuadPrefixTree enclosingInstance)
     : base(enclosingInstance, token)
 {
     this.shapeRel = shapeRel;
 }
示例#24
0
 internal QuadCell(QuadPrefixTree _enclosing, byte[] bytes, int off, int len)
     : base(bytes, off, len)
 {
     this._enclosing = _enclosing;
 }
示例#25
0
        public virtual void TestBadPrefixTreePrune()
        {

            IShape area = ctx.ReadShapeFromWkt("POLYGON((-122.83 48.57, -122.77 48.56, -122.79 48.53, -122.83 48.57))");

            SpatialPrefixTree trie = new QuadPrefixTree(ctx, 12);
            TermQueryPrefixTreeStrategy strategy = new TermQueryPrefixTreeStrategy(trie, "geo");
            Document doc = new Document();
            doc.Add(new TextField("id", "1", Field.Store.YES)); // LUCENENET TODO: Change API to Store.Yes

            Field[] fields = strategy.CreateIndexableFields(area, 0.025);
            foreach (Field field in fields)
            {
                doc.Add(field);
            }
            AddDocument(doc);

            IPoint upperleft = ctx.MakePoint(-122.88, 48.54);
            IPoint lowerright = ctx.MakePoint(-122.82, 48.62);

            Query query = strategy.MakeQuery(new SpatialArgs(SpatialOperation.Intersects, ctx.MakeRectangle(upperleft, lowerright)));
            Commit();

            TopDocs search = indexSearcher.Search(query, 10);
            ScoreDoc[] scoreDocs = search.ScoreDocs;
            foreach (ScoreDoc scoreDoc in scoreDocs)
            {
                Console.WriteLine(indexSearcher.Doc(scoreDoc.Doc));
            }

            assertEquals(1, search.TotalHits);
        }
示例#26
0
 public QuadCell(String token, QuadPrefixTree enclosingInstance)
     : base(enclosingInstance, token)
 {
 }