/// <summary> /// Removes the start/end point of a closed path while maintaining the closedness. /// </summary> /// <param name="wholeGeometry"></param> /// <param name="hitPartIndex"></param> /// <param name="partGeometry"></param> private static void RemoveClosedPathNullPoint([NotNull] IGeometry wholeGeometry, int hitPartIndex, [NotNull] IGeometry partGeometry) { // remove 0 and max, add new max var points = (IPointCollection)wholeGeometry; int lastIndex = ((IPointCollection)partGeometry).PointCount - 1; int partEndRealIndex = GeometryUtils.GetGlobalIndex(wholeGeometry, hitPartIndex, lastIndex); points.RemovePoints(partEndRealIndex, 1); int partStartRealIndex = GeometryUtils.GetGlobalIndex(wholeGeometry, hitPartIndex, 0); points.RemovePoints(partStartRealIndex, 1); IPoint newPoint = GeometryFactory.Clone(points.get_Point(partStartRealIndex)); object refMissing = Type.Missing; ((IPointCollection)partGeometry).AddPoint( newPoint, ref refMissing, ref refMissing); }
public void CanDeterminePolygonReshapeSideInsideOnlySeveralParts() { ISpatialReference spatialReference = SpatialReferenceUtils.CreateSpatialReference( WellKnownHorizontalCS.LV95, WellKnownVerticalCS.LHN95); IGeometry geometryToReshape = GeometryFactory.CreatePolygon(100, 100, 200, 200, spatialReference); IGeometry reshapeLine = GeometryFactory.CreatePolyline(spatialReference, GeometryFactory.CreatePoint(100, 200), GeometryFactory.CreatePoint(150, 100), GeometryFactory.CreatePoint(200, 200)); ReshapeInfo reshapeInfo = Reshape(GeometryFactory.Clone(geometryToReshape), reshapeLine, false); ExpectResult(reshapeInfo, RingReshapeSideOfLine.Left, 5000, 1, 1); const bool useNonDefaultSide = true; reshapeInfo = Reshape(GeometryFactory.Clone(geometryToReshape), reshapeLine, useNonDefaultSide); ExpectResult(reshapeInfo, RingReshapeSideOfLine.Right, 5000, 2, 2); }
private int ReportInvalidPoint([NotNull] IPoint point, [NotNull] IRow row) { double m = point.M; string error; const bool isNewRow = true; IssueCode issueCode; if (!IsInvalidValue(m, row, isNewRow, out error, out issueCode)) { return(NoError); } string errorDescription; if (StringUtils.IsNotEmpty(error)) { errorDescription = string.Format("Invalid M value: {0}", error); } else if (double.IsNaN(m)) { errorDescription = "Undefined M value"; } else { errorDescription = string.Format("Invalid M value: {0}", _invalidValue); } return(ReportError(errorDescription, GeometryFactory.Clone(point), issueCode, _shapeFieldName, row)); }
private static IGeometry CreateGeometryToStore( [NotNull] IGeometry geometry, [NotNull] ICollection <esriGeometryType> storedGeometryTypes) { Assert.ArgumentNotNull(geometry, nameof(geometry)); Assert.ArgumentNotNull(storedGeometryTypes, nameof(storedGeometryTypes)); esriGeometryType geometryType = geometry.GeometryType; if (storedGeometryTypes.Contains(geometryType)) { return(GeometryFactory.Clone(geometry)); } switch (geometry.GeometryType) { case esriGeometryType.esriGeometryPoint: return(storedGeometryTypes.Contains(esriGeometryType.esriGeometryMultipoint) ? GeometryFactory.CreateMultipoint((IPoint)geometry) : null); case esriGeometryType.esriGeometryMultiPatch: return(storedGeometryTypes.Contains(esriGeometryType.esriGeometryPolygon) ? GeometryFactory.CreatePolygon((IMultiPatch)geometry) : null); case esriGeometryType.esriGeometryEnvelope: return(storedGeometryTypes.Contains(esriGeometryType.esriGeometryPolygon) ? GeometryFactory.CreatePolygon((IEnvelope)geometry) : null); default: return(null); } }
private static IGeometry CreateErrorGeometry([NotNull] IPoint p0, [NotNull] IPoint p1) { return(GeometryUtils.AreEqualInXY(p0, p1) ? (IGeometry)GeometryFactory.Clone(p0) : GeometryFactory.CreatePolyline(p0, p1)); }
public static IPolyline GetLinearIntersection([NotNull] IPolyline line, [NotNull] IGeometry geometry, double?xyTolerance = null) { // the lines are often very short and close to each other --> xy cluster tolerance workaround is used far too often // --> test for IRelationalOperator.Equals at least if lines are very short? // --> if equal, return a clone of 'line'? if (xyTolerance != null) { double maxLengthWorkaround = xyTolerance.Value * 6; if (line.Length <= maxLengthWorkaround) { var otherLine = geometry as IPolyline; if (otherLine != null && otherLine.Length < maxLengthWorkaround) { if (((IRelationalOperator)line).Equals(otherLine)) { return(GeometryFactory.Clone(line)); } } } } return((IPolyline)IntersectionUtils.Intersect( line, geometry, esriGeometryDimension.esriGeometry1Dimension)); }
private static IMultipoint RemoveVertexIntersections( [NotNull] IMultipoint intersectionPoints, [NotNull] IPolyline polyline1, [NotNull] IPolyline polyline2, double vertexSearchDistance) { var remainingPoints = new List <IPoint>(); foreach (IPoint intersectionPoint in QueryPoints(intersectionPoints, TemplatePoint1)) { if (IntersectsVertex(intersectionPoint, polyline2, TemplatePoint2, vertexSearchDistance) && IntersectsVertex(intersectionPoint, polyline1, TemplatePoint2, vertexSearchDistance)) { // intersection point intersects vertex on both polylines // -> skip continue; } remainingPoints.Add(GeometryFactory.Clone(intersectionPoint)); } return(GeometryFactory.CreateMultipoint(remainingPoints)); }
protected static IMultiPatch CopyWithConvertedInnerRings( [NotNull] IMultiPatch multiPatch, [NotNull] IEnumerable <int> outerRingIndexes) { IMultiPatch result = GeometryFactory.Clone(multiPatch); var allFollowingRings = new List <IRing>(); foreach (int outerRingIndex in outerRingIndexes) { var ring = (IRing)((IGeometryCollection)result).Geometry[outerRingIndex]; int followingRingCount = result.FollowingRingCount[ring]; var followingRings = new IRing[followingRingCount]; GeometryUtils.GeometryBridge.QueryFollowingRings(result, ring, ref followingRings); allFollowingRings.AddRange(followingRings); } foreach (IRing followingRing in allFollowingRings) { result.PutRingType(followingRing, esriMultiPatchRingType.esriMultiPatchOuterRing); } return(result); }
private static IGeometry CreatePolygonFromRings([NotNull] IEnumerable <IRing> rings, [NotNull] IPolygon polygon) { Assert.ArgumentNotNull(polygon, nameof(polygon)); Assert.ArgumentNotNull(rings, nameof(rings)); IPolygon result = GeometryFactory.CreatePolygon(polygon.SpatialReference, GeometryUtils.IsZAware(polygon), GeometryUtils.IsMAware(polygon)); var geometryCollection = (IGeometryCollection)result; object missing = Type.Missing; foreach (IRing ring in rings) { geometryCollection.AddGeometry(GeometryFactory.Clone(ring), ref missing, ref missing); } const bool allowReorder = true; GeometryUtils.Simplify(result, allowReorder); return(result); }
private IEnumerable <IRing> ReadSingleExteriorRingPolygon( [NotNull] BinaryReader reader, Ordinates ordinates, bool?reverseOrder = null) { if (reader == null) { throw new ArgumentNullException(nameof(reader)); } int ringCount = checked ((int)reader.ReadUInt32()); bool zAware = ordinates == Ordinates.Xyz || ordinates == Ordinates.Xyzm; bool mAware = ordinates == Ordinates.Xym || ordinates == Ordinates.Xyzm; // NOTE: Somtimes this takes ca. 250ms (may be when the license is checked?)! IRing ringTemplate = GeometryFactory.CreateEmptyRing(zAware, mAware); if (ringCount > 0) { bool reverse = reverseOrder ?? !AssumeWkbPolygonsClockwise; var geometryBuilder = new WksPointListBuilder(reverse); foreach (WKSPointZ[] wksPoints in ReadLinestringsCore( reader, ordinates, ringCount, geometryBuilder)) { IRing resultRing = GeometryFactory.Clone(ringTemplate); GeometryUtils.SetWKSPointZs(resultRing, wksPoints); yield return(resultRing); } } }
private IPolygon GetSimplifiedPolygon([NotNull] IPolygon polygon) { IPolygon polygonCopy = _reducedResolutionSpatialReference != null ? GeometryFactory.Clone(polygon) : null; if (_minimumToleranceSpatialReference != null) { polygon.SpatialReference = _minimumToleranceSpatialReference; } // simplify first with the original tolerance, to get rid of vertical walls Simplify(polygon); if (polygon.IsEmpty) { // the polygon has become empty by the simplify (vertical or too small or invalid) // -> ignore return(null); } if (_reducedResolutionSpatialReference == null) { // return the simplified polygon return(polygon); } // simplify the original, with the minimum spatial reference Assert.NotNull(polygonCopy); polygonCopy.SpatialReference = _reducedResolutionSpatialReference; Simplify(polygonCopy); return(polygonCopy); }
private int CheckAngle([NotNull] IPoint connectPoint, [NotNull] IPoint otherSegmentEndPoint, double squaredSegmentLength, [NotNull] IPoint comparePoint, [NotNull] IRow feature, [NotNull] IRow compareFeature) { double distanceSquaredToComparePoint; double prod = GetProd(connectPoint, otherSegmentEndPoint, comparePoint, out distanceSquaredToComparePoint); if (prod > 0) { double cos2 = prod * prod / (squaredSegmentLength * distanceSquaredToComparePoint); if (cos2 > _limitCos2) { double angleRadians = Math.Acos(Math.Sqrt(cos2)); string description = string.Format("Angle {0} < {1}", FormatAngle(angleRadians, "N2"), FormatAngle(_limit, "N2")); return(ReportError(description, GeometryFactory.Clone(connectPoint), Codes[Code.AngleTooSmall], TestUtils.GetShapeFieldName(feature), new object[] { MathUtils.ToDegrees(angleRadians) }, feature, compareFeature)); } } return(NoError); }
public static ICollection <IPoint> GetPointsWithInvalidM( [NotNull] IPointCollection points, [NotNull] IPoint pointTemplate, double invalidValue) { Assert.ArgumentNotNull(points, nameof(points)); Assert.ArgumentNotNull(pointTemplate, nameof(pointTemplate)); IEnumVertex enumVertex = points.EnumVertices; int partIndex; int vertexIndex; enumVertex.QueryNext(pointTemplate, out partIndex, out vertexIndex); var result = new List <IPoint>(); while (partIndex >= 0 && vertexIndex >= 0) { if (IsInvalidValue(pointTemplate.M, invalidValue)) { result.Add(GeometryFactory.Clone(pointTemplate)); } enumVertex.QueryNext(pointTemplate, out partIndex, out vertexIndex); } return(result); }
public SegmentProxy GetSegment(int partIndex, int segmentIndex) { IEnumSegment enumSegs = _segments.EnumSegments; enumSegs.SetAt(partIndex, segmentIndex); ISegment segment; enumSegs.Next(out segment, ref partIndex, ref segmentIndex); ISegment proxiedSegment; if (enumSegs.IsRecycling) { proxiedSegment = GeometryFactory.Clone(segment); // release the segment, otherwise "pure virtual function call" occurs // when there are certain circular arcs (IsLine == true ?) Marshal.ReleaseComObject(segment); } else { proxiedSegment = segment; } return(new AoSegmentProxy(proxiedSegment, partIndex, segmentIndex)); }
public static void AddPaths([NotNull] IList <Linestring> linestringsToAdd, [NotNull] IPolyline toResult) { Func <Pnt3D, WKSPointZ> createPoint; if (GeometryUtils.IsZAware(toResult)) { createPoint = p => WKSPointZUtils.CreatePoint(p.X, p.Y, p.Z); } else { createPoint = p => WKSPointZUtils.CreatePoint(p.X, p.Y, double.NaN); } IPath pathTemplate = GeometryFactory.CreateEmptyPath(toResult); foreach (Linestring resultLinestring in linestringsToAdd) { var pathPoints = new WKSPointZ[resultLinestring.SegmentCount + 1]; var i = 0; foreach (Line3D line3D in resultLinestring) { pathPoints[i++] = createPoint(line3D.StartPoint); } Pnt3D last = resultLinestring[resultLinestring.SegmentCount - 1].EndPoint; pathPoints[i] = createPoint(last); IPath path = GeometryFactory.Clone(pathTemplate); GeometryUtils.AddWKSPointZs((IPointCollection4)path, pathPoints); ((IGeometryCollection)toResult).AddGeometry(path); } }
private static IEnvelope GetClipEnvelope([NotNull] IEnvelope tileEnvelope, [NotNull] Box allBox, double tolerance, out WKSEnvelope tileBox, out WKSEnvelope clipBox) { Assert.ArgumentNotNull(tileEnvelope, nameof(tileEnvelope)); Assert.ArgumentNotNull(allBox, nameof(allBox)); tileEnvelope.QueryWKSCoords(out tileBox); // the tolerance needs to be enlarged, otherwise there can be missed // errors when features touch tile boundaries double offsetDistance = tolerance * 3; // the clip box is enlarged to the left/bottom, by the tolerance, // unless the tile is to the left/bottom of the test box clipBox.XMin = Math.Max(allBox.Min.X, tileBox.XMin - offsetDistance); clipBox.YMin = Math.Max(allBox.Min.Y, tileBox.YMin - offsetDistance); clipBox.XMax = tileBox.XMax; clipBox.YMax = tileBox.YMax; IEnvelope result = GeometryFactory.Clone(tileEnvelope); result.PutWKSCoords(ref clipBox); return(result); }
public bool MoveNext() { ISegment segment; int partIndex = 0; int segIndex = 0; _enumSegment.Next(out segment, ref partIndex, ref segIndex); if (segment == null) { _currentSeg = null; return(false); } ISegment proxiedSegment; if (_isRecycling) { proxiedSegment = GeometryFactory.Clone(segment); // release the segment, otherwise "pure virtual function call" occurs // when there are certain circular arcs (IsLine == true ?) Marshal.ReleaseComObject(segment); } else { proxiedSegment = segment; } _currentSeg = new AoSegmentProxy(proxiedSegment, partIndex, segIndex); return(true); }
private IEnumerable <IFeature> GetFeaturesFromCache(IList <IFeature> cache, IPoint searchPoint, IList <esriGeometryType> geometryTypes) { if (SearchTolerance > GeometryUtils.GetXyTolerance(searchPoint)) { searchPoint = GeometryFactory.Clone(searchPoint); GeometryUtils.SetXyTolerance(searchPoint, SearchTolerance); } IEnumerable <IFeature> targetFeatures = cache.Where( f => { IGeometry shape = f.Shape; bool canBeUsed = geometryTypes.Contains(shape.GeometryType) && GeometryUtils.Intersects(searchPoint, shape); Marshal.ReleaseComObject(shape); return(canBeUsed); }); return(targetFeatures); }
protected override int CompleteTileCore(TileInfo args) { if (OnCachedRow != null) { if (args.CurrentEnvelope != null && args.State != TileState.Initial) { IEnvelope search = GeometryFactory.Clone(args.CurrentEnvelope); search.Expand(SearchDistance, SearchDistance, false); ISpatialFilter filter = new SpatialFilterClass(); filter.Geometry = search; filter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; int tableIndex = 0; foreach (ITable table in InvolvedTables) { var filterHelper = new QueryFilterHelper(table, null, false); filterHelper.ForNetwork = true; foreach (IRow cachedRow in Search(table, filter, filterHelper)) { OnCachedRow(args, cachedRow, tableIndex); } tableIndex++; } } } return(OnCompleteTile == null ? NoError : OnCompleteTile(args)); }
public void CanGetChangedVerticesSimplifiedZigZag() { // the source polyline visits the same points several times by going back and forth ISpatialReference lv95 = SpatialReferenceUtils.CreateSpatialReference(WellKnownHorizontalCS.LV95); IPolyline sourcePolyline = GeometryFactory.CreatePolyline( lv95, GeometryFactory.CreatePoint(0, 0), GeometryFactory.CreatePoint(10, 0), GeometryFactory.CreatePoint(20, 0), GeometryFactory.CreatePoint(10, 0), GeometryFactory.CreatePoint(20, 0), GeometryFactory.CreatePoint(30, 10)); IPolyline simplifiedPolyline = GeometryFactory.Clone(sourcePolyline); const bool allowNonPlanarLines = false; string nonSimpleReasonDescription; GeometryNonSimpleReason?nonSimpleReason; bool isSimple = GeometryUtils.IsGeometrySimple(sourcePolyline, lv95, allowNonPlanarLines, out nonSimpleReasonDescription, out nonSimpleReason); Assert.IsFalse(isSimple); GeometryUtils.Simplify(simplifiedPolyline, true, !allowNonPlanarLines); var geometryComparison = new GeometryComparison( sourcePolyline, simplifiedPolyline, 0.00125, 0.0125); const bool reportDuplicateVertices = true; IList <WKSPointZ> changes = geometryComparison.GetDifferentVertices(false, reportDuplicateVertices); Assert.AreEqual(2, changes.Count); changes = geometryComparison.GetDifferentVertices(true, reportDuplicateVertices); Assert.AreEqual(2, changes.Count); changes = geometryComparison.GetDifferentVertices(true, false); Assert.AreEqual(0, changes.Count); geometryComparison = new GeometryComparison( simplifiedPolyline, sourcePolyline, 0.00125, 0.0125); changes = geometryComparison.GetDifferentVertices(false, reportDuplicateVertices); Assert.AreEqual(0, changes.Count); changes = geometryComparison.GetDifferentVertices(true, reportDuplicateVertices); Assert.AreEqual(2, changes.Count); changes = geometryComparison.GetDifferentVertices(true, false); Assert.AreEqual(0, changes.Count); }
public void PrepareForSource(IGeometry sourceGeometry) { // Always clone _currentSourceGeometry because it could be projected if (_currentSourceGeometry != null) { Marshal.ReleaseComObject(_currentSourceGeometry); } _currentSourceGeometry = GeometryFactory.Clone(sourceGeometry); if (_useMinimalTolerance) { // Setting minimum tolerance is important, otherwise the union might not // be consistent with the difference lines GeometryUtils.SetMinimumXyTolerance(_currentSourceGeometry); } if (_sourceTargetPolyUnionBoundary != null) { Marshal.ReleaseComObject(_sourceTargetPolyUnionBoundary); } _sourceTargetPolyUnionBoundary = CreateSourceTargetPolyUnionBoundary( _currentSourceGeometry, _targetUnionPoly); }
private static IGeometry UnionReferenceGeometry( [NotNull] IList <IGeometry> relatedGeometries, int maximumPointCount) { Assert.ArgumentNotNull(relatedGeometries, nameof(relatedGeometries)); if (relatedGeometries.Count == 0) { return(null); } int pointCount = GeometryUtils.GetPointCount(relatedGeometries); if (pointCount > maximumPointCount) { return(GeometryUtils.UnionGeometryEnvelopes(relatedGeometries)); } if (relatedGeometries.Count == 1) { return(GeometryFactory.Clone(relatedGeometries[0])); } var copies = new List <IGeometry>(relatedGeometries.Count); foreach (IGeometry relatedGeometry in relatedGeometries) { copies.Add(GeometryFactory.Clone(relatedGeometry)); } const int toleranceFactor = 100; double bufferDistance = GeometryUtils.GetXyTolerance(copies[0]) * toleranceFactor; return(GeometryFactory.CreateUnion(copies, bufferDistance)); }
private IPolyline Reconnect([NotNull] IPolyline polyline, [NotNull] IPoint newEndPoint, bool atFromPoint) { IPolyline result = GeometryFactory.Clone(polyline); bool avoidBarrier = BarrierGeometryOriginal != null && !GeometryUtils.InteriorIntersects(polyline, BarrierGeometryOriginal); SetEndpoint(result, newEndPoint, atFromPoint); if (avoidBarrier) { // try to connect in a clever way such that the topological relation to the barrier remains unchanged if (BarrierGeometryChanged != null && GeometryUtils.InteriorIntersects(polyline, BarrierGeometryChanged)) { // cut back to the last vertex on the original side of the barrier, i.e. remove all // vertices between the end point and the intersection point result = RemoveVerticesBeyondBarrier(polyline, result, newEndPoint, atFromPoint); } } return(result); }
public bool MoveNext() { DisposeCurrent(); ISegment segment; if (!_reverse) { _enumSegment.Next(out segment, ref _currentPartIndex, ref _currentSegmentIndex); } else { _enumSegment.Previous(out segment, ref _currentPartIndex, ref _currentSegmentIndex); } if (segment == null) { _current = null; } else { if (_recycling && !Recycle) { _current = GeometryFactory.Clone(segment); Marshal.ReleaseComObject(segment); } else { _current = segment; } } return(_current != null); }
private static IEnvelope GetClipBox([NotNull] IEnvelope box, [NotNull] IRaster raster) { IEnvelope result = GeometryFactory.Clone(box); WKSEnvelope wks; result.QueryWKSCoords(out wks); double expandX = 0; double expandY = 0; var props = raster as IRasterProps; if (props != null) { IPnt pnt = props.MeanCellSize(); expandX = 2 * Math.Abs(pnt.X); expandY = 2 * Math.Abs(pnt.Y); } wks.XMin -= expandX; wks.XMax += expandX; wks.YMin -= expandY; wks.YMax += expandY; result.PutWKSCoords(wks); return(result); }
private int ReportError([NotNull] IFeature feature, [NotNull] IPoint node, [NotNull] TooCloseNeighbor neighborTooClose) { double searchDistance = _nearTolerancesByTableIndex[neighborTooClose.TableIndex]; IPoint errorGeometry = GeometryFactory.Clone(node); string description = string.Format( "Unconnected node is too close to nearest (border)-line: {0}", FormatLengthComparison(neighborTooClose.Distance, Math.Abs(neighborTooClose.Distance - searchDistance) < double.Epsilon ? "=" : "<", searchDistance, _spatialReference)); // NOTE: currently the neighbors are different features; this may be changed later IssueCode issueCode = feature == neighborTooClose.Feature ? Codes[Code.NodeTooCloseToLine_WithinFeature] : Codes[Code.NodeTooCloseToLine_BetweenFeatures]; return(ReportError(description, errorGeometry, issueCode, _shapeFieldName, new object[] { neighborTooClose.Distance }, feature, neighborTooClose.Feature)); }
private static IGeometry GetSelectedGeometryParts( [CanBeNull] IGeometry selectionArea, bool selectionAreaMustContain, [NotNull] IGeometryCollection fromGeometryCollection) { IGeometry result = null; foreach ( IGeometry highLevelPart in GetSelectableHighLevelParts( fromGeometryCollection)) { if (selectionArea == null || (!selectionAreaMustContain && GeometryUtils.Intersects(selectionArea, highLevelPart)) || GeometryUtils.Contains(selectionArea, highLevelPart)) { if (result == null) { result = GeometryFactory.Clone(highLevelPart); } else { ((IGeometryCollection)result).AddGeometryCollection( (IGeometryCollection)highLevelPart); } } } return(result); }
private int ReportError([NotNull] IFeature pointFeature, [NotNull] IFeature referenceFeature, [NotNull] IPoint point, [NotNull] IPoint nearPoint, double distance, double minimumDistance, bool isWithinPolygon, GeometryComponent geometryComponent, [CanBeNull] IValidRelationConstraint validConstraint) { IssueCode issueCode; string description; IGeometry errorGeometry; if (isWithinPolygon) { description = "Point lies within polygon"; errorGeometry = GeometryFactory.Clone(point); issueCode = validConstraint == null ? Codes[Code.PointWithin] : Codes[Code.PointWithin_ConstraintNotFulfilled]; } else { if (geometryComponent == GeometryComponent.EntireGeometry) { description = string.Format( "Point is too close to reference feature: {0}", FormatLengthComparison(distance, "<", minimumDistance, _spatialReference)); } else { description = string.Format( "Point is too close to {0} of reference feature: {1}", GeometryComponentUtils.GetDisplayText(geometryComponent), FormatLengthComparison(distance, "<", minimumDistance, _spatialReference)); } bool reportAsConnectionLine = MinimumErrorLineLength >= 0 && distance >= MinimumErrorLineLength; errorGeometry = GetErrorGeometry(point, nearPoint, reportAsConnectionLine); issueCode = validConstraint == null ? Codes[Code.PointTooClose] : Codes[Code.PointTooClose_ConstraintNotFulfilled]; } return(ReportError(description, errorGeometry, issueCode, _shapeFieldName, pointFeature, referenceFeature)); }
private IGeometry GetGeometry(int partIndex) { IGeometry geometry; if (!_perPart) { geometry = GeometryFactory.Clone(_baseGeometry); } else if (_baseGeometry is ICurve) { var geometryCollection = _baseGeometry as IGeometryCollection; if (geometryCollection == null || geometryCollection.GeometryCount == 1) { geometry = GetErrorGeometry((ICurve)_baseGeometry); } else { var curve = (ICurve)geometryCollection.get_Geometry(partIndex); geometry = GetErrorGeometry(curve); } return(geometry); } else { IGeometryCollection geometryCollection; if (_baseGeometry.GeometryType == esriGeometryType.esriGeometryPolygon) { geometryCollection = QaGeometryUtils.CreatePolygon(_baseGeometry); } else if (_baseGeometry.GeometryType == esriGeometryType.esriGeometryPolyline) { geometryCollection = QaGeometryUtils.CreatePolyline(_baseGeometry); } else if (_baseGeometry.GeometryType == esriGeometryType.esriGeometryMultiPatch) { geometryCollection = new MultiPatchClass(); } else { throw new InvalidOperationException("unhandled geometry type " + _baseGeometry.GeometryType); } int segmentCount = _indexedSegments.GetPartSegmentCount(partIndex); var partSegments = new List <SegmentProxy>(segmentCount); for (int iSegment = 0; iSegment < segmentCount; iSegment++) { partSegments.Add(_indexedSegments.GetSegment(partIndex, iSegment)); } SegmentUtils.CreateGeometry(geometryCollection, partSegments); geometry = (IGeometry)geometryCollection; } return(geometry); }
private static void AddFeature([NotNull] IFeatureClass featureClass, [NotNull] IGeometry shape) { IFeature feature = featureClass.CreateFeature(); feature.Shape = GeometryFactory.Clone(shape); feature.Store(); }