public static IList <IFeature> StoreResult( [NotNull] IFeature originalFeature, [NotNull] IGeometry remainingGeometry, [NotNull] ICollection <IGeometry> newGeometries, [CanBeNull] NotificationCollection warnings) { // Only store the result if all components can be stored: var notifications = new NotificationCollection(); foreach (IGeometry newGeometry in newGeometries) { if (!MakeGeometryStorable(newGeometry, notifications)) { NotificationUtils.Add(warnings, "Unable to store new result geometry for feature <oid> {0}: {1}", originalFeature.OID, notifications.Concatenate(", ")); return(null); } } if (!MakeGeometryStorable(remainingGeometry, notifications)) { NotificationUtils.Add(warnings, "Unable to store largest result geometry for feature <oid> {0}: {1}", originalFeature.OID, notifications.Concatenate(", ")); return(null); } // Presumably everything can be stored: var newFeatures = new List <IFeature>(); foreach (IGeometry newGeometry in newGeometries) { IFeature newFeature = GdbObjectUtils.DuplicateFeature(originalFeature, true); GdbObjectUtils.SetFeatureShape(newFeature, newGeometry); newFeature.Store(); newFeatures.Add(newFeature); } GdbObjectUtils.SetFeatureShape(originalFeature, remainingGeometry); originalFeature.Store(); return(newFeatures); }
public void GetConfigurations([CanBeNull] out T localConfiguration, [CanBeNull] out T centralConfiguration, bool suppressXmlSchemaWarning = false) { centralConfiguration = null; var issueNotifications = new NotificationCollection(); if (ConfigurationExists(CentralConfigDirectory, ConfigFileName)) { _centralConfiguration = GetConfiguration( CentralConfigDirectory, ConfigFileName, issueText => issueNotifications.Add(issueText)); if (issueNotifications.Count > 0 && !suppressXmlSchemaWarning) { // This could happen if the schema changes other than just adding new nodes: _msg.WarnFormat( "The central configuration file {0} in {1} could not be read completely ({2}). Please review its structure and ensure it conforms to the current schema.", ConfigFileName, CentralConfigDirectory, issueNotifications.Concatenate(". ")); } centralConfiguration = _centralConfiguration; } else if (_hardCodedDefaults != null) { centralConfiguration = _hardCodedDefaults; } localConfiguration = null; issueNotifications.Clear(); if (ConfigurationExists(LocalConfigDirectory, ConfigFileName)) { localConfiguration = GetConfiguration( LocalConfigDirectory, ConfigFileName, issueText => issueNotifications.Add(issueText)); if (issueNotifications.Count > 0 && !suppressXmlSchemaWarning) { // Could happen if the schema changes other than just adding new nodes: _msg.WarnFormat( "The local configuration file {0} in {1} could not be read completely ({2}). Please review and accept the current settings in the options dialog.", ConfigFileName, CentralConfigDirectory, issueNotifications.Concatenate(". ")); } } }
/// <summary> /// Removes the shorts segments of the specified featureVertexInfo unless they are protected /// by the specified featureVertexInfo's CrackPoints. The minimum of the featureVertexInfo must /// be set. /// </summary> /// <param name="fromPolycurve"></param> /// <param name="featureVertexInfo"></param> /// <param name="use2DLengthOnly"></param> /// <param name="inPerimeter"></param> /// <returns></returns> private static void RemoveShortSegments( [NotNull] IPolycurve fromPolycurve, [NotNull] FeatureVertexInfo featureVertexInfo, bool use2DLengthOnly, [CanBeNull] IGeometry inPerimeter) { Assert.ArgumentNotNull(fromPolycurve, nameof(fromPolycurve)); Assert.ArgumentNotNull(featureVertexInfo, nameof(featureVertexInfo)); Assert.ArgumentCondition(featureVertexInfo.ShortSegments != null, "featureVertexInfo's ShortSegments is null"); Assert.ArgumentCondition(featureVertexInfo.MinimumSegmentLength != null, "featureVertexInfo's MinimumSegmentLength is null"); var notifications = new NotificationCollection(); Assert.NotNull(featureVertexInfo.MinimumSegmentLength, "Minimum segment length not set."); var minimumSegmentLength = (double)featureVertexInfo.MinimumSegmentLength; IList <esriSegmentInfo> shortSegments = featureVertexInfo.ShortSegments; SegmentReplacementUtils.RemoveShortSegments(fromPolycurve, shortSegments, minimumSegmentLength, use2DLengthOnly, featureVertexInfo.CrackPointCollection, inPerimeter, notifications); if (notifications.Count > 0) { _msg.WarnFormat("Feature {0}: {1}", GdbObjectUtils.ToString(featureVertexInfo.Feature), notifications.Concatenate(" ")); } }
private void ProcessSelection([NotNull] MapView activeMapView, [CanBeNull] CancelableProgressor progressor = null) { Dictionary <MapMember, List <long> > selectionByLayer = activeMapView.Map.GetSelection(); NotificationCollection notifications = new NotificationCollection(); List <Feature> applicableSelection = GetApplicableSelectedFeatures(selectionByLayer, notifications).ToList(); int selectionCount = selectionByLayer.Sum(kvp => kvp.Value.Count); if (applicableSelection.Count > 0 && (AllowNotApplicableFeaturesInSelection || applicableSelection.Count == selectionCount)) { LogUsingCurrentSelection(); AfterSelection(applicableSelection, progressor); } else { if (selectionCount > 0) { _msg.InfoFormat(notifications.Concatenate(Environment.NewLine)); } LogPromptForSelection(); StartSelectionPhase(); } }
private bool ApplyReshapePath( [NotNull] IGeometry geometryToReshape, [NotNull] AdjustedCutSubcurve adjustCurve, NotificationCollection notifications, IDictionary <IGeometry, NotificationCollection> reshapedGeometries) { // if the connect line crosses the geometry's boundary only reshape to the first intersection // and subsequently try the remaining bits. Otherwise this could result in a flipped geometry (reshape to the wrong side) IPath remainderAtFrom, remainderAtTo; IPath cutConnectLineAtFrom = SplitConnectline(adjustCurve, geometryToReshape, true, out remainderAtFrom); IPath cutConnectLineAtTo = SplitConnectline(adjustCurve, geometryToReshape, false, out remainderAtTo); var mainSubcurve = new AdjustedCutSubcurve( adjustCurve.PathOnTarget, cutConnectLineAtFrom, cutConnectLineAtTo); IPath reshapePath = mainSubcurve.Path; bool reshaped = Reshape(geometryToReshape, reshapePath); reshaped |= remainderAtFrom != null && Reshape(geometryToReshape, remainderAtFrom); reshaped |= remainderAtTo != null && Reshape(geometryToReshape, remainderAtTo); if (reshaped) { // to avoid incorrect relational operator results in for the next path on target ((ISegmentCollection)geometryToReshape).SegmentsChanged(); } NotificationCollection reshapeNotifications = null; // TODO: get from out ReshapeInfo; // move adding notfications to caller? if (reshaped && !reshapedGeometries.ContainsKey(geometryToReshape)) { reshapedGeometries.Add(geometryToReshape, reshapeNotifications); } else { if (reshapeNotifications != null) { NotificationUtils.Add(notifications, reshapeNotifications.Concatenate(" ")); } } return(reshaped); }
public static AdvancedReshapeResponse Reshape( [NotNull] AdvancedReshapeRequest request) { var polyline = (IPolyline)ProtobufGeometryUtils.FromShapeMsg(request.ReshapePaths); List <IPath> reshapePaths = GeometryUtils.GetPaths(Assert.NotNull(polyline)).ToList(); GeometryReshaperBase reshaper = CreateReshaper(request, reshapePaths); bool useNonDefaultReshapeSide = request.UseNonDefaultReshapeSide; var notifications = new NotificationCollection(); IDictionary <IGeometry, NotificationCollection> reshapedGeometries = reshaper.Reshape(reshapePaths, useNonDefaultReshapeSide, notifications); Assert.NotNull(reshapedGeometries, "No reshaped geometries"); if (reshapedGeometries.Count == 0) { return(NoReshapeResponse(notifications)); } var response = new AdvancedReshapeResponse(); if (reshaper.ResultWithinOtherResultButNotInOriginal( reshapedGeometries.Keys, out IPolygon containedPolygon)) { response.OverlapPolygon = ProtobufGeometryUtils.ToShapeMsg(containedPolygon); } // Messages regarding some of the features that were not reshaped: if (notifications.Count > 0 && request.Features.Count > 1) { string overallMessage = notifications.Concatenate(". "); _msg.Info(overallMessage); response.WarningMessage = overallMessage; } // Junction-move, updating of adjacent lines is performed in Save: IList <IFeature> storedFeatures = reshaper.Save(reshapedGeometries); response.OpenJawReshapeHappened = reshaper.OpenJawReshapeOcurred; response.OpenJawIntersectionCount = reshaper.OpenJawIntersectionPointCount; PackReshapeResponseFeatures(response, storedFeatures, reshapedGeometries, reshaper.OpenJawReshapeOcurred, reshaper.NotificationIsWarning); return(response); }
public static IPolyline PrepareTargetLine( [NotNull] IList <IFeature> selectedFeatures, [NotNull] IGeometry targetGeometry, [CanBeNull] IEnvelope clipExtent, [NotNull] TargetBufferOptions bufferOptions, out string reasonForNullOrEmpty, [CanBeNull] ITrackCancel trackCancel) { IGeometry target = targetGeometry; // Ensure target's SR already here ISpatialReference sr = GetShapeSpatialReference(selectedFeatures[0]); if (GeometryUtils.EnsureSpatialReference(target, sr)) { _msg.Debug("Target geometry needed projection."); } reasonForNullOrEmpty = null; IPolyline targetLine = GetPreprocessedGeometryForExtent(target, clipExtent); if (targetLine.IsEmpty) { reasonForNullOrEmpty = "Reshape-along-target is outside main window extent."; return(targetLine); } if (trackCancel != null && !trackCancel.Continue()) { reasonForNullOrEmpty = "Cancelled"; return(null); } if (bufferOptions.BufferTarget) { var bufferNotifications = new NotificationCollection(); targetLine = BufferTargetLine(targetLine, bufferOptions, clipExtent, bufferNotifications, trackCancel); if (targetLine == null) { reasonForNullOrEmpty = $"Unable to buffer target geometry: {bufferNotifications.Concatenate(". ")}"; } } return(targetLine); }
protected string GetLocalOverridesMessage([NotNull] string optionsName) { string resultNotification = null; var notifications = new NotificationCollection(); if (HasLocalOverrides(notifications)) { resultNotification = string.Format("{0}: Default values were changed for: {1} {2}", optionsName, Environment.NewLine, notifications.Concatenate(Environment.NewLine + " ")); } return(resultNotification); }
private static AdvancedReshapeResponse NoReshapeResponse( NotificationCollection notifications) { string notificationMessage = notifications.Count > 0 ? $"{Environment.NewLine}{notifications.Concatenate(Environment.NewLine)}" : string.Empty; string noReshapeMessage = $"Unable to perform reshape{notificationMessage}"; _msg.WarnFormat(noReshapeMessage); return(new AdvancedReshapeResponse() { WarningMessage = noReshapeMessage }); }
public SubcurveFilter PrepareFilter( [NotNull] IList <IPolyline> preprocessedSourceLines, [NotNull] IList <IGeometry> targetGeometries, bool useMinimalTolerance, [NotNull] ReshapeCurveFilterOptions filterOptions) { _useMinimalTolerance = useMinimalTolerance; _filterOptions = filterOptions; ReleaseFilterObjects(); if (filterOptions.OnlyInVisibleExtent) { Assert.NotNull(_extentProvider); _currentlyVisibleExtents = new List <IEnvelope>(); // add the lens window extents _currentlyVisibleExtents.AddRange( _extentProvider.GetVisibleLensWindowExtents()); // plus the main map window _currentlyVisibleExtents.Add(_extentProvider.GetCurrentExtent()); } if (filterOptions.ExcludeOutsideTolerance) { // NOTE: Buffer lines / outlines -> otherwise we miss lines for individual reshapes // and clip on extent (pre-process) before buffering to improve performance var sourceOutline = (IPolyline)GeometryUtils.UnionGeometries(preprocessedSourceLines); const int logInfoPointCountThreshold = 10000; var bufferNotifications = new NotificationCollection(); if (AdjustUtils.TryBuffer(sourceOutline, filterOptions.ExcludeTolerance, logInfoPointCountThreshold, "Calculating reshape line tolerance buffer...", bufferNotifications, out _mustBeWithinSourceBuffer)) { ExclusionOutsideSourceBufferLine = GeometryFactory.CreatePolyline( Assert.NotNull(_mustBeWithinSourceBuffer)); } else { _msg.WarnFormat( "Unable to calculate reshape line tolerance buffer: {0}", bufferNotifications.Concatenate(". ")); } Marshal.ReleaseComObject(sourceOutline); } if (filterOptions.ExcludeResultingInOverlaps) { _targetUnionPoly = ReshapeUtils.CreateUnionPolygon( targetGeometries, _useMinimalTolerance); } return(this); }
private static string Concat([NotNull] NotificationCollection notifications) { return(notifications.Concatenate(_defaultSeparator, "- {0}")); }