/// <summary> /// Creates a new <c>CleanupQuery</c> and executes it. /// </summary> /// <param name="model">The model to clean</param> internal CleanupQuery(CadastralMapModel model) { if (model == null) { throw new ArgumentNullException(); } m_Model = model; m_UpdateWindow = new Window(); m_Deletions = new List <ISpatialObject>(100); m_Moves = new List <Feature>(100); // Cleanup features model.Index.QueryWindow(null, SpatialType.Feature, CleanupFeature); // Cleanup polygons model.Index.QueryWindow(null, SpatialType.Polygon, CleanupPolygon); // Remove stuff from spatial index if it's been deleted EditingIndex index = model.EditingIndex; foreach (ISpatialObject o in m_Deletions) { m_UpdateWindow.Union(o.Extent); if (o is Feature) { index.RemoveFeature((Feature)o); } else if (o is Ring) { index.Remove(o); } else { throw new ApplicationException("Unexpected data type: " + o.GetType().Name); } } }