I have created an attribute rule that that seeks to do a few things.
First, it checks to see if the geometry of the feature has changed from it's initial state.
If it has, then it compares two values, the legal acreage from a plat and the calculated acreage from the geometry. If there is a difference of 10% of the legal acreage, then it is supposed to flag it as an error for review. If not not, then it flags it as ok.
If the geometry of the original feature has not changed, however, then it simply returns the same value so that no changes are produced. My code:
var origGeometry = $originalFeature['Shape_Area'];
var newGeometry = $feature['Shape_Area'];
var QAQC_Eval = iif(abs($feature.ERROR_ACRES) > ($feature.StatedArea * 0.10), "Acreage mismatch. Deeded acres and calculated acres do not fall within OCGIS tolerance.","Acreage ok. Deeded acres and calculated acres fall within OCGIS tolerance.");
//If the absolute value of error acres is greater than 10% of the stated acres, then report mismatch. Otherwise, report that it is acceptable.
if(origGeometry != newGeometry){
return QAQC_Eval;
} else {
return $feature.QAQC_Status;
}
//This expression checks to see if the geometry of a feature has changed. If it has, then it compares the deeded acreage to the calculated acreage. If there is a discrepancy larger then 10%, it will flag that feature with an error in the attribute table. Otherwise it will flag it as "Ok".
The expression says it is valid, but when editing the layer to test the conditions, no changes are ever made. I can intentionally create a feature that should return an error but nothing happens. I can't even tell if the rule is running or not. Is there something in the above code that I have missed? Any pointers?
What happens if you compare the geometries of the two features?
if (Geometry($originalFeature) != Geometry($feature)) {
Ok! Made some progress! I updated the code to this based on your suggestion:
//This expression checks to see if the geometry of a feature has changed. If it has, then it compares the deeded acreage to the calculated acreage. If there is a discrepancy larger then 10%, it will flag that feature with an error in the attribute table. Otherwise it will flag it as "Ok".
var QAQC_Eval = iif(abs($feature.ERROR_ACRES) > ($feature.StatedArea * 0.10), "Acreage mismatch. Deeded acres and calculated acres do not fall within OCGIS tolerance.","Acreage ok. Deeded acres and calculated acres fall within OCGIS tolerance.");
//If the absolute value of error acres is greater than 10%, then report mismatch. Otherwise, report that it is acceptable.
if (Geometry($originalFeature) != Geometry($feature)){
return QAQC_Eval;
} else {
return $feature.QAQC_Status;
}
//This expression checks to see if the geometry of a feature has changed. If it has, then it compares the deeded acreage to the calculated acreage. If there is a discrepancy larger then 10%, it will flag that feature with an error in the attribute table. Otherwise it will flag it as "Ok".
That at least produces the attribute edits. But it seems to be ignoring the check to see if the geometry changes. Even if I only edit the attributes without touching the geometry, the rule always fires. I need to be able to prevent it from making changes unless there has been a geometry update. Any ideas?
With some more testing, this would check if the geometry changed, returning "Equal" if I just changed an attribute and "Not Equal" when I moved a vertex.
if (Area($originalFeature) != Area($feature)){
return 'Not equal';
} else {
return 'Equal';
}
when