Arcade: Iterate over line features and get endpoint

592
2
Jump to solution
11-02-2022 03:59 AM
StefanAngerer
Occasional Contributor

Hi everybody,

I am currently working on a problem related to arc arcade, arc pro. Basically I am trying to create an attribute rule that checks if a created feature intersects with any endpoint of a featureset of polylines. For this to work I created this code:

for(var line in lines){

var endPoint = Geometry(line).paths[-1][-1]

return count(intersects(endPoint, Geometry($feature))) > 0

}

This should return "False" if the created feature is not intersecting one of the line endpoints im trying to iterate over. However all I get is a "unexpected null" error at "var endPoint". Any Ideas how i could solve the problem and get the end points of all the line features im iterating over?

Thanks.

Stefan

1 Solution

Accepted Solutions
JohannesLindner
MVP Frequent Contributor
// get all intersecting lines
var lines = FeaturesetByName($datastore, "TestLines")
var i_lines = Intersects(lines $feature)
// loop thorugh those lines, return true if any end point intersects $feature
for(var line in i_lines) {
    var end_point = Geometry(line).paths[-1][-1]
    if(Intersects(end_point, $feature)) {
        return true
    }
}
// no end point intersects $feature
return false

Have a great day!
Johannes

View solution in original post

2 Replies
JohannesLindner
MVP Frequent Contributor
// get all intersecting lines
var lines = FeaturesetByName($datastore, "TestLines")
var i_lines = Intersects(lines $feature)
// loop thorugh those lines, return true if any end point intersects $feature
for(var line in i_lines) {
    var end_point = Geometry(line).paths[-1][-1]
    if(Intersects(end_point, $feature)) {
        return true
    }
}
// no end point intersects $feature
return false

Have a great day!
Johannes
StefanAngerer
Occasional Contributor

Your solution workes just perfect. Thank you so much for the help!

 

0 Kudos