Arcade expression to populate a field from one point layer to another that are on the same line

820
13
01-17-2024 09:33 AM
GIS_geek
New Contributor III

Hello,

My organization is moving from Geometric Network to Utility Network and that means we have to move all of our Attribute Assistant methods to Attribute Rules. I was hoping to get assistance on one of them.

We number fire hydrants based on the corresponding valve. Both points are on the same line and that is the only relationship between them.  All three features (hydrant, valve, and line) are in the same geodatabase.  The attached code I am running comes up with an error  mentioning "Invalid expression. Error on line 5. Wrong number of arguments." Hoping to get some help on this.

 

var valves = FeatureSetByName($datastore, "dwSystemValve");
var hydrants = FeatureSetByName($datastore, "dwHydrant");
var fireLines = FeatureSetByName($datastore, "dwLateralLine");

var intersectingValve = Intersects(valves, fireLines, true);
var intersectingHydrant = Intersects(hydrants, fireLines, true);

var commonFireLine = Filter(intersectingValve, intersectingHydrant);

var valveField = "NUM";
var hydrantField = "NUM";

var result = {};

for (var i in commonFireLine) {
    var valveValue = commonFireLine[i].attributes[valveField];
    var hydrantValue = commonFireLine[i].attributes[hydrantField];

    result[valveValue] = hydrantValue;
}

result

 

 

13 Replies
GIS_geek
New Contributor III

Hi Mike,

I updated the code as best as I could as shown below.  I am receiving the following error "Invalid expression. Error on line 8. Expected convertable to geometry."

var valves = FeatureSetByName($datastore, "dwSystemValve");
var fireLines = FeatureSetByName($datastore, "dwLateralLine");

var intersecting_lines = First(Intersects(fireLines, $feature));

// valves_to_update = [];
// for (var lat_line in intersecting_lines)
    var intersecting_valves = Intersects(valves, fireLines);
    for(var valve in intersecting_valves){
        push(valves_to_update, {'globalID':valve.globalid,
            'attributes': {
                'num': lat_line.num
            }})
    }

return {
    'edit': [{
        'className': 'valve',
        'updates': valves_to_update
    }]
}

 

0 Kudos
MikeMillerGIS
Esri Frequent Contributor

this line is trying to intersect two database classes. 

var intersecting_valves = Intersects(valves, fireLines);

You need to change that to the first line

var intersecting_valves = Intersects(valves, intersecting_lines );

 

why did you comment out this?

// valves_to_update = [];

 

needs to be 

var valves_to_update = [];

 

0 Kudos
GIS_geek
New Contributor III

Getting an error, "Invalid expression. Error on line 11. Close parenthesis expected."  Not sure why since I see the closed parenthesis in line 14.  I am a bit of a novice so not sure what to look for now.  I appreciate your time and effort on this @MikeMillerGIS .

0 Kudos
MikeMillerGIS
Esri Frequent Contributor
I did not format the dictionary correctly on line 11, will fix it tomorrow when back on my PC. Needs a { in front of global I'd and one more } on 14 after the other one.

0 Kudos