span8
span4
span8
span4
I have a working pipe network where I know how many service connections are on each pipe saved as the attribute [_count] on each pipe.
I'd like to count the number of connections upstream of each pipe segment and save it as an attribute on that pipe.Our goal is to prioritize emergency repairs based on the # of properties a particular pipe segment serves.
Most of the examples and transformers are based on the shortest value (time,travel,length,etc).I kind of want the opposite.StreamOrderCalculator could work if I were allowed to 1) use an attribute instead of Stream Order Type,and 2) accumulate that attribute at nodes instead of checking which one is larger or if they are equal.Same with StreamPriorityCalculator.It's looking for shortest path,not longest.
Any suggestions are appreciated.
import fmeimport fmeobjectsclass UpstreamHousesAccumulator(object): def __init__(self): self.idToFeature = {} def input(self,feature): id = str(feature.getAttribute('pipe_id')) feature.removeAttribute('total') self.idToFeature[id] = feature def close(self): for feature in self.idToFeature.values(): self.setTotal(feature) self.pyoutput(feature) def setTotal(self,feature): _,isMissing,_ = feature.getAttributeNullMissingAndType('total') if isMissing: n = int(feature.getAttribute('houses')) upstreamIds = feature.getAttribute('_relationships{}.pipe_id') if upstreamIds: for id in upstreamIds: upstream = self.idToFeature[id] self.setTotal(upstream) # recursive call n += upstream.getAttribute('total') feature.setAttribute('total',n)
Not sure how well,or performant it would be on a real network but.
Assuming your network is something like this,with an attribute with number of houses of that supply pipe.
Extract every start point of network and create line with final end point.Use ShortestPathFinder to get every path from start to finish.LineOnLine Overlayer to find overlapping segments,accumulate your house count into a list,sum the list to find number of houses upstream
No,it's the number of houses connected to that pipe that I want to keep adding as an attribute.
If I have 2 pipes;one that supplies water to 10 houses and one that supplies water to 100 - all other things being equal - I need to fix the one that supplies 100 houses first.
Really the task is to extract that part of the network upstream of the original segment,after which counting is fairly easy.I think you can do this by NetworkTopologyCounter and leaving out the pipe segment that is being worked on.Then you get a set of networks,one of which will be the part upstream of the original segment.
How to find which network?Well I'd take the start point (or end point depending on the direction) of the original pipe segment,do an overlay,and find out what network ID the line has.A simple test or merge removes all other networks and then a Counter/StatsCounter tells you how many features there are.
So here I have a network of streams.The one marked with a red line is my "pipe segment"...
And here's my workspace:
With this I can isolate the network upstream of the original segment and count that there are 8 line segments.
I'm not sure what counts as a "connection" for you.If it's the number of pipe segments,then this is your answer.If it's a connection at the end of each pipe,then the number of connections is the number of lines plus one.To be absolutely certain you could run it through the TopologyBuilder and count the number of nodes.Or count the number of vertices in a pipe using the VertexCounter.
Anyway,however you want to count,I think the important part is isolating that part of the network,and I think this method will do that fairly well.
这是我的工作空间if it's of help.I picked the original segment using a Counter/Tester,but obviously you'd select it using an ID of some sort.
© 2019 亚搏在线Safe Software Inc |Legal