Select to view content in your preferred language

Identify point ID at start of line using attribute rule

561
2
08-02-2023 02:17 PM
Chris_S
New Contributor II

I have two feature classes: One contains manholes (points) and the other contains sewer mains (polyline). I need to gather the Unit ID (text field) assigned to the manhole at the start of the sewer main and place it into a field ('StartID') in the sewer main table.

I'm trying to create an attribute rule that will do such a thing. Can anyone provide some insight as I'm not having any values returned? Thanks in advance.

Here's my code:

var manholeID = FeatureSetByName($datastore, 'Exported_Manholes', ['UNITID'], true)
var start_point = Geometry($feature).paths[0][0]

if(Intersects(start_point, $feature)){
return manholeID
}

return ERROR

2 Replies
Chris_S
New Contributor II

I figured this out and thought I'd share. 

For context:

Manholes (points) each have a UNITID. For example one manhole is A1-123 and another manhole is A1-456. 

Sewer Mains have a start point and an end point. The start point is stored in a column called UNITID and the end point in another column called UNITID2 in the Sewer Mains attribute table.

To capture the UNITID from the "start" manhole, I created the following attribute rule for the UNITID field in the Sewer Mains attribute table:

var manhole = FeatureSetByName($datastore, 'Exported_Manholes', ['*'], true)
var start_point = Geometry($feature).paths[0][0]
var intersectLayer = Intersects(manhole, start_point)

for (var f in intersectLayer){
return f.UNITID
}

 

To capture the UNITID from the "end" manhole, I created the following attribute rule for the UNITID2 field in the Sewer Mains attribute table:

var manhole = FeatureSetByName($datastore, 'Exported_Manholes', ['*'], true)
var end_point = Geometry($feature).paths[-1][-1]
var intersectLayer = Intersects(manhole, end_point)

for (var f in intersectLayer){
return f.UNITID
}

I'm curious what others think of this/how they would do it. I guess if it works, it works though...

0 Kudos
Chris_S
New Contributor II

The previous reply worked but would not return <null> if the line segment end point was moved off the point. The following fixes that issue:

var manhole = FeatureSetByName($datastore, 'Exported_Manholes', ['*'], true)
var start_point = Geometry($feature).paths[0][0]
var intersectLayer = Intersects(manhole, start_point)
var startID = First(intersectLayer)

if (startID == null){
return null
}
return startID.UNITID

 

0 Kudos