// 👆 Added a ".js" to this filename just to get the syntax highlighting on GitHub Gists. // You should remove the ".js" part when using it. /** * This Arcade script is used to generate labels for the milepost layer. */ /** * Gets the SRMP and Ahead/Back indicator attributes and * concatenates them into a single string. * @returns A string containing a number with up to three decimal places * and an optional "B" indicator. */ function getMilepost() { var output = Text($feature.SRMP, "#.###"); if ($feature.AheadBackInd == "B") { output += "B" } return output; } /** * Gets the route prefix "I-", "US ", or "SR " corresponding to the * route associated with the current milepost feature. * @returns "I-", "US ", or "SR " */ function getShield() { var isRoutes = [5, 82, 90, 182, 205, 405, 705]; var usRoutes = [2, 12, 97, 101, 195, 197, 395, 730]; var shield = "SR "; var srNum = Number($feature.StateRouteNumber); if (Includes(isRoutes, srNum)) { shield = "I-"; } else if (Includes(usRoutes, srNum)) { shield = "US "; } return shield; } /** * Gets the route label for the current milepost feature: * an integer with a suffix returned by {@link getShield()}. * @returns The route label for the current milepost feature. */ function getRouteLabel() { var output = $feature.RouteID; if ($feature.StateRouteNumber == $feature.RouteID) { output = `${getShield()}${Number($feature.StateRouteNumber)}` } return output; } // Concatenate the route label and milepost into a single string, along with // corresponding labels, separated by a newline. Concatenate([`Route: ${getRouteLabel()} (${$feature.Direction})`, `Milepost: ${getMilepost()}`], "\n");