Select to view content in your preferred language

Arcade Attribute Rule Puzzle

51
1
yesterday
Labels (1)
Smileyk_mdt
Emerging Contributor

I'm working on a data check that will flag in red (validation attribute rule) any median that DOES NOT have a divided highway. I used the code above and added an extra condition to exclude evaluation for Two Way Left Turn medians. I'm getting weird behavior. It ignores TWLT as expected, but it still flags things that have a divided highway. Here is my code and a pic. In the pic, the 2 lonely lines at the top are correctly flagged because I removed their divided highways. The other two longer roads (that cross each other) have a divided hwy but still get flagged. I'm stumped on this one. I confirmed that the lines do overlap. Same ROUTE_ID, begin and end. They do have Z values if that matters.

I did

 

// Only evaluate $features that have geometry and are active (TO_DATE is null)
if ((geometry($feature) != null) && $feature.TO_DATE == null && $feature.MEDIAN == "Two Way Left Turn Lane") {
  var routeID = $feature.ROUTE_ID
  var objectID = $feature.OBJECTID
  
  // Get 'Carto Feature' feature set
  var cartoFS = FeatureSetByName($datastore, 'Divided_Highway_Export')
  // Define the SQL query definition query to filter the feature set
  var sql = "ROUTE_ID = @routeID AND TO_DATE IS NULL"
  // Filter the feature set to only return active records where the Route ID is equal to the $feature being evaluated
  var cartoActive = Filter(cartoFS, sql)

  // For each of the features returned in the Filtered feature set  
  for (var c in cartoActive) {
    if (overlaps($feature, c)) { // If the $feature overlaps the feature from the feature set...
      // Return the error message
      return {"errorMessage": `Feature overlaps an activeCarto segment. Route ID: ${routeID}, Object ID: ${objectID}`
    }
  }
}
return true
}

 

check to make sure overlaps make since using an Arcade field calculation first.

median_rule_error.PNG

Tags (3)
0 Kudos
1 Reply
ZekeMI
by
Frequent Contributor

Doesn't a median by definition divide a highway?

0 Kudos