Skip to main content
Solved

Longest path through collection of lines


chau
Contributor
Forum|alt.badge.img+3
  • Contributor

I have a polygon on which I run a CenterLineReplacer (medial axis). I would like to calculate the longest path spanned by the center lines.

How is this possible within FME (preferable within FME 2016) ?

Best answer by takashi

Hi @chau, a possible solution I can think of is:

  1. Build a network from the center line.
  2. Find all dead-end nodes.
  3. Create from-to lines connecting all combinations of two dead-end nodes.
  4. Create shortest paths for every from-to line.
  5. Calculate lengths of the paths.
  6. Select the longest one. Done!

If you could provide a sample polygon data, I would test the solution above.

I have FME 2016.1.3.2 installation. Can you work with this version?

View original
Did this help you find an answer to your question?

8 replies

david_r
Evangelist
  • March 1, 2018

Here's one way that might work, given that I've understood the question properly

- Run the center lines through the TopologyBuilder

- For each end node (a node that isn't connected to more than one edge), create a line to each of the other end nodes (VertexCreator), e.g.

- ShortestPathFinder + LengthCalculator + Sorter by length, descending

- Your first feature should now contain the longest path


takashi
Supporter
  • Best Answer
  • March 1, 2018

Hi @chau, a possible solution I can think of is:

  1. Build a network from the center line.
  2. Find all dead-end nodes.
  3. Create from-to lines connecting all combinations of two dead-end nodes.
  4. Create shortest paths for every from-to line.
  5. Calculate lengths of the paths.
  6. Select the longest one. Done!

If you could provide a sample polygon data, I would test the solution above.

I have FME 2016.1.3.2 installation. Can you work with this version?


takashi
Supporter
  • March 1, 2018
takashi wrote:

Hi @chau, a possible solution I can think of is:

  1. Build a network from the center line.
  2. Find all dead-end nodes.
  3. Create from-to lines connecting all combinations of two dead-end nodes.
  4. Create shortest paths for every from-to line.
  5. Calculate lengths of the paths.
  6. Select the longest one. Done!

If you could provide a sample polygon data, I would test the solution above.

I have FME 2016.1.3.2 installation. Can you work with this version?

wow, exactly same as @david_r's solution.

 


david_r
Evangelist
  • March 1, 2018
takashi wrote:
wow, exactly same as @david_r's solution.

 

Scary! :-)

chau
Contributor
Forum|alt.badge.img+3
  • Author
  • Contributor
  • March 1, 2018
takashi wrote:
wow, exactly same as @david_r's solution.

 

Well that should ensure that the idea is even better :)

 

I used the idea and it worked!

 

Thanks both of you.

 

 


lde
Contributor
Forum|alt.badge.img+5
  • Contributor
  • January 23, 2020
takashi wrote:

Hi @chau, a possible solution I can think of is:

  1. Build a network from the center line.
  2. Find all dead-end nodes.
  3. Create from-to lines connecting all combinations of two dead-end nodes.
  4. Create shortest paths for every from-to line.
  5. Calculate lengths of the paths.
  6. Select the longest one. Done!

If you could provide a sample polygon data, I would test the solution above.

I have FME 2016.1.3.2 installation. Can you work with this version?

hi @takashi, @david_r, @chau,

I also need to do this exactly. I managed to have it working but I was wondering if there was a more efficient way of doing it, especially related to the point 3 of @takashi's comment.

Here is my workspace with a sample (developed in FME 2019.1) :test_sans_multi_lignes.fmwt

 

Do you have you guys have any advice for me ?

Thanks in advance !


  • September 10, 2020
takashi wrote:

Hi @chau, a possible solution I can think of is:

  1. Build a network from the center line.
  2. Find all dead-end nodes.
  3. Create from-to lines connecting all combinations of two dead-end nodes.
  4. Create shortest paths for every from-to line.
  5. Calculate lengths of the paths.
  6. Select the longest one. Done!

If you could provide a sample polygon data, I would test the solution above.

I have FME 2016.1.3.2 installation. Can you work with this version?

Hi @Takashi Iijima​, @Casper Børgesen​ and @david_r​,

i have the same problem, but the approach doesn't work for me. The centerlines are only one line. If I put them in the NetworkTopologyCalculator, they come out as rejected features. The help of the TopologyCalculator says "That is, all features must be split at junctions." If you split them with the Intersector, you can no longer calculate the longest paths afterwards.

I would be very happy if you could help me.


bwn
Evangelist
Forum|alt.badge.img+26
  • Evangelist
  • September 10, 2020
bastianr95 wrote:

Hi @Takashi Iijima​, @Casper Børgesen​ and @david_r​,

i have the same problem, but the approach doesn't work for me. The centerlines are only one line. If I put them in the NetworkTopologyCalculator, they come out as rejected features. The help of the TopologyCalculator says "That is, all features must be split at junctions." If you split them with the Intersector, you can no longer calculate the longest paths afterwards.

I would be very happy if you could help me.

The Solution posted above uses TopologyBuilder to build the Network. NetworkTopologyCalculator is a different transformer that is used on Networks that are already built and is not used for this solution. NetworkTopologyCalculator is instead used to calculate how many different separate networks exist, and which of those networks each line belongs to.

 

The Solution above also uses ShortestPathFinder to find all paths on split lines. A Path combines all the individual network segment lines together, so it doesn't matter if the centrelines are split up at their intersection points, the ShortestPathFinder will return them back as one "virtual" Path line, which can also be recombined back into a single polyline with GeometryRefiner if desired.


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