protected override int ExecuteCore(IRow row, int tableIndex) { var feature = (IFeature)row; IGeometry shape = feature.Shape; var polygonArea = shape as IArea; if (polygonArea == null) { return(0); } var polygon = shape as IPolygon; if (polygon == null) { return(ExecutePart(row, shape)); } PolygonPartType partType = _perPart ? PolygonPartType.ExteriorRing | PolygonPartType.Ring : PolygonPartType.Full; if (partType == PolygonPartType.Full || GeometryUtils.GetPartCount(polygon) == 1) { if (_useField) { double?areaValue = GdbObjectUtils.ReadRowValue <double>(row, _areaFieldIndex); if (areaValue != null) { return(CheckArea(Math.Abs(areaValue.Value), shape, row)); } } return(CheckArea(Math.Abs(polygonArea.Area), shape, row)); } // need to check the individual rings int errorCount = 0; foreach (IGeometry part in TestUtils.GetParts(polygon, partType)) { errorCount += ExecutePart(row, part); if (part != polygon) { // the part is some sub-component of the polygon, either // a ring or a connected-component polygon // -> release it to avoid pushing the VM allocation up Marshal.ReleaseComObject(part); } } return(errorCount); }
public static IEnumerable <IGeometry> GetParts([NotNull] IPolygon shape, PolygonPartType perPart) { if ((perPart & PolygonPartType.Full) == PolygonPartType.Full) { yield return(shape); } if ((perPart & PolygonPartType.ExteriorRing) == PolygonPartType.ExteriorRing) { foreach (IPolygon extPoly in GeometryUtils.GetConnectedComponents(shape)) { yield return(extPoly); } } if ((perPart & PolygonPartType.Ring) == PolygonPartType.Ring) { foreach (IRing ring in GeometryUtils.GetRings(shape)) { yield return(ring); } } }