Combine Multiple Attribute Intersects in one Rule

716
1
01-07-2021 08:11 AM
Status: Open
sjet1010
New Contributor III

Combining multiple intersect rules into one rule. I have three different point layers for our Stormwater Infrastructure. I have a single line layer that I am writing the rule in. Below is the code I wrote to try to update a field based on intersect and it does not work. 

//The attribute rule is setup to pull a field value from a 'upstream' layer. 
//This generates the geometry of the line layer 
Var g = Geometry($feature); 
//The variable generates the start point of the line 
Var toPointGeom = g.paths[0][0]; 
//The variable calls out the point layer and a specific field with no need to return 
Var fsPoint =FeatureSetByName($datastore, "GISProduction_10_7_1.SDE.D_Aprons",['FACILITYID']); 
Var fsPoint2 =FeatureSetByName($datastore, "GISProduction_10_7_1.SDE.D_Manholes", ['FACILITYID']); 
Var fsPoint3 =FeatureSetByName($datastore, "GISProduction_10_7_1.SDE.D_Control_Structure", ['FACILITYID'])
//Selects the first line endpoint that intersects the point 
Var toPoint = (Intersects(fsPoint , toPointGeom) ) 
Var toPoint2 = (Intersects(fsPoint2 ,toPointGeom) ) 
Var toPoint3 = (Intersects(fsPoint3 ,toPointGeom) ) 
//The script reads if the Intersect return value is null show '-1', otherwise return the toPoint fsPoint FacilityID 
If(toPoint > null){
return toPoint.FACILITYID}
else if (toPoint == null && toPoint2 > null){
return toPoint2.FACILITYID}
else if (toPoint == null && toPoint2 == null && toPoint3 > null){
return toPoint3.FACILITYID}

else{

return -1}

1 Comment
GISUSER6

Hello @sjet1010 ,

 

I also had been trying to combine all of these intersects into one attribute rule for our stormwater dataset but was unsuccessful in making one rule. Instead I had to make six separate rules for my intersecting features (storm manhole, inlet, and Intake / Outfall points). Three for the "FromPoint" rules and three for the "ToPoint" Rules. Below are examples for the attribute rules just for to and from manholes. 

From Manhole Attribute Rule:

var g = Geometry($feature);

var fromPointGeometry = g.paths[0][0];

var stMH =FeatureSetByName($datastore, "stManhole", ["FACILITYID"], false);

var fromPoint = First(Intersects(stMH, fromPointGeometry )  )

if (fromPoint != null){

return fromPoint.FACILITYID;

} else {

// do nothing
}

 

To Manhole Attribute Rule:

var g = Geometry($feature);

var toPointGeometry = g.paths[-1][-1];

var stMH =FeatureSetByName($datastore, "stManhole", ["FACILITYID"], false);

var toPoint = First(Intersects(stMH, toPointGeometry )  )

if (toPoint != null){

return toPoint.FACILITYID;

} else {

// do nothing
}

 

This was the order of the attribute rules I used: 

1. From Manhole

2. From Inlet

3. From Intake / Outfall

4. To Manhole

5. To Inlet

6. To Intake / Outfall

 

Hope this helps some!