I have a polyline feature class that corresponds to the centerline of a rectangular polygon feature class. I am trying to make an Attribute Rules set for validation that will compare specific attributes for the two corresponding features (Picture 1). In the example, I'm comparing the values of the length fields for the polyline and polygon that overlap. If the values for the two fields don't match, then I want an error/false.
The issue is that there are sometimes 2 sets of features that intersect and create false positives (Picture 2 & 3). To avoid this, I want to only evaluating the intersecting polygon/polyline relationship with the largest overlap. However, I am having some trouble with the sample code (See below). I've also considered buffering the polyline and comparing overlaps, or to find the centroids and only compare the closest feature.
I'm new to Arcade and still trying to figure things out. So any advice or examples of how I can modify the code would be greatly appreciated!
// variables for overlap comparison
var biggest_overlap = '';
var overlap_amount = 0;
// intersection
var linearrunway = (FeatureSetByName($datastore, "linear_runway"))
var intersect = Intersects(linearrunway,$feature)
// check if any features in the intersection
if (Count(intersect) > 0) {
// iterate over zones, calculate intersection amount and compare
for (var g in intersect) {
var xs = Intersection($feature, g)
// get area of overlap; subsitute length if linear features
var xs_overlap = LengthGeodetic(xs)
if (xs_overlap > overlap_amount) {
overlap_amount = xs_overlap
biggest_overlap = (Round(g.length, 2))
if (biggest_overlap != (Round($feature.length,2))){
return false;
}else{
return true;
}
}
}
}
You could look at using Contains(https://developers.arcgis.com/arcade/function-reference/geometry_functions/#contains) or Relate(https://developers.arcgis.com/arcade/function-reference/geometry_functions/#relate)
Update: I used the "Feature on Feature" Ready to Use rule with the DE-9IM relationship 1***0F*** and it works as needed! Thank you, Mike! Your suggestion to use Relate helped with the breakthrough.