The Proper() Arcade function is a handy way to format street names that are stored in all caps. But it doesn't deal with ordinals correctly; e.g., returns "16Th" rather than "16th". There are a few different ways to handle this in Python but I don't know how to do it with Arcade. Any ideas? Thanks!
Solved! Go to Solution.
Ah! I figured it out. When you copied my expression into the playground, you unwittingly, but correctly, added braces around the for loop. I failed to notice previously that every label was showing only the last word of the name; I was only paying attention to the Mac names. After adding the braces, many more street names magically popped into the map! Thanks!
For posterity, here's the corrected expression:
if (!IsEmpty($feature.STREET)) {
var words = split(upper($feature.STREET), " ")
var Mac = ["MACCUMBER", "MACKAY", "MACKENZIE", "MACMILLAN", "MACRAE"]
var dir = proper(DomainName($feature, 'DIR'))
var street = ""
var type = proper(DomainName($feature, 'TYPE'))
for (var i in words) {
var isMac = indexof(Mac, words[i]) > -1
if (left(words[i], 2) == "MC") {
street += upper(words[i][0]) + lower(words[i][1]) + upper(words[i][2]) + lower(right(words[i], count(words[i]) - 3)) + " ";
} else if (isMac) {
street += upper(words[i][0]) + lower(words[i][1]) + lower(words[i][2]) + upper(words[i][3]) + lower(right(words[i], count(words[i]) - 4)) + " ";
} else {
street += iif(IsNan(number(words[i][0])), proper(words[i]), lower(words[i])) + " ";
}
}
return concatenate([dir, street, type]," ");
} else {
return "";
}