Grab the LRS location with Arcade?

829
5
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
2 Solutions

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

TrevisMartin
New Contributor III

Yes, it's kind of a two-step process right now.

You can either do it with two related point features, or a single point feature.  Either way the feature class that represents your collection point need to have an M-Value field as a Double in the attributes.  If you are using the two related points you should have it in both.

Your point classes have to be M enabled.

Assuming you have a line layer that has been calibrated with your M values

For a single point process you will use a calc expression that inserts the M value in to the attribute field on creation only, then calls back to the original feature upon edit.

 

 

if ($editcontext.editType == "INSERT") {
  return Geometry($feature).M
} else {
  return $originalFeature.M_Val
}

 

 

 The collection process then is

  • tap the M-route,
  • Choose "Find Measure"
  • accept the measure popup.
  • Field maps drops a pin on the route (this will ferry the M value to your feature)
  • Use the "Collect Here" option, collecting your point.
    • Important: do not update the  point during this first stage, or you will lose the M value.
  • Submit your point
  • Tap the submitted point and select 'edit' in the popup. 
  • Tap your locator arrowhead (top right) in order to center on your position.
  • Click "Update Point" to move the point.
  • Submit the point again. 

The expression will only populate the M value when you create it on the line the first time.  After that you can move the point because it will call back to it's previous version for the M-value.

The second option is to have two related point classes.  One point acts as your centerline reference point an the other is your feature point class

The expression in your feature point M value field would be something like

 

 

var refPoint
refPoint = First(FeatureSetByRelationshipName($feature,"Demo_Centerline_Points"))
return Geometry(refPoint).M

 

 

The collection process  would be

  • Tap the m-route
  • Tap "Find Measure"
  • Accept the Pop-up with the distance
  • Tap "Collect Here"
  • Choose a Centerline Point
  • Submit the Point
  • Click the link button in the centerline Point to create a related feature
  • Click "Add"
  • Choose subclass if applicable.
  • Submit the point. 

The expression will grab the M value from the centerline point and populate it to the feature point's attributes.

So the process is a little fussy but it works. 

View solution in original post

0 Kudos
5 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
TrevisMartin
New Contributor III

Yes, it's kind of a two-step process right now.

You can either do it with two related point features, or a single point feature.  Either way the feature class that represents your collection point need to have an M-Value field as a Double in the attributes.  If you are using the two related points you should have it in both.

Your point classes have to be M enabled.

Assuming you have a line layer that has been calibrated with your M values

For a single point process you will use a calc expression that inserts the M value in to the attribute field on creation only, then calls back to the original feature upon edit.

 

 

if ($editcontext.editType == "INSERT") {
  return Geometry($feature).M
} else {
  return $originalFeature.M_Val
}

 

 

 The collection process then is

  • tap the M-route,
  • Choose "Find Measure"
  • accept the measure popup.
  • Field maps drops a pin on the route (this will ferry the M value to your feature)
  • Use the "Collect Here" option, collecting your point.
    • Important: do not update the  point during this first stage, or you will lose the M value.
  • Submit your point
  • Tap the submitted point and select 'edit' in the popup. 
  • Tap your locator arrowhead (top right) in order to center on your position.
  • Click "Update Point" to move the point.
  • Submit the point again. 

The expression will only populate the M value when you create it on the line the first time.  After that you can move the point because it will call back to it's previous version for the M-value.

The second option is to have two related point classes.  One point acts as your centerline reference point an the other is your feature point class

The expression in your feature point M value field would be something like

 

 

var refPoint
refPoint = First(FeatureSetByRelationshipName($feature,"Demo_Centerline_Points"))
return Geometry(refPoint).M

 

 

The collection process  would be

  • Tap the m-route
  • Tap "Find Measure"
  • Accept the Pop-up with the distance
  • Tap "Collect Here"
  • Choose a Centerline Point
  • Submit the Point
  • Click the link button in the centerline Point to create a related feature
  • Click "Add"
  • Choose subclass if applicable.
  • Submit the point. 

The expression will grab the M value from the centerline point and populate it to the feature point's attributes.

So the process is a little fussy but it works. 

0 Kudos