public AbstractPrefixTreeFilter(IShape queryShape, string fieldName, SpatialPrefixTree grid, int detailLevel)
 {
     this.m_queryShape  = queryShape;
     this.m_fieldName   = fieldName;
     this.m_grid        = grid;
     this.m_detailLevel = detailLevel;
 }
Exemplo n.º 2
0
 public IntersectsPrefixTreeFilter(IShape queryShape, string fieldName,
                                   SpatialPrefixTree grid, int detailLevel,
                                   int prefixGridScanLevel, bool hasIndexedLeaves)
     : base(queryShape, fieldName, grid, detailLevel, prefixGridScanLevel)
 {
     this.hasIndexedLeaves = hasIndexedLeaves;
 }
Exemplo n.º 3
0
 protected AbstractPrefixTreeFilter(IShape queryShape, string fieldName, SpatialPrefixTree grid, int detailLevel) // LUCENENET: CA1012: Abstract types should not have constructors (marked protected)
 {
     this.m_queryShape  = queryShape;
     this.m_fieldName   = fieldName;
     this.m_grid        = grid;
     this.m_detailLevel = detailLevel;
 }
 public PointPrefixTreeFieldCacheProvider(SpatialPrefixTree grid, string shapeField
                                          , int defaultSize)
     : base(shapeField, defaultSize)
 {
     //
     this.grid = grid;
 }
        protected readonly int m_prefixGridScanLevel;//at least one less than grid.getMaxLevels()

        public AbstractVisitingPrefixTreeFilter(IShape queryShape, string fieldName, SpatialPrefixTree grid,
                                                int detailLevel, int prefixGridScanLevel)
            : base(queryShape, fieldName, grid, detailLevel)
        {
            this.m_prefixGridScanLevel = Math.Max(0, Math.Min(prefixGridScanLevel, grid.MaxLevels - 1));
            Debug.Assert(detailLevel <= grid.MaxLevels);
        }
Exemplo n.º 6
0
 protected AbstractPrefixTreeFilter(IShape queryShape, string fieldName, SpatialPrefixTree grid, int detailLevel) // LUCENENET: CA1012: Abstract types should not have constructors (marked protected)
 {
     // LUCENENET specific - added guard clauses
     this.m_queryShape  = queryShape ?? throw new ArgumentNullException(nameof(queryShape));
     this.m_fieldName   = fieldName ?? throw new ArgumentNullException(nameof(fieldName));
     this.m_grid        = grid ?? throw new ArgumentNullException(nameof(grid));
     this.m_detailLevel = detailLevel;
 }
Exemplo n.º 7
0
 public PrefixTreeStrategy(SpatialPrefixTree grid, string fieldName, bool simplifyIndexedCells
                           )
     : base(grid.SpatialContext, fieldName)
 {
     // [ 0 TO 0.5 ]
     this.grid = grid;
     this.simplifyIndexedCells = simplifyIndexedCells;
 }
Exemplo n.º 8
0
 public AbstractPrefixTreeFilter(Shape queryShape, string
                                 fieldName, SpatialPrefixTree grid, int detailLevel)
 {
     //not in equals/hashCode since it's implied for a specific field
     this.queryShape  = queryShape;
     this.fieldName   = fieldName;
     this.grid        = grid;
     this.detailLevel = detailLevel;
 }
Exemplo n.º 9
0
        public Filter ToFilter(SpatialContext spatialContext, SpatialPrefixTree tree)
        {
            var strategy = new RecursivePrefixTreeStrategy(tree, GeoFieldName);

            var spatialArgs = new SpatialArgs(SpatialOperation.Intersects,
                                              spatialContext.MakeRectangle(this.MinX, this.MaxX, this.MinY, this.MaxY));

            return(strategy.MakeFilter(spatialArgs));
        }
Exemplo n.º 10
0
        public Filter ToFilter(SpatialContext spatialContext, SpatialPrefixTree tree)
        {
            var strategy = new RecursivePrefixTreeStrategy(tree, GeoFieldName);

            var spatialArgs = new SpatialArgs(SpatialOperation.Intersects,
                                              spatialContext.MakeCircle(X, Y, DistanceUtils.Dist2Degrees(this.Distance, DistanceUtils.EARTH_MEAN_RADIUS_KM)));

            return(strategy.MakeFilter(spatialArgs));
        }
Exemplo n.º 11
0
		public RecursivePrefixTreeFilter(String fieldName, SpatialPrefixTree grid, Shape queryShape, int prefixGridScanLevel,
							 int detailLevel)
		{
			this.fieldName = fieldName;
			this.grid = grid;
			this.queryShape = queryShape;
			this.prefixGridScanLevel = Math.Max(1, Math.Min(prefixGridScanLevel, grid.GetMaxLevels() - 1));
			this.detailLevel = detailLevel;
			Debug.Assert(detailLevel <= grid.GetMaxLevels());
		}
Exemplo n.º 12
0
        private void InitSpatial()
        {
            if (_spatialContext == null)
            {
                _spatialContext = SpatialContext.GEO;

                int maxLevels = 11;
                _tree = new GeohashPrefixTree(_spatialContext, maxLevels);
            }
        }
 public virtual void SetupGeohashGrid(int maxLevels)
 {
     this.ctx = SpatialContext.GEO;
     //A fairly shallow grid, and default 2.5% distErrPct
     if (maxLevels == -1)
     {
         maxLevels = randomIntBetween(1, 3);//max 16k cells (32^3)
     }
     this.grid     = new GeohashPrefixTree(ctx, maxLevels);
     this.strategy = new RecursivePrefixTreeStrategy(grid, GetType().Name);
 }
        public Filter ToFilter(SpatialContext spatialContext, SpatialPrefixTree tree)
        {
            var strategy = new RecursivePrefixTreeStrategy(tree, GeoFieldName);

            var spatialArgs = new SpatialArgs(SpatialOperation.Intersects,
                                              spatialContext.MakeBufferedLineString(
                                                  this.Points.Select(p => (IPoint) new Point(p[0], p[1], spatialContext)).ToList(),
                                                  DistanceUtils.Dist2Degrees(this.Distance, DistanceUtils.EARTH_MEAN_RADIUS_KM)));

            return(strategy.MakeFilter(spatialArgs));
        }
 public AbstractVisitingPrefixTreeFilter(Shape queryShape
                                         , string fieldName, SpatialPrefixTree grid, int detailLevel,
                                         int prefixGridScanLevel
                                         )
     : base(queryShape, fieldName, grid, detailLevel)
 {
     //Historical note: this code resulted from a refactoring of RecursivePrefixTreeFilter,
     // which in turn came out of SOLR-2155
     //at least one less than grid.getMaxLevels()
     this.prefixGridScanLevel = Math.Max(0, Math.Min(prefixGridScanLevel, grid.MaxLevels - 1));
     Debug.Assert(detailLevel <= grid.MaxLevels);
 }
Exemplo n.º 16
0
        private readonly IShape bufferedQueryShape;//if null then the whole world

        /// <summary>
        /// See <see cref="AbstractVisitingPrefixTreeFilter.AbstractVisitingPrefixTreeFilter(IShape, string, SpatialPrefixTree, int, int)"/>.
        /// <c>queryBuffer</c> is the (minimum) distance beyond the query shape edge
        /// where non-matching documents are looked for so they can be excluded. If
        /// -1 is used then the whole world is examined (a good default for correctness).
        /// </summary>
        public WithinPrefixTreeFilter(IShape queryShape, string fieldName, SpatialPrefixTree grid,
                                      int detailLevel, int prefixGridScanLevel, double queryBuffer)
            : base(queryShape, fieldName, grid, detailLevel, prefixGridScanLevel)
        {
            if (queryBuffer == -1)
            {
                bufferedQueryShape = null;
            }
            else
            {
                bufferedQueryShape = BufferShape(queryShape, queryBuffer);
            }
        }
        private void SetupQuadGrid(int maxLevels)
        {
            //non-geospatial makes this test a little easier (in gridSnap), and using boundary values 2^X raises
            // the prospect of edge conditions we want to test, plus makes for simpler numbers (no decimals).
            FakeSpatialContextFactory factory = new FakeSpatialContextFactory();

            factory.geo         = false;
            factory.worldBounds = new Rectangle(0, 256, -128, 128, null);
            this.ctx            = factory.NewSpatialContext();
            //A fairly shallow grid, and default 2.5% distErrPct
            if (maxLevels == -1)
            {
                maxLevels = randomIntBetween(1, 8);//max 64k cells (4^8), also 256*256
            }
            this.grid     = new QuadPrefixTree(ctx, maxLevels);
            this.strategy = new RecursivePrefixTreeStrategy(grid, GetType().Name);
        }
Exemplo n.º 18
0
 /// <summary>
 /// See
 /// <see cref="AbstractVisitingPrefixTreeFilter">AbstractVisitingPrefixTreeFilter.AbstractVisitingPrefixTreeFilter(Shape, string, Lucene.Net.Spatial.Prefix.Tree.SpatialPrefixTree, int, int)
 ///     </see>
 /// .
 /// <code>queryBuffer</code>
 /// is the (minimum) distance beyond the query shape edge
 /// where non-matching documents are looked for so they can be excluded. If
 /// -1 is used then the whole world is examined (a good default for correctness).
 /// </summary>
 public WithinPrefixTreeFilter(Shape queryShape, string fieldName
                               , SpatialPrefixTree grid, int detailLevel, int prefixGridScanLevel,
                               double queryBuffer
                               )
     : base(queryShape, fieldName, grid, detailLevel, prefixGridScanLevel)
 {
     //TODO LUCENE-4869: implement faster algorithm based on filtering out false-positives of a
     //  minimal query buffer by looking in a DocValues cache holding a representative
     //  point of each disjoint component of a document's shape(s).
     //if null then the whole world
     if (queryBuffer == -1)
     {
         bufferedQueryShape = null;
     }
     else
     {
         bufferedQueryShape = BufferShape(queryShape, queryBuffer);
     }
 }
Exemplo n.º 19
0
        protected virtual SpatialStrategy MakeSpatialStrategy(Config config, IDictionary <string, string> configMap,
                                                              SpatialContext ctx)
        {
            //A factory for the prefix tree grid
            SpatialPrefixTree grid = SpatialPrefixTreeFactory.MakeSPT(configMap, /*null,*/ ctx); // LUCENENET TODO: What is this extra param?

            RecursivePrefixTreeStrategy strategy = new RecursivePrefixTreeStrategyAnonymousHelper(grid, SPATIAL_FIELD, config);

            int prefixGridScanLevel = config.Get("query.spatial.prefixGridScanLevel", -4);

            if (prefixGridScanLevel < 0)
            {
                prefixGridScanLevel = grid.MaxLevels + prefixGridScanLevel;
            }
            strategy.PrefixGridScanLevel = prefixGridScanLevel;

            double distErrPct = config.Get("spatial.distErrPct", .025);//doc & query; a default

            strategy.DistErrPct = distErrPct;
            return(strategy);
        }
Exemplo n.º 20
0
 public RecursivePrefixTreeStrategy(SpatialPrefixTree grid, string fieldName)
     : base(grid, fieldName)
 {
     prefixGridScanLevel = grid.GetMaxLevels() - 4;//TODO this default constant is dependent on the prefix grid size
 }
Exemplo n.º 21
0
 public RecursivePrefixTreeStrategyAnonymousHelper(SpatialPrefixTree grid, string fieldName, Config config)
     : base(grid, fieldName)
 {
     this.m_pointsOnly = config.Get("spatial.docPointsOnly", false);
 }
Exemplo n.º 22
0
        protected double m_distErrPct = SpatialArgs.DEFAULT_DISTERRPCT;                                   // [ 0 TO 0.5 ]

        protected PrefixTreeStrategy(SpatialPrefixTree grid, string fieldName, bool simplifyIndexedCells) // LUCENENET: CA1012: Abstract types should not have constructors (marked protected)
            : base(grid.SpatialContext, fieldName)
        {
            this.m_grid = grid;
            this.m_simplifyIndexedCells = simplifyIndexedCells;
        }
Exemplo n.º 23
0
        private readonly SpatialPrefixTree grid; //

        public PointPrefixTreeFieldCacheProvider(SpatialPrefixTree grid, string shapeField, int defaultSize)
            : base(shapeField, defaultSize)
        {
            // LUCENENT specific - added guard clause
            this.grid = grid ?? throw new ArgumentNullException(nameof(grid));
        }
 public RecursivePrefixTreeStrategyThatSupportsWithin(SpatialPrefixTree grid, string fieldName)
     : base(grid, fieldName)
 {
     _prefixGridScanLevel = grid.GetMaxLevels() - 4;
 }
Exemplo n.º 25
0
 public RecursivePrefixTreeStrategy(SpatialPrefixTree grid, string fieldName)
     : base(grid, fieldName, true)             //simplify indexed cells
 {
     prefixGridScanLevel = grid.MaxLevels - 4; //TODO this default constant is dependent on the prefix grid size
 }
Exemplo n.º 26
0
 public ContainsPrefixTreeFilter(IShape queryShape, string fieldName, SpatialPrefixTree grid, int detailLevel, bool multiOverlappingIndexedShapes)
     : base(queryShape, fieldName, grid, detailLevel)
 {
     this.multiOverlappingIndexedShapes = multiOverlappingIndexedShapes;
 }
        protected readonly int m_prefixGridScanLevel;//at least one less than grid.getMaxLevels()

        protected AbstractVisitingPrefixTreeFilter(IShape queryShape, string fieldName, SpatialPrefixTree grid,
                                                   int detailLevel, int prefixGridScanLevel) // LUCENENET: CA1012: Abstract types should not have constructors (marked protected)
            : base(queryShape, fieldName, grid, detailLevel)
        {
            this.m_prefixGridScanLevel = Math.Max(0, Math.Min(prefixGridScanLevel, grid.MaxLevels - 1));
            if (Debugging.AssertsEnabled)
            {
                Debugging.Assert(detailLevel <= grid.MaxLevels);
            }
        }
Exemplo n.º 28
0
 public TermQueryPrefixTreeStrategy(SpatialPrefixTree grid, string fieldName)
     : base(grid, fieldName, false)//do not simplify indexed cells
 {
 }
        protected double distErrPct = SpatialArgs.DEFAULT_DISTERRPCT; // [ 0 TO 0.5 ]

        protected PrefixTreeStrategy(SpatialPrefixTree grid, String fieldName)
            : base(grid.GetSpatialContext(), fieldName)
        {
            this.grid = grid;
        }
 public TermQueryPrefixTreeStrategy(SpatialPrefixTree grid, string fieldName)
     : base(grid, fieldName)
 {
 }