On this page
The attribute merge calculation profile automatically calculates a new value for an attribute for the result features when several features are merged.
Profile variables
Variable name | Type | Description |
---|---|---|
$map | FeatureSetCollection | The list of layers in the web map. Can be used with the FeatureSetByName or FeatureSetById function to get a particular layer in the map. This can then be queried. |
$userId | Text | The unique user ID of the editor who is logged into the application. |
$userName | Text | The full name of the editor who is logged into the application. |
$userIdentity | Text | Provides a credential instance. This can be used when accessing external layers with the FeatureLayer function. The credentials represent the user’s logged in credentials. |
$session | Dictionary | A dictionary containing key value pairs. The dictionary contains all the session variables that have been configured in the app. When the application first launches, the user will be asked for values for the session variables. They can also (if configured) change session variables in the application. This provides programmatic access to the user’s choices / settings. |
$editingLayer | FeatureSet | The layer to which $feature belongs to. Can be queried to find other records. |
$feature | Feature | The feature that has been edited, added or worked on. |
$originalFeature | Feature | The original version of the feature before it was edited. This is not available for all situations where scripting is run. |
$value | Any | The value to test in the script. Certain rules, such as the restrict domain values rule, pass in a value for the current field value. |
$parentFeature | Feature | If there is a geographic contains relationship for the current feature being edited, this variable will contain the parent (or containing feature). |
$routeFeature | Feature | If the feature is a linear referencing feature, this variable will reference source route/line feature. |
$unchangedMap | FeatureSetCollection | The list of layers in the web map with data as it was originally before the current editing operation began executing. This is not available for all situations where scripting is run. |
$onlyCausedByCracking | Boolean | Boolean value to indicate that this feature has only been changed to add vertices to prevent slithers appearing. |
$mergedFeatures | FeatureSet | When running a merge operation, and the merge field rule is running, this will contain the original features being merged into one. |
$mergedFeature | Feature | When running a merge operation, this will contain the feature that has been merged together. |
Return types
Date | Number | String | null
(depending on the type of field)
Example
Set field by using an apportion of each merged feature based on its area:
/**Apportion each merged features contribution based on area
*
* This method weights the relative contribution of each feature to the final
* total based on its individual area normalised by the final merged area.
*/
var total = 0;
// Get the Full Area of the merged feature
var totalarea = Area(Geometry($mergedFeature));
// Now go through all the features that were merged
// And use their area of the total, to aportion their contribution
for (var f in $mergedFeatures) {
total += (Area(Geometry(f)) / totalarea) * f.IncomePotential;
}
return total;