IItemVisitor{T}
您可以使用排除与绿色矩形相交的项目的自定义查询索引。沿着这些思路:
/// <summary>
/// Item visitor that specifically excludes a predefined area.
/// </summary>
/// <typeparam name="T">The type of the items to visit</typeparam>
public class ExcludingItemVisitor<T> : IItemVisitor<T> where T:Geometry
{
private readonly Envelope _exclude;
private readonly List<T> _items = new List<T>();
/// <summary>
/// Initialize with <paramref name="exclude"/>
/// </summary>
/// <param name="exclude"></param>
public ExcludingItemVisitor(Envelope exclude)
{
_exclude = exclude;
}
/// <inheritdoc cref="IItemVisitor{T}.VisitItem"/>>
public void VisitItem(T item)
{
// If we have no intersection with _exclude, add it.
if (!_exclude.Intersects(item.EnvelopeInternal))
_items.Add(item);
}
/// <summary>
/// Get a value indicating the gathered items
/// </summary>
public IList<T> Items => _items;
}