Question

How to extend line to intersection with another line


Badge +1

Hello everybody,

Im trying to find a way how to extend line to intersection with different line. I know, its a very common issue here - I read about Extender (but it extends whole line - both ends right?), also about anchoredsnapper. But both of them have troubles... And MRF2DExtender is perfect, but paid... Is anybody here, who found reliable solution for that problem please?

Thank You so much!

Lubo


10 replies

Badge

may be that will help you

https://knowledge.safe.com/questions/28971/how-to-extend-a-line-until-it-touches-another-line.html

and

https://knowledge.safe.com/questions/83658/fme-challenge-12-days-of-fme-hackathon-2018.html?childToView=84232#comment-84232

 

Badge +1

@miladahmad

Thank You so much! But, what if I need to extend lines to intersection in one feature class? I check, that both solution use base and candidate principle... Just imagine similar tool as "MAPCLEAN" in AutoCAD.

Thanks a lot!

Lubo

Badge

@miladahmad

Thank You so much! But, what if I need to extend lines to intersection in one feature class? I check, that both solution use base and candidate principle... Just imagine similar tool as "MAPCLEAN" in AutoCAD.

Thanks a lot!

Lubo

try SmartCleaner_2013 from FME_HUB (https://hub.safe.com/publishers/safe-lab/transformers/smartcleaner_2013 )

Badge +3

@lazarlubomir

 

High school math should suffice.

In the 28971 link i posted a workspace that simply (in my sample,unconditionaly) merges lines and calculates the intersectionpoint. Subsequently the line is rebuild.

Looks complicated but is actually high school math.

 

I doubt someone on the forum used it though.... ;)

 

 

Badge +22

Many of the solutions in question 28971 posted by miladahmad do not use the base/candidate principle.

 

 

If I were to create one in pure fme (no python). I would try something along the lines of
  • Assign unique id to features (Data 1)
  • Identify Dangle Lines (and direction)
    • TopologyBuilder
    • Tester to identify nodes with only one edge
    • FeatureMerger to identify corresponding dangle lines
  • Extend dangle lines in the relevant direction by some tolerance distance
    • LineExtender (Beginning/End Ports, not stretched)
    • AttributeCreator to indicated that the features are potential extensions (PE)
  • Identify and remove PEs that are dangles
    • TopologyBuilder (make sure all attributes of first topology builder are removed from feature
    • Tester to identify nodes with more than one edge
    • Tester to identify edges that are PEs
    • FeatureMerger to identify connected PEs (Data 2)
  • Check that PE is connected to parent feature (deal with case where the PE crosses multiple features in the extension tolerance, presumably one wants it to stop at the first line)
    • SpatialFilter/Relator Data 2 touches Data 1 (Group by unique ID)
    • Alternatively you could have extracted the coordinates of the extended line (last for beginning, first for end) prior to the second topologyBuilder and compare them to the coordinates after the topologyBuilder and keep only the one that matches.

You should now have a set of features that are the extended bits (REs). Depending on what you want your final data to be, you can do any of the following:

  • LineCombiner with REs and original data, grouped by unique id. Original dangle vertex is kept, feature that it now touches is not split at point of intersection. Optionally use Vertex remover to remove original dangle vertex.
  • LineCombiner with REs and edges from the second topologyBuilder (remove all PEs first), grouped by unique id. Resulting dataset is topologically correct.
  • LineCombiner with REs and original data, grouped by unique id. Extract new end(start) point, pointOnLineOverlayer to split lines at intersection.
Badge +22

@miladahmad

Thank You so much! But, what if I need to extend lines to intersection in one feature class? I check, that both solution use base and candidate principle... Just imagine similar tool as "MAPCLEAN" in AutoCAD.

Thanks a lot!

Lubo

Many of the solutions in question 28971 posted by miladahmad do not use the base/candidate principle.

 

 

If I were to create one in pure fme (no python). I would try something along the lines of
  • Assign unique id to features (Data 1)
  • Identify Dangle Lines (and direction)
    • TopologyBuilder
    • Tester to identify nodes with only one edge
    • FeatureMerger to identify corresponding dangle lines
  • Extend dangle lines in the relevant direction by some tolerance distance
    • LineExtender (Beginning/End Ports, not stretched)
    • AttributeCreator to indicated that the features are potential extensions (PE)
  • Identify and remove PEs that are dangles
    • TopologyBuilder (make sure all attributes of first topology builder are removed from feature
    • Tester to identify nodes with more than one edge
    • Tester to identify edges that are PEs
    • FeatureMerger to identify connected PEs (Data 2)
  • Check that PE is connected to parent feature (deal with case where the PE crosses multiple features in the extension tolerance, presumably one wants it to stop at the first line)
    • SpatialFilter/Relator Data 2 touches Data 1 (Group by unique ID)
    • Alternatively you could have extracted the coordinates of the extended line (last for beginning, first for end) prior to the second topologyBuilder and compare them to the coordinates after the topologyBuilder and keep only the one that matches.

You should now have a set of features that are the extended bits (REs). Depending on what you want your final data to be, you can do any of the following:

  • LineCombiner with REs and original data, grouped by unique id. Original dangle vertex is kept, feature that it now touches is not split at point of intersection. Optionally use Vertex remover to remove original dangle vertex.
  • LineCombiner with REs and edges from the second topologyBuilder (remove all PEs first), grouped by unique id. Resulting dataset is topologically correct.
  • LineCombiner with REs and original data, grouped by unique id. Extract new end(start) point, pointOnLineOverlayer to split lines at intersection.
Userlevel 4
Badge +13

Hi @lazarlubomir Did you try end-point or segment snapping with the AnchoredSnapper (or Snapper)?

Badge +22

@lazarlubomir

 

High school math should suffice.

In the 28971 link i posted a workspace that simply (in my sample,unconditionaly) merges lines and calculates the intersectionpoint. Subsequently the line is rebuild.

Looks complicated but is actually high school math.

 

I doubt someone on the forum used it though.... ;)

 

 

How well does your workspace scale with a full dataset? For example a road network. It looks like it would computer every possible intersection twice, regardless of whether the features were already connected at both ends.

 

 

I'm thinking the lines could be analysed first to identify the dangles, and only send those to the Requestor port, and the full dataset to the supplier port. But I have no idea if the cost of identifying the dangles is more or less than the savings in reducing the number of intersection calculations.
Badge +3

@lazarlubomir

 

High school math should suffice.

In the 28971 link i posted a workspace that simply (in my sample,unconditionaly) merges lines and calculates the intersectionpoint. Subsequently the line is rebuild.

Looks complicated but is actually high school math.

 

I doubt someone on the forum used it though.... ;)

 

 

@jdh

 

The workspace (part) only calculates inetersection points of any ine to any line that one would want to.

 

Then it recreates the lines to that point.

2 lines can only intersect in 1 point, is it not?

 

Other logic is not in there, it is part of a custom transfomer.

Other ologic would be in the main space.

 

It would seem obvious to me that one would not calculate intersections where not needed.

What logic you would use to do that is not relevant to this bit.

 

That one would select the objects where or when required.

 

I did not realise this would not be obvious. ;)

 

 

It is part of a script concerning zero stroke ofsetter (it should be in the forum somewhere, 2014 or so)

Badge +3

@lazarlubomir @jdh

 

Here i have extracted just the intersecting bit of the script. So as to clarify things.

 

This is result

 

Green lines intersected. Only 1x run for there is no intersection possible at the other side (obvious)

 

Here is wb for intersection...saves u some highschool math.

lineintersection.fmw

(expression is old, created in 2014 )

 

Reply