Unexpected Behaviour in Javascript API Cut Tool

2894
3
Jump to solution
11-28-2015 05:19 AM
Abu_BakarGadi
New Contributor II

Hi All,

Currently i'm using the latest version of Arcgis JS API Editor | API Reference | ArcGIS API for JavaScript  for our geometric network editing. Everything is going fine until we need to do some splitting on a wire (polyline).

The cut tool is working fine for splitting polylines as we needed, but the problem is with the points that are already being snapped to the target polyline to be splitted. Some points below will make the problem clearer to be understood :

1.) This picture shows the original condition of the connection. Two poles connected (snapped) with a wire.

Original Connection.PNG

2.) The next step is, We use the cutting tool provided inside esri/dijit/editing/Editor widget to cut the wire, anywhere in the middle. This will split the wire into two objects.

3.) Aand.. here's the problematic result, The left pole suddenly dragged to the splitting point :

Condition After Cut.PNG

After some checking, it seems like the left pole which previously snapped with the old wire still refer to the old wire's OBJECTID or something for the snapping, so this problem appears. From the second picture above, the right segment of the wire holds the same OBJECTID as the uncut wire (first picture), the left segment is the newly created object after cutting with new OBJECTID.

So, Our objective is to split the wire into two parts without affecting other objects that are snapped with the targeted wire to be cut. Actually we need something that behaves like the ArcMap splitting tool, but inside the Arcgis JS API..

Is there any workaround regarding this problem?

Thanks alot...

0 Kudos
1 Solution

Accepted Solutions
TyroneBiggums
Occasional Contributor III

Personally, I would take the extra time to design your own helper class for this. I have found a few Esri JS API objects to be finicky. Unless you look at the code, you don't know exactly what the cut is doing.

It looks like you know where you want to cut the wire. So, you also have the vertex where you want to cut. I would remove the original polyline and create two new ones. Or, if you need to maintain IDs, edit the geometry of the oringal polyline and create a new one to manufacture a 'cut' with your own code.

View solution in original post

3 Replies
Abu_BakarGadi
New Contributor II

I think I've found the cause.. The applyEdits operation after performing cut operation is by default, updating (shrinking) the original polyline geometry and adding the remainder polyline as new object. Not deleting the original polyline and then adding 2 new polylines.

So, of course any objects snapped to the original polyline which is now updated, will be dragged to the splitting point. I think I should handle the applyEdit event manually after cut operation is performed.

Any suggestions?

0 Kudos
TyroneBiggums
Occasional Contributor III

Personally, I would take the extra time to design your own helper class for this. I have found a few Esri JS API objects to be finicky. Unless you look at the code, you don't know exactly what the cut is doing.

It looks like you know where you want to cut the wire. So, you also have the vertex where you want to cut. I would remove the original polyline and create two new ones. Or, if you need to maintain IDs, edit the geometry of the oringal polyline and create a new one to manufacture a 'cut' with your own code.

View solution in original post

Abu_BakarGadi
New Contributor II

I think i will take the remove original and add two new polylines approach, since i don't need to maintain IDs. But I need to make sure that the two new polylines will be still snapped to the poles. Thanks for the direction!