Question

How to extend a line until it touches another line


I'm looking for a way to extend a line until it touches another line. The extender is nice but I don't want to specify a length. Can somebody help? Thanks


10 replies

Userlevel 4

Hi

One solution could be use a looping custom transformer that uses the Extender to iteratively make the line longer (e.g. double the length for each iteration) and then perform an LineOnLineOverlayer to check if it intersects. If intersection, then exit with the intersected line, else iterate one more time.

It would probably be a good idea to test for a maximum length as well, so it doesn't iterate indefinitely if there are no intersections.

Davdi

Hi

One solution could be use a looping custom transformer that uses the Extender to iteratively make the line longer (e.g. double the length for each iteration) and then perform an LineOnLineOverlayer to check if it intersects. If intersection, then exit with the intersected line, else iterate one more time.

It would probably be a good idea to test for a maximum length as well, so it doesn't iterate indefinitely if there are no intersections.

Davdi

OK good idea but may be a lot a processing when having to do that for a lot of lines?

Badge +3

@smarceau

extent-to-intersection.fmw

You can use a unconditional merger to merge the lines, or if you have a conditionvalue you can merge on this.

Then simply calculate the intersection and create the line by the end-or startpoint of one line to the intersectionpoint(s)

I extracted part of a biggish script and created a stand alone version.

enjoy!

Badge +5

The "classic" method was always to use the Extender, deliberately specifying a length that is too long. Then use the Intersector to chop the extended line at the intersection point. Finally remove lines that are very short (test using the LengthCalculator/Tester) or that are connected only at one end (maybe the TopologyBuilder or Calculator).

That works, but it's the sort of thing that would worry me if it were my data! I'd check the results carefully to make sure they are all correct.

Badge +5

Oh, the other solution would be the MRF2DExtender transformer, but that would be an extra-cost package. Talk to the Safe sales team (sales@safe.com) to get an evaluation copy and pricing info.

Badge +3

..i see link i postred does not work?

I'll insert pic, nexttime i'm at work...

Badge +3

@smarceau

extent-to-intersection.fmwt

i posted as fmwt this time

Just wanted to share my solution for a similar problem.

 

I wanted to extend some lines of an area to create area-crossing lines. Normally you would also want to extend the lines until the first intersection, relating it to this problem.

 

 

I have a set of areas A and a set of lines L. I extend the lines to give a set L1.

 

Using LineOnAreaOverlayer with L1, A we obtain for each segment of a line whether it is inside an area. I only keep the ones that are inside by testing _overlap giving L2. I then relate L2 to L and keep the ones that touch as L3. L3 is then the set of the extended lines that are completely within A and start at L.

 

I give each line in L3 a unique ID (e.g. crc) and snip off to get the set of non-starting points P3. I test for an overlap with P3, lines(A).

 

The ones with >=2 overlaps create P4. Matching P4 with L3 gives the line segments L4 that completely intersect A, without any leftover parts.

Sadly, this solution does not work when you only have lines, since LineOnLineOverlayer can create intersections between the same input set, resulting in the lines being split before reaching the other side in some cases.

Badge +1

@smarceau

extent-to-intersection.fmw

You can use a unconditional merger to merge the lines, or if you have a conditionvalue you can merge on this.

Then simply calculate the intersection and create the line by the end-or startpoint of one line to the intersectionpoint(s)

I extracted part of a biggish script and created a stand alone version.

enjoy!

Hello gio i am not able to download workbench can you help me please ?

Userlevel 4
Badge +13

Hello gio i am not able to download workbench can you help me please ?

Hi @amolparande, @jdh made a LineToIntersectionExtender which I recommend. See https://knowledge.safe.com/comments/84232/view.html

Reply