ArcGIS Online Arcade (automation & for loop help)

54
0
10-05-2022 01:34 PM
Labels (2)
Natalia
New Contributor III

Hello!

I need some assistance in the way of automating an arcade expression based on values imputed. I have forms in Field Maps that are used to survey pedestrian features and give a rating based off of the measurements recorded to determine if the feature is compliant. I'm now trying to take it a step further, by trying to make an expression that returns what part of the pedestrian feature is non-compliant (if any), and how it should be fixed (reconstruct, repair, maintenance etc.). My initial thought is to use for loops, unfortunately I'm having a hard time understanding how to use them and what the formatting means. Would anybody be willing to help?

This is what I have so far,

 

var cs = 10
var gw = 10
var lw = 10
var pa = 10
var ras = 7
var rw = 9
var rs = 8
var le = 10
var clear = 10

function compDecrease(field, compfield){
    if (field != 10 && field == compfield){
        return field-1
    }
    else {
        return 10
    }
}
  
var compFields = [
    cs,
    gw,
    lw,
    pa,
    ras,
    rw,
    rs,
    le,
    clear
]

var outArray = [];

for (var f1 = 0; f1 < Count(compFields); f1++){
    for (var f2 = f1 + 1; f2 < Count(compFields); f2++){
        
        Push(outArray, compDecrease(compFields[f1], compFields[f2]))
    }
}

var out = min(outArray)

var test = when(
    cs < 10, 'The Cross Slope is Not Compliant', 
    rs < 10, 'The Running Slope is Not Compliant', 
    ras < 10, 'The Road Slope is Not Compliant', 
    rw < 10, 'The Route Width is Not Compliant', 
    pa < 10, 'The Passing Area is Not Compliant', 
    gw < 10, 'The Elongated Opening (i.e. Gap) Width is Not Compliant', 
    lw < 10, 'The Vertical Change in Level (i.e. Lip) is Not Compliant', 
    clear < 10, 'The Clear Space Next to the Protrusion is Not Compliant', 
    le < 10, 'The Lowest Edge of the Protrusion is Not Compliant', 
    'Feature is ADAAG Compliant'
)

var total = Min(out,cs,gw,lw,pa,ras,rw,rs,le,clear)

var words = dictionary(cs,'The Cross Slope is Not Compliant', rs,'The Running Slope is Not Compliant', ras,'The Road Slope is Not Compliant', rw,'The Route Width is Not Compliant', pa,'The Passing Area is Not Compliant', gw, 'The Elongated Opening (i.e. Gap) Width is Not Compliant', lw, 'The Vertical Change in Level (i.e. Lip) is Not Compliant', clear,'The Clear Space Next to the Protrusion is Not Compliant', le,'The Lowest Edge of the Protrusion is Not Compliant')

distinct(words)

 

(the for loop used was given to me from a previous expression). The When function returns only the first value given, how to I get it to return all values?

 

Thanks!

0 Kudos
0 Replies