<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Split line at intersection between line features in Attribute Rules Questions</title>
    <link>https://community.esri.com/t5/attribute-rules-questions/line-edit-by-calculation-rule/m-p/1107826#M259</link>
    <description>&lt;P&gt;It seems like you have all the ingredients. Just use the first point of your new line B as split feature.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var start_point = Geometry($feature).paths[0][0]
var fs_line_a = FeatureSetByName($datastore, "LineA", ["GlobalID"], true)

var result = {"geometry": Geometry($feature)}
var edit_line_a = {"className": "LineA", "adds": [], "deletes": []}

for(var s in Intersects(fs_line_a, start_point)) {
  var path = Geometry(s).paths[0]
  // we don't care about intersections with start or end points of LineA features
  if(Intersects(path[0], start_point) || Intersects(path[-1], start_point)) {
    continue
  }
  // construct cutter
  var clip_path = Clip(Geometry(s), Extent(Buffer(start_point, 0.1))).paths[0]
  var a = (Angle(clip_path[0], clip_path[-1]) + 90) * PI/180
  var m_geometry = Geometry($feature)
  var cutter = Polyline({
    "paths": [ [
      [start_point.x - 0.1 * cos(a), start_point.y - 0.1 * sin(a)],
      [start_point.x + 0.1 * cos(a), start_point.y + 0.1 * sin(a)]
    ] ],
    "spatialReference": Geometry($feature).spatialReference
  })
  // cut LineA feature
  var line_a_cuts = Cut(Geometry(s), cutter)
  // delete the intersected LineA feature
  Push(edit_line_a .deletes, {"globalID": s.GlobalID})
  // add both cut parts
  Push(edit_line_a .adds, {"geometry": line_a_cuts[0], "attributes": {"ID_A": NextSequenceValue("ID_A"}})
  Push(edit_line_a .adds, {"geometry": line_a_cuts[-1], "attributes": {"ID_A": NextSequenceValue("ID_A"}})
}
// return
return {"result": result, "edit": [edit_line_a ]}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 15 Oct 2021 08:28:04 GMT</pubDate>
    <dc:creator>JohannesLindner</dc:creator>
    <dc:date>2021-10-15T08:28:04Z</dc:date>
    <item>
      <title>Line edit by calculation rule</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/line-edit-by-calculation-rule/m-p/1107748#M258</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have not been able to make a proper code as I am new to Arcade. What I want to do is, split a line feature A by a start point of another line feature B. When I draw a line B from somewhere on the line A, the line A is split at the start point of line B.&amp;nbsp; Also, the feature A has field "ID_A". For example, value of 10, the attribute of the "ID_A" is going to be updated to 11 and 12 respectively when the feature A is split into two features.&lt;/P&gt;&lt;P&gt;Based on a code that I found on web, I managed to prepare a code to split a line by a point feature. This works well that also achieve the update of attribute with using NextSequenceValue. But I am struggling to achieve this using a line feature instead of a point.&lt;/P&gt;&lt;P&gt;Much appreciated if anyone give me hint.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 20:58:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/line-edit-by-calculation-rule/m-p/1107748#M258</guid>
      <dc:creator>Aнастасия88</dc:creator>
      <dc:date>2021-10-20T20:58:46Z</dc:date>
    </item>
    <item>
      <title>Re: Split line at intersection between line features</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/line-edit-by-calculation-rule/m-p/1107826#M259</link>
      <description>&lt;P&gt;It seems like you have all the ingredients. Just use the first point of your new line B as split feature.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var start_point = Geometry($feature).paths[0][0]
var fs_line_a = FeatureSetByName($datastore, "LineA", ["GlobalID"], true)

var result = {"geometry": Geometry($feature)}
var edit_line_a = {"className": "LineA", "adds": [], "deletes": []}

for(var s in Intersects(fs_line_a, start_point)) {
  var path = Geometry(s).paths[0]
  // we don't care about intersections with start or end points of LineA features
  if(Intersects(path[0], start_point) || Intersects(path[-1], start_point)) {
    continue
  }
  // construct cutter
  var clip_path = Clip(Geometry(s), Extent(Buffer(start_point, 0.1))).paths[0]
  var a = (Angle(clip_path[0], clip_path[-1]) + 90) * PI/180
  var m_geometry = Geometry($feature)
  var cutter = Polyline({
    "paths": [ [
      [start_point.x - 0.1 * cos(a), start_point.y - 0.1 * sin(a)],
      [start_point.x + 0.1 * cos(a), start_point.y + 0.1 * sin(a)]
    ] ],
    "spatialReference": Geometry($feature).spatialReference
  })
  // cut LineA feature
  var line_a_cuts = Cut(Geometry(s), cutter)
  // delete the intersected LineA feature
  Push(edit_line_a .deletes, {"globalID": s.GlobalID})
  // add both cut parts
  Push(edit_line_a .adds, {"geometry": line_a_cuts[0], "attributes": {"ID_A": NextSequenceValue("ID_A"}})
  Push(edit_line_a .adds, {"geometry": line_a_cuts[-1], "attributes": {"ID_A": NextSequenceValue("ID_A"}})
}
// return
return {"result": result, "edit": [edit_line_a ]}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Oct 2021 08:28:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/line-edit-by-calculation-rule/m-p/1107826#M259</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2021-10-15T08:28:04Z</dc:date>
    </item>
  </channel>
</rss>

