I am creating a map showing different ratings for a feature. When data was collected rating was as below (an example).
00 : No defects
15 : 5 Minor defects
1A : More than 10 but less than 15 Minor defect
2A : More than 10 but less than 15 major defects
1B : more than 15 but less than 20 major defects
3C More than 20 but less than 25 significant defects
A represents values from 11-15
B represents values from 16-20
C represents values from 21-25
how do I create arcade expression to reflect alphanumeric as a numeric value to indicate the conditions where 3C>2A>1B>1A>15>00
thanks in advance
Hi Khem Aryal ,
Another way would be to use a value renderer based on the severity and frequency of the events. See some sample code below (this will use some sample rating and try to create a numeric value from it based on a weight for severity multiplied by the frequency).
Function Score(val) {
val = Upper(val);
var dct = {"0": 0, "1": 1, "2": 2, "3": 3, "4": 4, "5": 5,
"6": 6, "7": 7, "8": 8, "9": 9, "A": 10, "B": 15,
"C": 20, "D": 25, "E": 30, "F": 35, "G": 40, "H": 45,
"I": 50, "J": 55, "K": 60, "L": 65, "M": 70, "N": 75,
"O": 80, "P": 85, "Q": 90, "R": 95, "S": 100, "T": 105,
"U": 110, "V": 115, "W": 120, "X": 125, "Y": 130, "Z": 135};
if (HasKey(dct, val)) {
return dct[val];
} else {
return -1;
}
}
Function Severity(val) {
// should probably use different weights for severity 1 to 5
// var dct = {"0": 0, "1": 1, "2": 2, "3": 3, "4": 4, "5": 5};
var dct = {"0": 0, "1": 5, "2": 10, "3": 15, "4": 20, "5": 25};
if (HasKey(dct, val)) {
return dct[val];
} else {
return -1;
}
}
Function CalculateScore(val) {
if (Count(val) == 4) {
var sev1 = Severity(Left(val, 1));
Console("sev1: " + sev1);
var sco1 = Score(Mid(val, 1, 1));
Console("sco1: " + sco1);
var sev2 = Severity(Mid(val, 2, 1));
Console("sev2: " + sev2);
var sco2 = Score(Mid(val, 3, 1));
Console("sco2: " + sco2);
return sev1 * sco1 + sev2 * sco2;
} else {
return -1;
}
}
var rating = "5J3B";
Console("5J3B: " + CalculateScore(rating) + TextFormatting.NewLine); // 320 = 5 * 55 + 3 * 15
var rating = "3Z2Z";
Console("3Z2Z: " + CalculateScore(rating) + TextFormatting.NewLine); // 675 = 3 * 135 + 2 * 135
var rating = "5P4Z";
Console("5P4Z: " + CalculateScore(rating) + TextFormatting.NewLine); // 965 = 5 * 85 + 4 * 135
//return CalculateScore(rating);
return "OK";
This will write to the console:
sev1: 25
sco1: 55
sev2: 15
sco2: 15
5J3B: 1600
sev1: 15
sco1: 135
sev2: 10
sco2: 135
3Z2Z: 3375
sev1: 25
sco1: 85
sev2: 20
sco2: 135
5P4Z: 4825
It all depends a lot on how you compare a severity 1 to 2 to 3 to 4 to 5... Also, in my example J is translated to 55, but maybe the coding does not include the character "I"?
Having access to this type of data with the number of incidents per pipe, it would be nice to do some predictive analysis and include material, diameter, pressure, and other additional data.