Select to view content in your preferred language

Arcade for Measure Attribute Rule

450
0
07-07-2023 02:28 PM
AyanPalit
Esri Regular Contributor
2 0 450

Calculation rules are used to automatically populate attribute configurations on a feature. The practical use cases are discussed at the blogpost Maintain Measure Attributes. The following Arcade code may be used to configure an Attribute Rule that will  populate measure attributes in designated fields when new pipeline routes are created. The script will also update measure attributes when pipeline routes and/or their calibration is changed. 

 

/**
 * Assigned To: Polyline Feature Class that is M-aware
 * Type: Calculation
 * Name: StartM_EndM_Values
 * Description: Calculate  start Measure and end Measure values of Polyline-M feature
 * Trigger: Insert, Update
 * Misc: Exclude from Application Evaluation: True
 * Feature must have GLOBALID, EngFromM, EngToM, EngLength fields 
 */

var geom  = Geometry($feature);

if (!geom.hasM) {
    return;
}

// Get Start/End Points
var start_p = geom['paths'][0][0];
var end_p   = geom['paths'][-1][-1];

var start_m = Round(start_p.m);
var end_m   = Round(end_p.m);
var length  = Round(end_m - start_m);

return {
    "result": {
        "attributes": {
            "EngFromM": start_m,
            "EngToM": end_m,
            "EngLength": length
        }
    }
}

 

Attribute rule may be configured for the Primary LRS Network (Engineering) as well as the Derived LRS Network (Continuous) by updating the appropriate fields as in the feature class.

About the Author
Principal Consultant @Esri with over 20 years of GIS experience in the Energy and Utilities verticals.