Select to view content in your preferred language

Arcade Calculation Rule with if statement to determine intersecting feature set to use

670
1
02-06-2024 03:11 PM
AdamBarrs
New Contributor

Hello I am attempting to create a Calculation Rule that will use the endpoint of a given line feature, iterate through a list of possible feature layers with intersections and then based on the results of the if statement obtain a value from the intersecting feature and update the line feature with this attribute. It doesnt error out but it also doesnt update the value as needed.

 

 

var intersecting_field = "stationID";
var LineEndPoint = Geometry($feature).paths[-1][-1];
var FPFilter = Filter(FeatureSetByName($datastore,'SP'),'Subtype = 16');
var HHFilter = Filter(FeatureSetByName($datastore,'PA'),"Subtype = 5");
var PFilter = Filter(FeatureSetByName($datastore,'SS'),'Subtype <> 6 OR Subtype IS NULL');
var SPFilter = Filter(FeatureSetByName($datastore,'SP'),'Subtype IN (16,0,1,20)');
var PAFilter = Filter(FeatureSetByName($datastore,'PA'),'Subtype IN (0,2,3,4,6)');
intersectionLayer = ''
if (Intersects(LineEndPoint, FPFilter)==true){
    intersectionLayer = FPFilter;}
if (Intersects(LineEndPoint, HHFilter)==true){
    intersectionLayer = HHFilter;}
if (Intersects(LineEndPoint, PFilter)==true){
    intersectionLayer = PFilter;}
if (Intersects(LineEndPoint, SPFilter)==true){
    intersectionLayer = SPFilter;}
if (Intersects(LineEndPoint, PAFilter)==true){
    intersectionLayer = PAFilter;}
return intersectionLayer
if (IsEmpty(intersected_feature) || intersected_feature == null)
{ 
    return;
}
// If the intersected feature is null, return the original value
if (IsEmpty(intersected_feature.stationID))
{
    return;
}
return {
    //result is a dictionary
    "result": {
        "attributes": {
            "stationID": intersected_feature[intersecting_field]
        }
    }
};

 

 

 

0 Kudos
1 Reply
Amir-Sarrafzadeh-Arasi
Frequent Contributor

Dear Adam,

If you can share a portion of your gdb with feature classes which you used in this script it will be easier to debug the code.

 

best regards

Amir Sarrafzadeh Arasi
0 Kudos