We are using ArcGIS Pro 3.3.5, and trying to create a calculation attribute rule.
This is what the rule is designed to do:
Traverse association from a non-spatial UN participating table, once the associated features(boundary (polygon)) are collected, they are clubbed together using the UNION arcade function, and later converted to Polyline, and finally updating or inserting the converted Polyline into a Line type FeatureClass named GeoLocatorFC.
I have added comments to easily understand what this arcade does!!
//This is a non-spatial telecom table that is used for traversing associations with UNM FeatureClasses
var getTelecomId = $feature.locationid;
//This is the UNM StructureBoundary Feature class
var BoundaryTable = FeatureSetByName($datastore, "StructureBoundary", ['*']);
//This is the featureclass we would be finally making updates/inserts
var geolocatorFC = FeatureSetByName($datastore, "GeoLocatorFC", ['*']);
//First we find associations
var allcontent = FeatureSetByAssociation($feature, "container");
//Filter rows for StructureBoundary entries
var devicerows = Filter(allcontent, "className = 'StructureBoundary'");
//Define empty array for collecting geometry
var arrayOfGeometry = [];
for (var row in devicerows) {
var globalId = row.globalid;
var getGeometryOfBoundary = First(Filter(BoundaryTable, "GLOBALID=@globalId"));
Push(arrayOfGeometry, Geometry(getGeometryOfBoundary));
}
//This part is defined to Union collected Polygons and Convert it to a line
var unionOfGeometries = Union(arrayOfGeometry);
var geom = Geometry(unionOfGeometries);
var rings = geom.rings;
var spatialRef = geom.spatialReference;
var polyline = Polyline({
'paths': rings,
'spatialReference': spatialRef
});
// After the line is collected the geometry is checked for either insert if its not present or update if already exists.
if (unionOfGeometries != null) {
var recordFromGeolocator = Filter(geolocatorFC, "LOCATIONID=@getTelecomId");
if (Count(recordFromGeolocator) > 0) {
return {
"edit": [{
"className": "GeoLocatorFC",
"updates": [{
"geometry": polyline,
"globalId": First(recordFromGeolocator).GLOBALID
}]
}]
};
} else {
return {
"edit": [{
"className": "GeoLocatorFC",
"adds": [{
"geometry": polyline,
"attributes": {
"LOCATIONID": getTelecomId
}
}]
}]
};
}
}
The rule triggers an error with unexpected null at line 21 where it tries to grab rings of the polygons. Not sure how to involve this conversion part.
The above rule works if we are not considering the polygon to polyline conversion and push the updates into a Polygon FC with union of collected geometry only.
Any help on this would be highly appreciated!!