本文整理汇总了C#中Cell.GetSubCells方法的典型用法代码示例。如果您正苦于以下问题:C# Cell.GetSubCells方法的具体用法?C# Cell.GetSubCells怎么用?C# Cell.GetSubCells使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cell
的用法示例。
在下文中一共展示了Cell.GetSubCells方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AllCellsIntersectQuery
/// <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;
}
示例2: FindSubCellsToVisit
protected internal override IEnumerator<Cell> FindSubCellsToVisit(Cell cell)
{
//use buffered query shape instead of orig. Works with null too.
return cell.GetSubCells(((WithinPrefixTreeFilter)outerInstance).bufferedQueryShape).GetEnumerator();
}
示例3: Visit
//see getLeafDocs
/// <summary>This is the primary algorithm; recursive.</summary>
/// <remarks>This is the primary algorithm; recursive. Returns null if finds none.</remarks>
/// <exception cref="System.IO.IOException"></exception>
internal SmallDocSet Visit(Cell cell, IBits acceptContains
)
{
if (termsEnum == null)
{
//signals all done
return null;
}
//Leaf docs match all query shape
SmallDocSet leafDocs = GetLeafDocs(cell, acceptContains);
// Get the AND of all child results
SmallDocSet combinedSubResults = null;
ICollection<Cell> subCells = cell.GetSubCells(_enclosing.queryShape);
foreach (Cell subCell in subCells)
{
if (!SeekExact(subCell))
{
combinedSubResults = null;
}
else
{
if (subCell.Level == _enclosing.detailLevel)
{
combinedSubResults = GetDocs(subCell, acceptContains);
}
else
{
if (subCell.GetShapeRel() == SpatialRelation.WITHIN)
{
combinedSubResults = GetLeafDocs(subCell, acceptContains);
}
else
{
combinedSubResults = Visit(subCell, acceptContains);
}
}
}
//recursion
if (combinedSubResults == null)
{
break;
}
acceptContains = combinedSubResults;
}
//has the 'AND' effect on next iteration
// Result: OR the leaf docs with AND of all child results
if (combinedSubResults != null)
{
if (leafDocs == null)
{
return combinedSubResults;
}
return leafDocs.Union(combinedSubResults);
}
return leafDocs;
}
示例4: FindSubCellsToVisit
protected internal override IEnumerator<Cell> FindSubCellsToVisit(Cell cell)
{
//use buffered query shape instead of orig. Works with null too.
return cell.GetSubCells(_enclosing.bufferedQueryShape).GetEnumerator();
}
示例5: RecursiveGetCells
/// <summary>Returns true if cell was added as a leaf.</summary>
/// <remarks>
/// Returns true if cell was added as a leaf. If it wasn't it recursively
/// descends.
/// </remarks>
private bool RecursiveGetCells(Cell cell, IShape shape, int detailLevel,
bool inclParents, bool simplify,
IList<Cell> result)
{
if (cell.Level == detailLevel)
{
cell.SetLeaf();//FYI might already be a leaf
}
if (cell.IsLeaf)
{
result.Add(cell);
return true;
}
if (inclParents && cell.Level != 0)
{
result.Add(cell);
}
ICollection<Cell> subCells = cell.GetSubCells(shape);
int leaves = 0;
foreach (Cell subCell in subCells)
{
if (RecursiveGetCells(subCell, shape, detailLevel, inclParents, simplify, result))
{
leaves++;
}
}
//can we simplify?
if (simplify && leaves == cell.SubCellsSize && cell.Level != 0)
{
//Optimization: substitute the parent as a leaf instead of adding all
// children as leaves
//remove the leaves
do
{
result.RemoveAt(result.Count - 1);//remove last
}
while (--leaves > 0);
//add cell as the leaf
cell.SetLeaf();
if (!inclParents)// otherwise it was already added up above
{
result.Add(cell);
}
return true;
}
return false;
}