Have additional functions for attribute rules such as...

282
0
01-04-2024 06:40 AM
Status: Open
Labels (1)
RPGIS
by
Occasional Contributor III

Hi,

I would really like for additional attribute rule functionality to be able to retrieve matching fields, records etc. and to also have editing capabilities. Thus far most of those functionalities have to be scripted in but I was wondering if it could be set as a function rather than something that has to be scripted.

 

// Get matching field names found in both lists
function GetMatchingFields( FieldListA, FieldListB ){
    var MatchingFields = [ ]
    // Loop through the list of field names in list A
    for ( var i in FieldListA ){
        var fieldname = FieldListA[i]
        /* If list of field names in list B includes the field name in list A
           then append the field name to the matching list of field names */
        if ( Includes( FieldListB , fieldname ) ){ Push( MatchingFields, fieldname ) }
        }
    return MatchingFields
    }

 

 

 

// Get field names from input features
function GetFieldNames( InputFeature , OmitFields ){
    var FieldNames = [ ]
    var FeatureInfo = Schema(InputFeature).fields
    for ( var i in FeatureInfo ){
        // Get the field name of the input feature
        var fieldname = FeatureInfo[ i ].name
        if ( Boolean( OmitFields ) ) {
            if ( Includes( OmitFields , fieldname ) == False ) { Push( FieldNames , fieldname ) }
            }
        else { Push( FieldNames , fieldname ) }
    return FieldNames
    }

 

 

 

// Get feature attributes based on field list
function GetFeatureAttributes( FieldList ){
    Expects( $feature , '*' )
    var Attributes = Dictionary( $feature ).attributes
    var SpecificAttributes = { }
    if ( IsEmpty( FieldList ) == False ){
        for ( var f in FieldList ){
            SpecificAttributes[ FieldList[ f ] ] = Attributes[ FieldList[ f ] ]
            }
        }
    else { SpecificAttributes = Attributes }
    return SpecificAttributes
    }