Select to view content in your preferred language

Get route m-value at point-clicked using Arcade?

4913
13
Jump to solution
03-05-2020 07:42 AM
NickHarvey
Frequent Contributor

Hi All - I see that it is possible to access x,y,z, & m values for a custom pop-up using Arcade. The code below appears to be working in ArcGIS Pro 2.5.0 per my route layer:

var line = Geometry($feature)
var paths = line.paths;
var startingpoint = paths[0][0];
return text(startingpoint)‍‍‍‍‍‍‍‍

However, I'm not yet understanding how to return the m-value for any point along the route that was clicked, rather than the centroid or endpoints.  The m-value I'm looking for appears in the pop-up panel at lower right in ArcGIS Pro 2.5.0 (see pic below). 

Any assistance appreciated!  

13 Replies
BartvanderWolf
Emerging Contributor

Hi All,
Working on the same sort of workflow. I guess what would be handy is a "$clickedlocation" profile variabele.  We could create the geometry object for that location and hopefully extract M and Z-values from "$feature"..

I try to create a popup for route segments exposing some route statistics. Id also would like to show the progress (M) and elevation (Z) of the clicked location. Only way I can think of to achieve this, is to convert vertices to points and do the popup on that layer.

DISIG
by
Regular Contributor

this final code work fine for me.

i pre calculate the "M" value.

// CALCUL DU CUMUL POUR UNE LIGNE
// version 1.0 2023-03-16

 

// variables utilisateur
var CAS            = 0 ;//mettre 0 pour point de début et -1 point de fin
                    console("cas choisis : "+ CAS )
var SearchingLayer = FeatureSetByName($map,"ROUTE");
var TOLERANCE      = 20 ;// la variable TOLERANCE de capture fixée à 5 mètres peut être ajustée si nécessaire
                    console("tolérance choisie : "+TOLERANCE)

 

// 1 - Extraction du point de calcul et recherche
var myPoint   = Point({x: Geometry($feature)['paths'][CAS][CAS]['x'],y: Geometry($feature)['paths'][CAS][CAS]['y'],spatialReference: { wkid: 102100 }})
              console("coordonnées de mon point : "+ myPoint)
var buff      = Extent(bufferGeodetic(myPoint,TOLERANCE,'meters'));
var myGeom    = myPoint;
var MySearch = Intersects(BufferGeodetic(myGeom, TOLERANCE, "meters"),SearchingLayer);

 

// le calcul renvoit -1 pour signifier absence de rd à proximité
if(isempty(Mysearch)){return -1}
// dans les autres cas on calcul pour le cas choisi.
if(count(Mysearch)==1){
          console("cas une seule rd")
  var Arc = first(Mysearch)
}
else{
                 console("cas plusieurs rd")
  var EvDistance = Infinity;
  var MyNearest;
  for (var listing in MySearch){
      var DynDistance = Distance(listing,myGeom, "meters");
      if(DynDistance < EvDistance){
        EvDistance = DynDistance;
        MyNearest = listing;
        var Arc = MyNearest
      }
  }
}
var longueur  = 0;
var p         = 0;
var newLine   = Dictionary(text(Geometry(Arc)));
var reste     = Round(LengthGeodetic(First(Cut(Arc,Rotate(clip(Arc,buff),90)))));
var cutter    = Rotate(clip(Arc,buff),90);
for (p in newLine.paths){
    var segment  = Polyline({paths: [newLine.paths[p]],spatialReference:{latestWkid:3857,wkid:102100}})
    var segLongueur = lengthGeodetic(segment,'meters')
    if (intersects(segment,cutter)==true)
        {return round(longueur+reste)}
    else
        {longueur += segLongueur;}
0 Kudos
DISIG
by
Regular Contributor

Now that the m value is exposed in arcade the code is  a bit more easy 🙂

the video show how to dynamically get a distance relative to a landmark.

// https://www.youtube.com/watch?v=dddZTpsOjY0

var click = $userinput

// step2 : get cumul from segment

var geom       = Geometry($feature)

var RD         = $feature.route

var densegeom  = Densify(geom, 1)

var XClickGeom = intersection(densegeom,buffer(click,10,'meters'))

var PTC        = PointToCoordinate(XClickGeom, click)

var POIM       = round(XClickGeom.paths[PTC.partID][PTC.segmentID].m)

// step3 : get PR from cumul

var prevBorne = first(orderby(Filter(FeatureSetByName($map,"BORNES"),'G_cumul_3857_geod<=@POIM AND ROUTE=@RD'),'G_cumul_3857_geod DESC'));

if(isempty(prevBorne)){return '0 + '+ POIM}

var diff = POIM-prevBorne.G_cumul_3857_geod

var pr = prevBorne.PR + ' + ' + diff

return pr
0 Kudos
AyanPalit
Esri Regular Contributor

Updating this old thread for tracking and community documentation. Get route m-value at point-clicked is out of the box Pro function and doesn't require any custom code.

At ArcGIS Pro 2.4, the Navigation > Explore tool included this enhancement.  You can view m-values in a pop-up for a feature that contains measured values (m-values) in their geometries. The coordinate display at the bottom of the pop-up includes the m-value closest to the clicked location in the map or scene. For linear geometries, the value is calculated by interpolating between the nearest vertices. 

Pop-ups for M-aware features

Related thread Link with Screenshots.

There is also LRS Identify widget in Experience Builder for web apps.

FYI @KatyLewis 

Ayan Palit | Principal Consultant Esri
0 Kudos