Hello all!
I'm hoping to find some help troubleshooting this Arcade code used in a data expression for a dashboard. I'm far from an expert on Arcade so there may be something silly I'm misunderstanding.
The situation:
I have one large feature layer of all sewer lines in our network, that I am looking to break into 3 separate service areas in the dashboard, so I can track stats for each service area separately. (Unfortunately I do not have the ability to edit this UN sewer line layer, and there is not an appropriate attribute in existence to filter for these service areas without using a spatial query).
My code:
//Define the Enterprise portal connection
var myportal = Portal("https://samplesite.net/portal"
)
// Get the line layer: UN - Sewer Lines
var SewerLines = FeatureSetByPortalItem(
myportal,
'2c08361d8abe4308afba3d25c857a11c',
3,
['*'],
true
)
// Get the polygon layer: Separated Service Areas,
//filtered for Core Service Area feature only
var CoreSvcArea = Filter(
FeatureSetByPortalItem(
myportal,
'41c17045b4cf4359a8237db163fe82a6',
0,
['*'],
true),
"ServiceAreaName = 'RVSS Core Service Area'"
)
// Create an empty array to store intersecting features
var CoreLines = []
// Loop through each sewer line
for (var line in SewerLines) {
//Check if the given line intersects any core service area polygon,
//Filter() returns those intersection polygon features (if any) in
//a new array called intersxtion
var intersxtion = Filter(CoreSvcArea, Intersects(line, CoreSvcArea))
//If count of features in intersxtion is not 0, means an intersxtion
//with given line exists, and it is added to the end feature set
if (Count(intersxtion) > 0) {
// Add the intersecting line to the result array
Push(CoreLines, line)
}
}
// Return the intersecting sewer lines as a FeatureSet
return FeatureSet(CoreLines)
Issues:
When I test this code it returns the error "g.charAt is not a function". I believe I have isolated the issue as coming from the filter/intersection expression on line 34, but it could potentially be from the next few lines of code in the loop expression as that was a bit hard to isolate and test directly. Can anyone tell me what functionality inside this expression would be trying to call a string and not finding one? (this is my understanding of the error). Or if there is a better way to achieve the identification of overlapping features in this scenario I'm all ears!
Many thanks for any insight,
Christine