Hi, I want to implement immediate attribute rule on $editContext.editType for "UPDATE" to generate a new parcel id on splitting of polygons and merging of polygons but not able to find split & merge event in ArcGIS Aracade Expression. I found that Cut(polylineOrPolygon, cutter) is available for ArcCade Expression. Please if anyone have any idea about ... please share.
The Cut() function is for cutting geometries, not for detecting cuts.
$editcontext.editType only returns "INSERT", "UPDATE" or "DELETE". There is no way to trigger the rule only on a merge or cut operation.
A possible workaround could be to detect changes in the geometry:
// Attribute rule to calculate parcel id
// triggers: insert, update
var geometry_changed = $editcontext.editType == "UPDATE" && !Equals(Geometry($feature), Geometry($originalfeature))
if($editcontext.editType == "INSERT" || geometry_changed) {
var new_id = ...
return new_id
}
// If we land here, the feature got updated, but the geometry didn't change
return $feature.ParcelID
But this will calculate a new ID everytime you edit the geometry. So it will only work if cutting and merging are the only geometry edits you do.
Hi
Thanks for the reply.
I am planning to generate new id on the basis of split (UPDATE TRIGGER) assigning new id using the parent id eg: Polygon ID : 0070 -- Splitted in to two parts so splitted polygon id will be -- 1) 0070_01 and 2) 0070_02.
Same for merging the two polygons 1) 0070_01 2) 0070_02 and assign new id 0071( merged polygon).
I want to find the Split or Merge operation in Arcade expression.
Kindly share some idea to differentiate in Split & Merge operation at Arcade ( already tried Geometry equal & object id equal)
This is a way you could handle a split.
// Attribute Rule
// field: ParcelID
// triggers: Insert
// Exclude from Application Evaluation
// An Insert can be a "normal" insert or a Split operation
var id = $feature.ParcelID
var gid = $feature.GlobalID
// no ParcelID -> normal insert, create and return a new ParcelID
if(id == null) {
var new_id = NextSequenceValue("SequenceParcelID")
return new_id
}
var other_parcels = Filter($featureset, "ParcelID = @ID AND GlobalID <> @gid")
// no other parcels with the same ParcelID -> normal Insert.
if(Count(other_parcels) == 0) {
return id
}
// else, it's a Split operation
// create and fill an array of updates to the other split parts
var updates = []
var i = 2 // this $feature gets id 1
for(var op in other_parcels) {
var new_id = op.ParcelID + "_" + Text(i++, "00")
Push(updates, {globalID: op.GlobalID, attributes: {ParcelID: new_id}})
}
return {
result: $feature.ParcelID + "_01", // the new ParcelID of this feature
edit: [{className: "TestPolygons", updates: updates}] // apply the edits to the other split parts !!! CHANGE THE CLASSNAME !!!
}
I have looked for a way to detect merges, but I haven't fond one, yet.
You could just add this Attribute Rule:
// Attribute Rule
// field: ParcelID
// triggers: Update
var id = $feature.ParcelID
if(id == null) {
var new_id = NextSequenceValue("SequenceParcelID")
return new_id
}
return id
And then delete the ParcelID in the Merge dialog:
Thanks. I will check and update you