protected override int CompleteTileCore(TileInfo args) { if (args.State == TileState.Initial) { _tileFeatures.Clear(); _tileAreasOfInterest.Clear(); _allBox = null; _knownGaps = null; return(NoError); } try { if (_allBox == null) { Assert.NotNull(args.AllBox, "args.AllBox"); _allBox = QaGeometryUtils.CreateBox(Assert.NotNull(args.AllBox, "AllBox")); } if (_knownGaps == null) { _knownGaps = new KnownGaps(_maxArea, _tolerance, _allBox); } Assert.NotNull(args.CurrentEnvelope, "args.CurrentEnvelope"); IEnvelope tileEnvelope = GeometryFactory.Clone(Assert.NotNull(args.CurrentEnvelope, "CurrentEnvelope")); tileEnvelope.SpatialReference = _spatialReference; var errorCount = 0; foreach (IEnvelope subtile in GetSubtiles(tileEnvelope)) { errorCount += CheckSubtile(subtile, _allBox, _tileFeatures, _knownGaps); // this can be the entire (cloned) tileEnvelope: Marshal.ReleaseComObject(subtile); GC.Collect(); GC.WaitForPendingFinalizers(); } if (args.State == TileState.Final) { _knownGaps = null; } return(errorCount); } finally { _tileFeatures.Clear(); } }
private int CheckSubtile([NotNull] IEnvelope tileEnvelope, [NotNull] Box allBox, [NotNull] IEnumerable <IFeature> features, [NotNull] KnownGaps knownGaps) { Assert.ArgumentNotNull(tileEnvelope, nameof(tileEnvelope)); Assert.ArgumentNotNull(allBox, nameof(allBox)); Assert.ArgumentNotNull(features, nameof(features)); Assert.ArgumentNotNull(knownGaps, nameof(knownGaps)); WKSEnvelope tileBox; WKSEnvelope clipBox; IEnvelope clipEnvelope = GetClipEnvelope(tileEnvelope, allBox, _tolerance, out tileBox, out clipBox); IList <IGeometry> geometriesToRelease; IList <IGeometry> clippedPolygons; if (_findGapsBelowTolerance) { clippedPolygons = GetClippedPolygonCopies( clipEnvelope, _spatialReference, features); geometriesToRelease = clippedPolygons; } else { clippedPolygons = GetClippedPolygons( clipEnvelope, features, out geometriesToRelease); } IPolygon clipPolygon = GeometryFactory.CreatePolygon(clipEnvelope); IList <IPolygon> gapPolygons = GetGapPolygons(clippedPolygons, clipPolygon, clipEnvelope, tileEnvelope).ToList(); var errorCount = 0; foreach (IPolygon completedGap in knownGaps.GetCompletedGaps(gapPolygons, clipEnvelope, tileEnvelope)) { errorCount += CheckGapPolygon(completedGap); } ReleaseGeometries(geometriesToRelease); return(errorCount); }