Last active
September 1, 2026 16:16
-
-
Save JeffJacobson/e2f07fbd8f8940bdc52894d7e39e38a4 to your computer and use it in GitHub Desktop.
Locate SRMP using Arcade
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * With LRS layers that are separated by direction, hard-code the direction. | |
| * For the unified LRS layer, you will need to extract the last character | |
| * from the route ID, which includes an "i" or "d" suffix | |
| */ | |
| var direction = "i"; | |
| /** | |
| * Gets the M value of where the user clicked. | |
| */ | |
| function getM() { | |
| if (TypeOf($userInput) == "Point") { | |
| var result = PointToCoordinate($feature, $userInput); | |
| return result.coordinate.m; | |
| } | |
| return null; | |
| } | |
| // Get routeID and direction. | |
| function getSrmpInfo() { | |
| var m = getM(); | |
| Console(`M = ${m}`) | |
| var routeId = $feature.RouteID; | |
| /* Milepost fields | |
| "OBJECTID", | |
| "RouteID", | |
| "ARM", | |
| "SRMP", | |
| "Direction", | |
| "Easting", | |
| "Northing", | |
| "Longitude", | |
| "Latitude", | |
| "Azimuth", | |
| "StateRouteNumber", | |
| "RelRouteType", | |
| "RelRouteQual", | |
| "AheadBackInd", | |
| "LRS_Date", | |
| */ | |
| /** Mileposts layer ArcGIS Online item ID */ | |
| var milepostsItemId = "cb9e130af9374f71a164a9a2d555af96"; | |
| var milepostItemLayerId = 0; | |
| var milepostsPortal = Portal("https://wsdot.maps.arcgis.com"); | |
| // Round the measure to 2 decimal places. | |
| var arm = Text(Round(m, 2), "#.00"); | |
| var startTime = Timestamp(); | |
| // Query the mileposts features for features matching the route that | |
| // was clicked on and measures nearby the measure of the user's click. | |
| var f = First( | |
| Filter( | |
| FeatureSetByPortalItem( | |
| milepostsPortal, | |
| milepostsItemId, | |
| milepostItemLayerId, | |
| ["RouteID", "Direction", "SRMP", "AheadBackInd", "ARM"], | |
| false | |
| ), | |
| `RouteID = '${routeId}' AND ARM = ${arm} AND Direction IN ('${direction}', 'b')` | |
| ) | |
| ); | |
| var outputText = "Could not find SRMP"; | |
| if (f != null) { | |
| // Specify the format used when numbers are converted to strings. | |
| var numberFormat = "#.##"; | |
| // Convert the SRMP to text, and append "B" if it is back mileage. | |
| var SRMP = Text(f.SRMP, numberFormat); | |
| if (Upper(f.AheadBackInd) == "B") { | |
| SRMP = `${SRMP}${f.AheadBackInd}`; | |
| } | |
| outputText = SRMP | |
| } | |
| // Return output text. | |
| outputText | |
| } | |
| getSrmpInfo(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment