Hi, I'm using a modified version of the Local Government Solution for Addressing. I would like to utilize the nearest street Attribute Rule; however, we have times when we need to change the street name to another street - primarily on corners. It works well to pull a street name and fill in the attributes; however, when we change it if needed, or if it is selecting the wrong street, we need to be able to change it and it stick. I've removed the update portion of the AR and it still puts the name back to what it chose originally. Any help on this would be greatly appreciated.
Thanks!
var streetLayer = FeatureSetByName($datastore, "StreetCenterline");
var searchDistance = 150;
var streetIntersect = Intersects(streetLayer, Buffer($feature, searchDistance, "feet"));
var cnt = Count(streetIntersect);
var minDistance = Infinity;
var stname = null;
if (!(isempty($feature.FullStreetName))) {
stname = $feature.FullStreetName;
}
else if ((cnt > 0) && (isempty($feature.FullStreetName))) {
for (var street in streetIntersect) {
var dist = Distance(street, $feature, "feet");
if (dist < minDistance) {
stname = street.FullStreetName;
minDistance = dist
}
}
} else {
// pass no features found within search distance, name remains null
}
return stname;
Attribute rules do not perform any updates if you return with no value, so if you throw this at the top:
if (!IsEmpty($feature.FullStreetName)) {
return // Do not replace existing data
}
Then the rest of your code can run below. As an added bonus, you've guaranteed "FullStreetName" is an empty value which can simplify your logic a bit.
That seems to have worked, my testers will let me know for sure though 🙂 .
Thanks!
I copied your code and updated for street featureclass name and fields and seems to be working as expected. Auto assigns the closest street name, but, If I change it in the attribute table (I have domain dropdown on this field), it will update to whatever street I select and stick.
Only thing I really see different is that my street field names are different in my lookup street centerline layer and the target layer.
Line 15 should have the field name containing the streetname in your FeatureSetByName($datastore, "StreetCenterline") layer.
MAIN_ROAD = streetname field in target layer
Street_Lables_Zoom = streetname field in lookup layer
R_