private IEnumerable <IWorkItem> GetItems(QueryFilter filter = null, int startIndex = -1, CurrentSearchOption currentSearch = CurrentSearchOption.ExcludeCurrent, VisitedSearchOption visitedSearch = VisitedSearchOption.ExcludeVisited) { IEnumerable <IWorkItem> query = GetItems(filter, false, startIndex); if (currentSearch == CurrentSearchOption.ExcludeCurrent) { query = query.Where(item => !Equals(item, Current)); } if (visitedSearch == VisitedSearchOption.ExcludeVisited) { query = query.Where(item => !item.Visited); } return(query); }
private bool TryGoNearest([NotNull] Polygon[] contextPerimeters, [NotNull] Geometry reference, VisitedSearchOption visitedSearchOption, int startIndex) { IList <IWorkItem> candidates = GetWorkItemsForInnermostContext(contextPerimeters, visitedSearchOption, startIndex); if (candidates.Count > 0) { IWorkItem nearest = GetNearest(reference, candidates); if (nearest != null) { SetCurrentItem(nearest, Current); return(true); } } return(false); }
private IList <IWorkItem> GetWorkItemsForInnermostContext([NotNull] Polygon[] perimeters, VisitedSearchOption visitedSearch, int startIndex) { Assert.ArgumentNotNull(perimeters, nameof(perimeters)); if (_msg.IsVerboseDebugEnabled) { _msg.DebugFormat("Getting work items for innermost context ({0} perimeters)", perimeters.Length); } const CurrentSearchOption currentSearch = CurrentSearchOption.ExcludeCurrent; for (var index = 0; index < perimeters.Length; index++) { Polygon intersection = GetIntersection(perimeters, index); if (intersection.IsEmpty) { // continue with next perimeter } else { // Possible optimization: do one search, // and qualify each candidate with "intersects" / "within" // --> filter result // todo daro: old implementation // search the items fully within the search extent //IList<WorkItem> workItems = GetItems(statusSearch, currentSearch, // visitedSearch, startIndex, // intersection, // SpatialSearchOption.Within, // match); SpatialQueryFilter filter = GdbQueryUtils.CreateSpatialFilter(intersection, SpatialRelationship.Within); List <IWorkItem> workItems = GetItems(filter, startIndex, currentSearch, visitedSearch).ToList(); if (workItems.Count == 0) { if (_msg.IsVerboseDebugEnabled) { _msg.Debug("No work items fully within the intersection, searching partially contained items"); } // todo daro: old implementation // search also intersecting items //workItems = GetItems(statusSearch, currentSearch, // visitedSearch, startIndex, // intersection, SpatialSearchOption.Intersect, // match); filter = GdbQueryUtils.CreateSpatialFilter(intersection); workItems = GetItems(filter, startIndex, currentSearch, visitedSearch).ToList(); } if (_msg.IsVerboseDebugEnabled) { _msg.DebugFormat("{0} work item(s) found", workItems.Count); } if (workItems.Count > 0) { return(workItems); } // else: continue with next perimeter } } // nothing found so far. Search entire work list // todo daro: old implementation //return GetItems(statusSearch, currentSearch, visitedSearch, startIndex, match); return(GetItems(null, startIndex, currentSearch, visitedSearch).ToList()); }