Skip to main content
Solved

Looping According to Spatial Data


parashari
Forum|alt.badge.img+2
Hi There,

 

I have a road network polyline data with some dangle roads. I need to remove all the dangles using looping in FME. But the master catch comes here...I do not need to give the number of iterations myself. All the roads, having a free node should be looped out of the network spatially giving output of the present loop to the input of the next one regardless of the nnumber of loops. Attached Image can help better to understand more.

 

 

 

Please revert if i am not able to communicate properly.

 

Thanks and regards.

 

 

 

Best answer by takashi

Hi,

 

 

I suppose that your requirement is to remove "dangle" lines recursively from the network, so that the resulting network contains only lines belonging to a cycle or a circuit.

 

An interesting challenge. I would try that by creating a custom transformer with Loop.

 

e.g.

 

 

 

A "dangle" line touches a node that touches just one line. You can determine that a node touches how many lines by testing the number of elements of the "_node_angle{}" list created by the TopologyBuilder.

 

The SpatialFilter outputs "dangle" lines from the Passed port, "non-dangle" lines from the Failed port.

 

The FeatureMerger merges one "dangle" line to every "non-dangle" line unconditinally.

 

If a "dangle" line existed, all the "non-dangle" lines will be output from the Merged port of the FeatureMerger and go to the Input port (next iteration) through the Loop port.

 

Otherwise, they will be output from the NotMerged port --> Output port, and the iteration will finish.

 

Note that this custom transformer must be always linked because it contains blocking-transformers with Loop.

 

 

Takashi
View original
Did this help you find an answer to your question?
This post is closed to further activity.
It may be a question with a best answer, an implemented idea, or just a post needing no comment.
If you have a follow-up or related question, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

8 replies

david_r
Evangelist
  • October 8, 2015
Hi

 

 

Sorry, I struggled with the same sentence as Pratap. What does the numbers mean?

 

 

As a general recommendation, I'd start with the TopologyBuilder.

 

 

David

parashari
Forum|alt.badge.img+2
  • Author
  • October 8, 2015
In general Looping, the looper parameter pops "Maximum number of iterations(0 for infinity)", and the process iterates in the loops for certain number of times. Ex. In the image above, all the green road network segments will remove in the first iteration, all the red roads will iterate iin the second time, and so on...

 

The above output is a take from the WB which I have created, but I had set '2' for "Max no. of iterations", so WB took two loops.

 

I want the WB to run the iteration according to the road network. It should go through the loops untill all free nodes end, without any hard code values.

 

The WB should keep the loop till it finds the dangled road elements. As soon as, all the road elements are extracted out of the road network, the looping process should stop and my output would be all interconnected road (free of dangled ones). :)

david_r
Evangelist
  • October 8, 2015
In addition to Prataps suggestion using the NeighborFinder, there is also the MRF2DDangleRemover (3rd party license necessary) to consider.

 

 

David

takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • Best Answer
  • October 8, 2015
Hi,

 

 

I suppose that your requirement is to remove "dangle" lines recursively from the network, so that the resulting network contains only lines belonging to a cycle or a circuit.

 

An interesting challenge. I would try that by creating a custom transformer with Loop.

 

e.g.

 

 

 

A "dangle" line touches a node that touches just one line. You can determine that a node touches how many lines by testing the number of elements of the "_node_angle{}" list created by the TopologyBuilder.

 

The SpatialFilter outputs "dangle" lines from the Passed port, "non-dangle" lines from the Failed port.

 

The FeatureMerger merges one "dangle" line to every "non-dangle" line unconditinally.

 

If a "dangle" line existed, all the "non-dangle" lines will be output from the Merged port of the FeatureMerger and go to the Input port (next iteration) through the Loop port.

 

Otherwise, they will be output from the NotMerged port --> Output port, and the iteration will finish.

 

Note that this custom transformer must be always linked because it contains blocking-transformers with Loop.

 

 

Takashi

takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • October 8, 2015
Testing result. Red lines are the removed "dangle" lines.

 

Does it satisfy your requirement?

 


parashari
Forum|alt.badge.img+2
  • Author
  • October 12, 2015
Hi Takashi,

 

 

I think you understood my problem. I guess that might be the right solution, but I think my WB is going in the infinite loop process. Your image attachment is perfect according to my requirement, but then I m not able to get through the right answer.

takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • October 12, 2015
I can't find a possible reason that the custom transformer will fall into an infinite loop.

 

Compare your transformer definition and this (an improved version). (https://drive.google.com/file/d/0B0ufVP2t0eApODNfYnAyU0VNT0E/view?usp=sharing)

parashari
Forum|alt.badge.img+2
  • Author
  • October 15, 2015
Well Thanks Takashi.

 

That is exactly what I wanted. I had dangles till 3rd degree of the road network and its working perfectly.

 

 

Regards. :)

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings