Hi, all,
I am attempting to write an arcade expression that identifies the closest intersected feature of a point layer to three other layers within the same map and returns certain values from the feature that is intersected. Also, I only want to return the closest feature to the point layer that matches the individual point layer record based on a field value between the three layers in question.
I currently have an arcade expression that works majority of the time because the features that are returned on the intersection are the closest intersection between the 3 opposing layers. I am running into issues when the closest feature intersected is not a match to the point layers record based on the field value (MXASSETNUM) not being equal.
Please view my current expression below:
var LL_AREA = FeatureSetByName($map,"SASD Lower Laterals");
var buf = Buffer($feature, 500, "feet");
var fs_filtered = Intersects(LL_AREA, buf);
var min_dist = Infinity;
var closest_feat = null;
for (var f in fs_filtered){
var dist = Distance($feature, f);
if (dist < min_dist) {
closest_feat = f;
min_dist = dist;
}
}
if (closest_feat.MXASSETNUM == $feature.MXASSETNUM){
return "Lower Lateral: " + closest_feat.MXASSETNUM + " is " + closest_feat.STATUS
}
var GM_AREA = FeatureSetByName($map,"SASD Gravity Mains");
var buf2 = Buffer($feature, 500, "feet");
var fs_filtered2 = Intersects(GM_AREA, buf2);
var min_dist2 = Infinity;
var closest_feat2 = null;
for (var f2 in fs_filtered2){
var dist2 = Distance($feature, f2);
if (dist2 < min_dist2) {
closest_feat2 = f2;
min_dist2 = dist2;
}
}
if (closest_feat2.MXASSETNUM == $feature.MXASSETNUM){
return "Gravity Main: " + closest_feat2.MXASSETNUM + " is " + closest_feat2.STATUS
}
var Node_AREA = FeatureSetByName($map,"SASD Manholes");
var buf3 = Buffer($feature, 500, "feet");
var fs_filtered3 = Intersects(Node_AREA, buf3);
var min_dist3 = Infinity;
var closest_feat3 = null;
for (var f3 in fs_filtered3){
var dist3 = Distance($feature, f3);
if (dist3 < min_dist3) {
closest_feat3 = f3;
min_dist3 = dist3;
}
}
var NDTYPE = DomainName(closest_feat3, 'NODETYP')
if (closest_feat3.MXASSETNUM == $feature.MXASSETNUM){
return NDTYPE + " " + closest_feat3.MXASSETNUM + " is " + closest_feat3.STATUS
}