Grab the LRS location with Arcade?

682
4
Jump to solution
01-16-2023 07:44 AM
TrevisMartin
New Contributor III

I have a setup where we're going to collect point features along a route feature with m-values. 

I'm able to have created point feature grab the closest route with an appropriately modified version of the Arcade field calculation in the blog article here.  Number 7 - Storing information of a nearby feature.

https://www.esri.com/arcgis-blog/products/field-maps/field-mobility/common-calculated-expressions-fo...

I'd also like to get the M value of the point if it were projected onto the route line.  Field Maps recently put in the ability to get that position. 

https://www.esri.com/arcgis-blog/products/field-maps/field-mobility/linear-referencing-comes-to-arcg...

Is there a way to call and store that information in the collected feature using an arcade expression in the form that someone can point me to?

 

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
JustinReynolds
Occasional Contributor III

When working with Geometry in the Arcade Editor, it does not return M-Values for you to work with at the moment... so your ability to work with M-values so that you can author such a solution isn't possible.

Field Maps mobile however would return the M-Values to the user at runtime (based on a response I received on this topic from one of the developers at ESRI).  This means it is psuedo supported/ possible, but you will need to be creative with how you author the expression in the editor.  By this I mean, comment out the code that won't compile so that you can save the expression in the arcade editor.  Then using AGO Assistant uncomment out that part of the code.  All testing would have to be done in at runtime in the Mobile App.  This would probably be a fairly complex expression... so it wouldn't be much fun.

- Justin Reynolds, PE

View solution in original post

4 Replies
JustinReynolds
Occasional Contributor III

When working with Geometry in the Arcade Editor, it does not return M-Values for you to work with at the moment... so your ability to work with M-values so that you can author such a solution isn't possible.

Field Maps mobile however would return the M-Values to the user at runtime (based on a response I received on this topic from one of the developers at ESRI).  This means it is psuedo supported/ possible, but you will need to be creative with how you author the expression in the editor.  By this I mean, comment out the code that won't compile so that you can save the expression in the arcade editor.  Then using AGO Assistant uncomment out that part of the code.  All testing would have to be done in at runtime in the Mobile App.  This would probably be a fairly complex expression... so it wouldn't be much fun.

- Justin Reynolds, PE
RodrigoLama
Occasional Contributor

Yes, there is a way to call and store that information in the collected function using an Arcade expression in Field Maps. You can use the 'Nearest' function to get the nearest route to the point and then use the 'Interpolate' function to get the M value at that position on the route line. Here is an example of how this Arcade expression could be written:

// Get the nearest route to the point
var nearestRoute = Nearest($feature, 'Routes');

// Get the M value at the point's position on the route line
var mValue = Interpolate(nearestRoute, $feature.x, $feature.y, 'M');

// Store the M value in a custom field
$feature.M_Value = mValue;

 

Please note that you need to make sure that both the point and the route feature have M-values fields before using this expression, and also you must make sure that both point and route feature are in the same coordinate system.

TrevisMartin
New Contributor III

I was looking for pretty much exactly that in functions, but neither Nearest or Interpolate is in the expression editor for a FieldMaps form.   I'm assuming they aren't in the FieldMaps Arcade Profile. 

As it is, I already have the point linked up to the route through a relate, so they can find each other easily enough.  

I want to store the value in a field,  

The problem is I don't have Interpolate as an option in a Field Maps Form Expression to fetch that M value.

I can do it as a backend process after collection, but it would be useful to have it go in right away.

0 Kudos
jtmouw_NCDOT
New Contributor III

I also have been trying to find a way to do this for a while, any luck getting something functional?

0 Kudos