0

Background to the problem: When I use the Editor Split tool on a line, the line gets split into 2, and a junction is placed between the two lines. When I use the Editor merge tool, the 2 lines are merged back into 1, but the junction stays (snap is removed, but the junction stays). The operation in the background for those ESRI editor tools, are probably to reshape the line, and create a new one, inserting a junction in the middle for splitting function, and for merging function extend the line, and delete the other line hence why it prompt you with which line to take pick. What is the problem? I need the junction that was created during the split to be gone after the merge is completed.

Solutions tried so far:

1. Using Active Tool or Active Command: I tried listening to the Editor events, to determine the current active tool/command, and if it is the merge tool, simply delete the junction.

    ((IEditEvents_Event)_Editor).OnStartEditing += editor_OnStartEditing;
    
    private void EditExtension_LimitEditDefault_OnChangeFeature(IObject obj)
    { // app.CurrentTool is the merge tool, do some logic
    }

However this fails, because the current tool is basically the editor, I tried getting the command, the CommandItem, nothing spits out the Merge tool, so I am unable to distinguish if its a merge, or split, or extend or any editing operation.

2. Compare Line Vertices with Junction Point: when any sort of editing of a feature happen (merging included). determine if the passed object is the junction feature class, check it against line features (if it intersects), if it does, check the vertices of the line feature that intersected the junction, and determine if it is equal to any of those junctions (hoping it would not be equal because it is not snapped), and of course that too did not work, since a vertex is created during the merge, and the junction I want gone sits on that vertex. So my last resolution is to determine if the Junction point is snapped to the line, if not, then I can delete it with ease

          private void EditExtension_LimitEditDefault_OnChangeFeature(IObject obj)
                    { 
                        while ((cName= lineClassNames.Next()) != null){
                       var fClass= ftrWspace.OpenFeatureClass(cName);
                        var spFilter = new SpatialFilterClass();
                        spFilter.Geometry = junctionShape;
                        spFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                        crsr=fClass.Search(spFilter, false);
                        IFeature crntFtr;
                        while ((crntFtr=crsr.NextFeature()) != null) {
                            var polyLine = (IPointCollection)crntFtr.ShapeCopy;
                            for (int i =0; i <= polyLine.PointCount - 1; i++){
                                var point = polyLine.Point[i];
                                var relOperator=(IRelationalOperator2)point;
                                if((relOperator.Equals(junctionShape)) || 
                               (point.X == junctionShape.X && point.Y == junctionShape.Y)) {
                              // CHECK HERE IF IT IS SNAPPED, if it is, then break, and move on

                                    pointIssnapped = true;
                                    break;
                                }
                                
                            }
                        
                        }
                    }
                    if (!pointIssnapped) {
                        // point is not snapped to anything, delete it
                        obj.Delete();

                    }
              }
2
  • So I just tested what you said and indeed if you use the split tool from the editor tool bar in ArcMap then immediately merge them back together using the merge tool on the editor tool bar, the resulting polyline has a vertex where you had done the split. So my questions are why would anyone split a line then immediately merge it back? Secondly are you concerns principally about this vertex being left in when using the editor tools? In your workflow could the split have been done by geoprocessing? So are you trying to trap this vertex when done from the editor UI?
    – Hornbydd
    Commented Nov 17, 2023 at 15:10
  • Answer to your 1st question is, users hardly ever do this, it is done to avoid an internal QA check that prohibits multiple lines having the same start and end point, so they split it to bypass that, then doing whatever needs to be done, then merging the line back. I suggested simply removing the junction feature that is left from the split manually , but was denied. 2nd question, I am concerned about the junction that is being left after merging. In my checks, I am unable to distinguish between the vertex point and the junction feature, since they both sit on the line at the same point.
    – ZZZ
    Commented Nov 17, 2023 at 19:31

1 Answer 1

0

I figured an easier way to delete the added junction.

1- I need to listen to the onChangeFeature Event, and determine if the object being changed is of the feature class in question (GeomNetwork_Junction).

2- Cast the junction into ISimpleJunctionFeature, and get it's EID.

3- I Query every Line feature class in my dataset that intersects the junction using ISpatialFilter

4- Either Cast the line into IEdgeFeature, and get the FromJunctionEID and ToJunctionEID.

if neither one of those EIDs match the junction EID, it means that this junction is not on either end of the line, and thus it is a standalone junction that was created by esri during the Split since it is sitting on the line, I can probably also Query the from Edge and To Edge on the junction, and since it is not snapped to the line, I will not get any edges, thus delete it on the BeforeStopOperation Events

       private void EditExtension_LimitEditDefault_OnChangeFeature(IObject obj)
                { 
                  while ((cName= lineClassNames.Next()) != null){
                    var fClass= ftrWspace.OpenFeatureClass(cName);
                    var spFilter = new SpatialFilterClass();
                    spFilter.Geometry = junctionShape;
                    spFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                    crsr=fClass.Search(spFilter, false);
                    IFeature crntFtr;
                    while ((crntFtr=crsr.NextFeature()) != null) {
                           var eid = edge.FromJunctionEID;
                           var toEid = edge.ToJunctionEID;
                           var junction = obj as ISimpleJunctionFeature;
                           if (junction != null && (junction.EID == eid || junction.EID == toEid))
                               {
                                 pointIssnapped = true; // this junction is needed 
                                 break;
                               }
                         
                    }
                    if (pointIssnapped)
                        break; // no need to loop over the rest of the features since this junction is part of another line geometry network and is needed
                }
                if (!pointIssnapped) {
                    // point is not snapped to anything store it on a global variable, and delete on the BeforeStopOperation Event as to not cause an exception here
                    FeatureToBeDeleted=obj;
                }
           }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.