private int CheckLoop([NotNull] IGeometry geometry, int startVertexIndex, int endVertexIndex, [NotNull] IRow row) { Assert.ArgumentNotNull(geometry, nameof(geometry)); Assert.ArgumentNotNull(row, nameof(row)); const string baseMessage = "Boundary loop"; const string baseMessageStartPoint = "Boundary loop (start point)"; string noPolygonReason = string.Empty; IPolygon loopPolygon = null; if (_errorGeometry == BoundaryLoopErrorGeometry.LoopPolygon || _areaLimit > 0) { // the loop polygon will be needed, try to create it loopPolygon = BoundaryLoopUtils.TryCreateLoopPolygon(geometry, startVertexIndex, endVertexIndex, out noPolygonReason); } if (_areaLimit > 0) { return(CheckLoopArea(geometry, startVertexIndex, loopPolygon, noPolygonReason, row, baseMessage, baseMessageStartPoint)); } // no area check applied: if (_errorGeometry == BoundaryLoopErrorGeometry.LoopStartPoint) { return(ReportError(baseMessage, GetPoint(geometry, startVertexIndex), Codes[Code.BoundaryLoop], _shapeFieldName, row)); } // polygon is requested as error geometry if (loopPolygon == null) { // ... but the polygon could not be created string description = string.Format("{0} - unable to determine loop polygon: {1}", baseMessageStartPoint, noPolygonReason); return(ReportError(description, GetPoint(geometry, startVertexIndex), Codes[Code.BoundaryLoop_UnableToConstructLoopPolygon], _shapeFieldName, row)); } return(ReportError(baseMessage, loopPolygon, Codes[Code.BoundaryLoop], _shapeFieldName, row)); }
private static IPolyline GetOutermostBoundary(IPolygon fullUnionPolygon, out List <IRing> innerRings) { var resultRings = new List <IPath>(); innerRings = new List <IRing>(); foreach (IRing ring in GeometryUtils.GetRings(fullUnionPolygon)) { if (ring.IsExterior) { resultRings.Add(ring); } else { innerRings.Add(ring); } } IPolyline fullUnionOuterRings = GeometryFactory.CreatePolyline(resultRings); // TOP-4915: Must also handle boundary loops between source and target foreach (IPolygon boundaryLoop in BoundaryLoopUtils.GetBoundaryLoops( fullUnionPolygon, GeometryUtils.GetXyTolerance(fullUnionPolygon))) { // remove from result, add to rings IPolyline boundaryLoopLine = GeometryFactory.CreatePolyline(boundaryLoop); fullUnionOuterRings = (IPolyline)IntersectionUtils.Difference( fullUnionOuterRings, boundaryLoopLine); innerRings.AddRange(GeometryUtils.GetRings(boundaryLoop)); } return(fullUnionOuterRings); }