Help with Rule Attribution in Arcade

521
4
Jump to solution
06-22-2021 09:32 AM
Labels (3)
ChrisGAEG
Occasional Contributor

I'm trying to write an Arcade expression that does the following. If a line is within the boundary of another poly layer, the line takes the name attribution from the boundary, but only if the line is of a certain type. So far we have this which does the first part. 

var OLT = FeatureSetByName($datastore, "Proposed_OLT_LCP_Boundaries",["cab_id"], true)
var intersectLayer = Intersects(OLT, Geometry($feature))
if (Count(intersectLayer) > 0) {
    var layer = First(intersectLayer);
    return layer.cab_id;
} else {
    return null;
}

 

However I'm struggling with the part that only pulls in cab_id if intersectsLayer is of a certain type. Any input on this is greatly appreciated. 

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
DavidPike
MVP Frequent Contributor
var OLT = FeatureSetByName($datastore, "Proposed_OLT_LCP_Boundaries",["cab_id"], true)
var intersectLayer = Intersects(OLT, Geometry($feature))
if (Count(intersectLayer) > 0 && ($feature.cabletype == 'F1' || $feature.cabletype == 'F2')) {
    var layer = First(intersectLayer);
    return layer.cab_id;
} else {
    return null;
}

View solution in original post

0 Kudos
4 Replies
DavidPike
MVP Frequent Contributor

A certain type? can you elaborate?

0 Kudos
ChrisGAEG
Occasional Contributor

Yes we have a type field that has different labels. And we only want this function to apply to lines of a specific type in the layer. Here's what I'm trying to do (Although incorrect so far...)

 

var OLT = FeatureSetByName($datastore, "Proposed_OLT_LCP_Boundaries",["cab_id"], true)
var intersectLayer = Intersects(OLT, Geometry($feature))
if ((Count(intersectLayer) > 0) and ($feature.cabletype == 'F1' or 'F2')) {
    var layer = First(instersectLayer);
    return layer.cab_id;
} else {
    return null;
}
0 Kudos
DavidPike
MVP Frequent Contributor
var OLT = FeatureSetByName($datastore, "Proposed_OLT_LCP_Boundaries",["cab_id"], true)
var intersectLayer = Intersects(OLT, Geometry($feature))
if (Count(intersectLayer) > 0 && ($feature.cabletype == 'F1' || $feature.cabletype == 'F2')) {
    var layer = First(intersectLayer);
    return layer.cab_id;
} else {
    return null;
}
0 Kudos
ChrisGAEG
Occasional Contributor

That works! The syntax example will also help a lot for future rules, so thanks so much!