Attribute rule works in Pro 2.9.2, but not in Pro 2.6.8

441
3
03-31-2022 08:27 AM
Bud
by
Notable Contributor

I have a calculation attribute rule that works in Pro 2.9.2 (in a 2.9.2 FGDB). It updates the M-values of the polyline geometry:

function pythagoras(x1, y1, x2, y2) {
    return sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));
}

var geom = Dictionary(Text(Geometry($feature)));
var paths = geom['paths'];
var oldX = paths[0][0][0];
var oldY = paths[0][0][1];
var line_length = 0;

for (var path_idx in paths) {
    for (var point_idx in paths[path_idx]) {
        var newX = paths[path_idx][point_idx][0];
        var newY = paths[path_idx][point_idx][1];
        if (point_idx != 0) {
            line_length += pythagoras(oldX, oldY, newX, newY);
        }
        paths[path_idx][point_idx][-1] = line_length;
        oldX = newX;
        oldY = newY;
    }
}
return Polyline(geom);


However, if I create that attribute rule in Pro 2.6.8 (in a separate 2.6.8 FGDB), it doesn't work as expected. It runs without errors, and it even densifies true curves (which tells me that the code is running), but it doesn't update the M-values of the vertices properly (it sets the M-values to Nan).

Question:

Is there something in that script that is not supported in older versions of ArcGIS Pro?

I believe the Dictionary(), Text(), and Geometry() functions are working ok (since the script successfully returns a densified geometry). So I think it must be something else. Unfortunately, I can't upgrade Pro any further right now, since our version of license manager doesn't support later versions of Pro.

Thanks!

 

Tags (1)
0 Kudos
3 Replies
Bud
by
Notable Contributor

The following test script works in Pro 2.6.8. It adjusts the Y-coordinates, instead of the M-coordinates.

var geom = Dictionary(Text(Geometry($feature)));
var paths = geom['paths'];

for (var path_idx in paths) {
    for (var point_idx in paths[path_idx]) {
        paths[path_idx][point_idx][1] += 10
    }
}
return Polyline(geom);

Bud_3-1648850127841.png


However, if I change the script so that it updates the M-coordinates, instead of the Y-coordinates, then it doesn't work. I don't get any errors, but the M-values just get updated to Nan, which isn't what I want.

var geom = Dictionary(Text(Geometry($feature)));
var paths = geom['paths'];

for (var path_idx in paths) {
    for (var point_idx in paths[path_idx]) {
        paths[path_idx][point_idx][2] += 10
    }
}
return Polyline(geom);

Bud_2-1648850083229.png

That tells me that there is a bug in Pro 2.6.8. It isn't able to update the geometry's M-values correctly.

(And for what it's worth, I tried using the Geometry() function, instead of the Polyline() function, to return the value to the geometry. Similarly, that worked for the Y-coordinate, but not the M-coordinate).


I don't have that problem in Pro 2.9.2. The script can update M-values without issue:

Bud_1-1648850916692.png

So I think Esri must have fixed the problem in later versions.


Note: I came across an additional bug in 2.6.8 (a problem with true curves): Get paths of polyline with true curve (Pro 2.6.8)

0 Kudos
MikeMillerGIS
Esri Frequent Contributor

I would have to look it up, but I believe you could not modify the shape of a feature till 2.7 or 2.8 or since you were able to update Y, maybe it is something specific with M's.  

0 Kudos
Bud
by
Notable Contributor

Esri Canada support did some testing and found the issue was fixed in ArcGIS Pro version 2.8.0.
Case #03048202


Related:

Support for updating z-values (using the Move tool) was added in ArcGIS Pro 2.8.  If you haven’t updated yet, the steps described below should work to populate x,y,z attribute values when creating features and populate x,y attribute values when moving features.”

https://www.esri.com/arcgis-blog/products/arcgis-pro/data-management/get-to-the-point-automatically-...

0 Kudos