Hello, I am seeking a way in Arcade expression for Attribute Rules to add multiple features (parkA layer) intersected with an inserted or updated polygon feature (bufferA) to a third layer (NationalPark layer).
I managed to prepare an expression to add only a single feature intersected with a buffer polygon - please see the expression below. But I have not been able to find out the way for adding multiple features.
My final goal is to set up a batch calculation of Attribute Rules to achieve that, i.e. to add, update or delete all the features of NationalPark layer that correlated with each of buffer feature in one go. To start with, I tried set up an immediate calculation by the code but it only does for a single feature. Is there any way of selecting multiple features by the buffer and add them to the third layer?
Thanks in advance for any ideas!
// This rule is set in a bufferA (polygon)
// Target field :
// Insert and Update
// Exclude from app evaluation
// Decide an edit mode ("INSERT", or "UPDATE")
var mode = $editcontext.editType
// get parkA feature (polygon)
var parkA = FeatureSetByName($datastore, "parkA", ["*"], false)
var parkA_intersect = Intersects(parkA, Geometry($feature))
var parkA_first = First(fsparkA_firstIntersect)
// return error if $feature doesn't intersect any parkA polygon
if (parkA_first == null)
return {"errorMessage": "Buffer must be intersected with parkA polygon."}
// create the result dict
var result = {
"attributes": {
}
}
// initialize the edit arrays for adds and updates
var adds = []
var updates = []
if(mode == "INSERT") {
var add = {
"geometry": Geometry(parkA_first),
"attributes": {
"Status_A": parkA_first.statusA
}
}
Push(adds, add)
}
if(mode == "UPDATE") {
var update = {
"geometry": Geometry(parkA_first),
"attributes": {
"Status_A": parkA_first.statusA
}
}
Push(updates, update)
}
// return
return {
"result": result,
"edit": [
{
"className": "NationalPark",
"adds": adds,
"updates": updates
}
]
}