1

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.

4
  • Just to be crystal clear when you say "I create that attribute rule in Pro 2.6.2 (FGDB)" are you saying you are using a geodatabase created in 2.6.2 but you are using 2.9 to create the rule or are you creating a rule in a geodatabase using ArcPro 2.6.2? I suspect no one will answer this question because who keeps multiple versions unless they are using some sort of virtual machine? I know I don't! Sorry!
    – Hornbydd
    Apr 1 at 15:09
  • @Hornbydd Good question. I have Pro 2.9.2 on a dev computer, where I dream of using the latest software (includes a 2.9.2 FGDB). And I have Pro 2.6.8 on a separate prod computer, with a separate 2.6.8 FGDB, using a version of license manager that can’t easily be updated (until IT does an upgrade project). I perform separate tests, with separate data, in each environment.
    – User1974
    Apr 1 at 15:20
  • @Hornbydd : If there’s anyone out there who has Pro 2.6, or remembers the limitations in Arcade at that version, then they might be able to help me. But I agree, most people are lucky enough to have newer versions.
    – User1974
    Apr 1 at 15:27
  • 2
    This should help: developers.arcgis.com/arcade/guide/version-matrix - you can click into each version and see what was added.
    – KHibma
    Apr 1 at 16:48

1 Answer 1

1

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);

enter image description here


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);

enter image description here

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 Y-coordinates, but not M-coordinates).


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

enter image description here

So I think the problem only exists in older versions like 2.6.8.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.