Skip to main content
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

david_r
Celebrity
  • May 25, 2016

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


  • Author
  • May 25, 2016
david_r wrote:

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?


gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • May 26, 2016

@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!


Forum|alt.badge.img+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.


Forum|alt.badge.img+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.


gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • May 28, 2016

..i see link i postred does not work?

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


gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • May 30, 2016

@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.


amolparande
Forum|alt.badge.img+1
gio wrote:

@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 ?


fmelizard
Safer
Forum|alt.badge.img+18
  • Safer
  • February 13, 2019
amolparande wrote:

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


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