Finding the distance along a pipe where a point intersects it.

194
2
03-20-2024 10:31 AM
VanessaSimps
Occasional Contributor III

Hello -

I am currently working to migrate our Attribute Assistant, Dynamic Values in ArcMap to Attribute Rules in ArcPro. I found this handy dandy GitHub page, which has been a HUGE help. However the INTERSECTING_FEATURE_DISTANCE rule from Attribute Assistant doesn't appear to have any migration clues... 

VanessaSimps_0-1710954808263.png

 

What I want to do:

I need to find the distance along a pipe where a tap intersects it. This value needs to be returned in feet and added to a field in the Tap feature class table. 

I was thinking I could start with the following

 

 

//Returns true if the geometries intersect
//Intersects(geometry1, geometry2)
var pipe = Polyline(FeatureSetByName($datastore, "wwMain_TN"));
Intersects($feature, pipe);

 

 

This will only give me a true if they intersect. But I need to know at what distance along the pipe that intersection is happening. 

I found this post, but I don't want to create new lines or actually split the pipes. I simply want to find where the Taps lands along the pipe... 

I also have this that I am using to find the to/from MH at the ends of each pipe, so I am wondering if I could adjust it to my needs?

// This Arcade expression will calculate field values from intersecting point layer.
// Can be used for either the From OR the To Junction Field Attribute Assistant Methods. Will need to comment out/uncomment specfic lines (noted in the code below) depending on what it is being used for.

//FROM MHID

// Get Point layer, with fields to evaluate
var fields = ['FACILITYID']
var point_fs = FeatureSetByName($datastore, "wwManhole_TN", fields, true);

var line_shape = Geometry($feature)
var spRef = line_shape['spatialReference']

// Get the origin and end points of the line
var orig_x = line_shape['paths'][0][0].x
var orig_y = line_shape['paths'][0][0].y
var orig_point = Point({x: orig_x, y: orig_y, spatialReference: spRef})

var end_x = line_shape['paths'][-1][-1].x
var end_y = line_shape['paths'][-1][-1].y
var end_point = Point({x: end_x, y: end_y, spatialReference: spRef})

var attributes = {}

function IsEmptyButBetter(data) {Fea
    if (IsEmpty(data)) return true;
    for (var x in data) return false;
    return true;
}

//comment the following to line 35 if you are using for TOMHID
//find point intersecting origin
var origIntx = first(Intersects(orig_point, point_fs));

if (!IsEmptyButBetter(origIntx)) {
   // attributes['UPELEV'] = origIntx['ELEV']
    attributes['FROMMH'] = origIntx['FACILITYID']
  }

//uncomment the following to line 43 if you are using for TOMHID
////find point intersecting end 
//var endIntx = first(Intersects(end_point, point_fs));
//
//if (!IsEmptyButBetter(endIntx)) {
//   // attributes['DOWNELEV'] = endIntx['ELEV']
//    attributes['TOMH'] = endIntx['FACILITYID']
//  }


var result = {}
if (!IsEmptyButBetter(attributes)) {
    result['result'] = {
        'attributes': attributes
    }
}

return result

Has anyone done this before and have any words of wisdom?! 

Thanks in advance!

Vanessa-

0 Kudos
2 Replies
MikeMillerGIS
Esri Frequent Contributor

This came up the other day and my suggestion is as you thought, start with the split code and instead of returning the new geometry, just return the length of the original segment that was split:

 

https://github.com/Esri/arcade-expressions/blob/master/attribute_rule_calculation/SplitIntersectingL...

 

around this area

 line_att = set_date_type(line_feature, pop_keys(line_att, atts_to_remove));
    // Check length of new shapes, adjust the current feature to the longest segment
    if (polyline_1_length > polyline_2_length) {
        Push(update_features, {
            'globalID': line_feature.globalID,
            'geometry': polyline_1
        });

,change it to return length of polyline_1 

0 Kudos
VanessaSimps
Occasional Contributor III

@MikeMillerGIS I will give that a try, thank you!

0 Kudos