Select to view content in your preferred language

How to set a value when a new line intersects with a line?

80
3
Wednesday
rsnider43
Emerging Contributor

Hello, I am writing an attribute rule that is supposed to set a value of either 1.25 or 2 in the attribute table of a newly created feature, based on the value of fcount. However, it only outputs a null value. Any insights?

 

 

 

var fibercable = FeaturesetByName($datastore,"attributeruletest.sde.fibercable", ['fcount'], true);
if(Count(intersects(fibercable,Geometry($feature))) > 0)
{   if(fibercable <= 48){
   return 1.25;
} else {
   return 2;}}



 

0 Kudos
3 Replies
RPGIS
by MVP Regular Contributor
MVP Regular Contributor

Hi @rsnider43,

Your code is a bit confusing as to what you are specifically looking for. If you are looking to get the 'fcount' of the intersecting feature then it would look something like this.

var fibercable = FeaturesetByName($datastore,"attributeruletest.sde.fibercable", ['fcount'], true)
var IntCable = Intersects(fibercable,Geometry($feature))
if(Count(IntCable) > 0){ IntCable = First( IntCable ) ; iif( IntCable['fcount'] <= 48, 1.25, 2 ) }

// If you are trying to return multiple values, then you would need to loop through each row and return the corresponding field value
var Values = {}
if(Count(IntCable) > 0){
	for( var row in IntCable ){
		Values['Somefield'] = iif( row['fcount'] <= 48, 1.25, 2 )
		}
	}

Without any context or direction it is difficult to determine the best way to help. We can definitely help you if you could please clarify on what it is you are trying to accomplish.

0 Kudos
rsnider43
Emerging Contributor

Right, so the rule is built around the idea of when a new feature is drawn, and it directly intersects another feature called fibercable, it will set a value of either 1.25 or 2 in the attribute table column of 'diameter_inches' in the newly drawn feature. This would be based on the 'fcount' value in the intersected fibercable feature being lower or higher than 48. It would be active upon when the feature is created.

0 Kudos
RPGIS
by MVP Regular Contributor
MVP Regular Contributor

Then the solution that I gave you earlier should do the trick. The only thing that I am unsure of is if you are only looking for the features that intersect a single cable or multiple cables.

If it is only 1 then the example that I provided earlier should do the trick. The only thing you would need to do is delete the section of code from the comment and below.

If there is more than 1, you can simply add Max( IntCable, 'fcount' ) and return an iif( Max( IntCable, 'fcount' ) < 48, 1.25, 2) statement.

0 Kudos