Beispiel #1
0
            /// <summary>
            /// Returns true if the provided cell, and all its sub-cells down to
            /// detailLevel all intersect the queryShape.
            /// </summary>
            private bool AllCellsIntersectQuery(Cell cell, SpatialRelation relate /*cell to query*/)
            {
                if (relate == SpatialRelation.NOT_SET)
                {
                    relate = cell.Shape.Relate(m_outerInstance.m_queryShape);
                }
                if (cell.Level == m_outerInstance.m_detailLevel)
                {
                    return(relate.Intersects());
                }
                if (relate == SpatialRelation.WITHIN)
                {
                    return(true);
                }
                if (relate == SpatialRelation.DISJOINT)
                {
                    return(false);
                }
                // Note: Generating all these cells just to determine intersection is not ideal.
                // It was easy to implement but could be optimized. For example if the docs
                // in question are already marked in the 'outside' bitset then it can be avoided.
                ICollection <Cell> subCells = cell.GetSubCells(null);

                foreach (Cell subCell in subCells)
                {
                    if (!AllCellsIntersectQuery(subCell, SpatialRelation.NOT_SET))
                    {
                        //recursion
                        return(false);
                    }
                }
                return(true);
            }
Beispiel #2
0
            /// <summary>
            /// Returns true if the provided cell, and all its sub-cells down to
            /// detailLevel all intersect the queryShape.
            /// </summary>
            private bool AllCellsIntersectQuery(Cell cell, SpatialRelation relate /*cell to query*/)
            {
                // LUCENENET specific - added guard clause
                if (cell is null)
                {
                    throw new ArgumentNullException(nameof(cell));
                }

                if (relate == SpatialRelation.None)
                {
                    relate = cell.Shape.Relate(m_filter.m_queryShape);
                }
                if (cell.Level == m_filter.m_detailLevel)
                {
                    return(relate.Intersects());
                }
                if (relate == SpatialRelation.Within)
                {
                    return(true);
                }
                if (relate == SpatialRelation.Disjoint)
                {
                    return(false);
                }
                // Note: Generating all these cells just to determine intersection is not ideal.
                // It was easy to implement but could be optimized. For example if the docs
                // in question are already marked in the 'outside' bitset then it can be avoided.
                ICollection <Cell> subCells = cell.GetSubCells(null);

                foreach (Cell subCell in subCells)
                {
                    if (!AllCellsIntersectQuery(subCell, SpatialRelation.None))
                    {
                        //recursion
                        return(false);
                    }
                }
                return(true);
            }
 /// <summary>
 /// Returns true if the provided cell, and all its sub-cells down to
 /// detailLevel all intersect the queryShape.
 /// </summary>
 private bool AllCellsIntersectQuery(Cell cell, SpatialRelation relate/*cell to query*/)
 {
     if (relate == SpatialRelation.NOT_SET)
     {
         relate = cell.Shape.Relate(outerInstance.queryShape);
     }
     if (cell.Level == outerInstance.detailLevel)
     {
         return relate.Intersects();
     }
     if (relate == SpatialRelation.WITHIN)
     {
         return true;
     }
     if (relate == SpatialRelation.DISJOINT)
     {
         return false;
     }
     // Note: Generating all these cells just to determine intersection is not ideal.
     // It was easy to implement but could be optimized. For example if the docs
     // in question are already marked in the 'outside' bitset then it can be avoided.
     ICollection<Cell> subCells = cell.GetSubCells(null);
     foreach (Cell subCell in subCells)
     {
         if (!AllCellsIntersectQuery(subCell, SpatialRelation.NOT_SET))
         {
             //recursion
             return false;
         }
     }
     return true;
 }