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’s 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).
Is there something in that script that is not supported in older versions of Arcade?
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 right now, since our version of license manager doesn't support later versions of Pro.