Arcade Attribute Rule and WKT Values

462
2
Jump to solution
03-30-2023 10:13 AM
Labels (2)
Mary
by
New Contributor

I am writing an attribute rule against Utility Network Datasets to update the Z value on point features based on the features lifecycle status to be fired on update and create. I have several data sets where the first code snippet is working as they have “regular” coordinate systems with wkid values. I have one dataset that is a custom coordinate system I have been attempting to extract the wkt value from the point feature to construct the new geometry. However, the second code snippet where I am doing this is causing Pro to crash when opening the attributes pane of this data set.

Any thoughts on the different behavior between WKT and WKID references? 

 

Side Note: if I disable the WKT attribute rule I do not see the crashing behavior.

WKID Z Value Update no issues:

  1. var geom_text = Text(Geometry($feature));
  2. var geom = Dictionary(geom_text);
  3. var xGeo = geom.x
  4. var yGeo = geom.y
  5. var spatialRef = geom.spatialReference
  6. var wkidVal = spatialRef.wkid
  7. var zGeoProposed = 1
  8. var zGeoOther = 0
  9. if($feature.LIFECYCLESTATUS != 1){
  10. var newGeo = Point({"x": xGeo, "y": yGeo, "z":zGeoOther, spatialReference: {wkid: wkidVal}})
  11. }
  12. else{
  13. var newGeo = Point({"x": xGeo, "y": yGeo, "z": zGeoProposed, spatialReference: {wkid: wkidVal}})
  14. }
  15. return newGeo;
  16.  

 

WKT Z Value Update Crashes Pro

 

  1. var geom_text = Text(Geometry($feature));
  2. var geom = Dictionary(geom_text);
  3. var xGeo = geom.x
  4. var yGeo = geom.y
  5. var spatialRef = geom.spatialReference
  6. var wktVal = spatialRef.wkt
  7. var wkidVal = null
  8.  
  9. var zGeoProposed = 1
  10. var zGeoOther = 0
  11.  
  12. if($feature.LIFECYCLESTATUS != 1){
  13. var newGeo = Point({"x": xGeo, "y": yGeo, "z":zGeoOther, spatialReference: {wkt: wktVal }})
  14. }
  15. else{
  16. var newGeo = Point({"x": xGeo, "y": yGeo, "z": zGeoProposed, spatialReference: {wkt: wktVal }})
  17. }
  18. return newGeo;
0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
MVP Frequent Contributor

To post formatted code:

JohannesLindner_0-1677736512957.pngJohannesLindner_1-1677736529803.png

 

 

You can massively simplify your rule. It should work with a regular coordinate system. I didn't test it with a custom system, but maybe it works there, too.

var geom = Geometry($feature)
var z = IIf($feature.LIFECYCLESTATUS == 1, 1, 0)
return Point({"x": geom.x, "y": geom.y, "z": z, "spatialReference": geom.spatialReference})

Have a great day!
Johannes

View solution in original post

0 Kudos
2 Replies
JohannesLindner
MVP Frequent Contributor

To post formatted code:

JohannesLindner_0-1677736512957.pngJohannesLindner_1-1677736529803.png

 

 

You can massively simplify your rule. It should work with a regular coordinate system. I didn't test it with a custom system, but maybe it works there, too.

var geom = Geometry($feature)
var z = IIf($feature.LIFECYCLESTATUS == 1, 1, 0)
return Point({"x": geom.x, "y": geom.y, "z": z, "spatialReference": geom.spatialReference})

Have a great day!
Johannes
0 Kudos
Mary
by
New Contributor

This works great, was not aware of IIF logic in arcade (still new to Arcade). Thanks again! 

0 Kudos