Hello ESRI people,
I am thinking if it is possible to cut a line at the intersection of an inserted line.
It seems like we can achieve this by a point of point feature class for cutting a line of line feature class. But I am just wondering if we can do by only using a single line feature class, i.e. Both the target line and the inserted line are same feature class.
Thanks in advance!
It should be possible. Something like this (completely untested!)
// Calculation Attribute Rule on LineFC
// Field: empty
// triggers: insert(, update)
// load the whole LineFC
var line_fs = FeatureSetByNAme($datastore, "LineFC", ["GlobalID"], true)
// get the intersecting lines
var intersect_lines = Intersects(line_fs, $feature)
// create and fill adds and deletes arrays
var adds = []
var deletes = []
for(var i_line in intersect_lines) {
// get intersection geometry
var i_geom = Intersection(i_line, $feature)
// there are multiple conditions where we don't want to cut the line:
// intersection isn't a point (overlapping lines or i_line == $feature)
// i_line is intersecting $feature on start or end point
if(i_geom.type != "Point" ||
Equals(i_geom, Geometry(i_line).paths[0][0] ||
Equals(i_geom, Geometry(i_line).paths[-1][-1] ) {
continue
}
// cut i_line with $feature, delete the original, add the cut parts
var cut_parts = Cut(i_line, $feature)
Push(deletes, {"globalID": i_line.GlobalID})
for(var p in cut_parts) {
Push(adds, {"geometry": cut_parts[p]})
}
}
// apply the edits
return {
"edit": [
{
"className": "LineFC",
"adds": adds,
"deletes": deletes
}
]
}
Hi Johannes,
I applied your Arcade expression for a line feature class but unfortunately got an error, saying "Arcade error: Unexpected null, Script line: 20".
Unfortunately I don't know how to workaround this. If you could tell me any solution to this, that would be much appreciated.
Include a null check in the conditions:
if(i_geom == null || i_geom.type != "Point" ||
Equals(i_geom, Geometry(i_line).paths[0][0] ||
Equals(i_geom, Geometry(i_line).paths[-1][-1] ) {
continue
}