Skip to main content

Good morning,

I am trying to extend lines till they intersect. I have a gap between three lines (see attached picture). I would like to extend each line using each lines same trajectory until they all intersect. Is there a way to do this programmatically? Instead of specifying a certain distance to extend the lines. So I want to find the next point along the line on the same trajectory.

I have tried using the distance formula, but I get the shortest distance to each point, but that gives me a triangle instead of T intersection.

Any guidance would be greatly appreciated! Thanks!

David

Hi @david_prosack88, just an idea.

  1. LineExtenter: Extend the lines.
  2. CoordinateExtracter x 2: Extract coordinates from the end node of the Beginning line, extract coordinates from the start node of the End line.
  3. Bufferer: Transform the Beginning/End lines into long narrow polygons with a tiny buffer amount.
  4. AreaOnAreaOverlayer: Overlay those buffer areas, generate list to store the coordinates extracted by the CoordinateExtractor.
  5. Tester: Select overlaid area having 3 as the overlapping count attribute.
  6. CenterPointReplacer: Transform the selected area into its center point. Consider it as the cross point of the original three lines.
  7. ListExploder: Explode the list to make 3 copies of the center point.
  8. VertexCreator: Add vertex (x, y) which were saved with the CoordinateExtractor to connect between the center point and the original line.


I have a couple of ideas, but have a few questions.

 

 

Are the lines that should be extended pre-identified (with say a common id) or do they need to be determined from the the complete line network?

 

 

When you have 3 lines, will they come to a perfect intersection, or is there some tolerance?

I have a couple of ideas, but have a few questions.

 

 

Are the lines that should be extended pre-identified (with say a common id) or do they need to be determined from the the complete line network?

 

 

When you have 3 lines, will they come to a perfect intersection, or is there some tolerance?
Hi @jdh,

 

 

The closest common id they have is the autocad layer name. There are multiple areas within the map that are similar. Yes, they will need to form a an intersection. The end goal will then turn the areas that they form into polygons. I am trying to use an algorithm that will find that intersection in space. I'm brushing up on some Linear Algebra to solve this but it is proving to be a bit more difficult.

 

 

Thanks!

 


Hi @david_prosack88, just an idea.

  1. LineExtenter: Extend the lines.
  2. CoordinateExtracter x 2: Extract coordinates from the end node of the Beginning line, extract coordinates from the start node of the End line.
  3. Bufferer: Transform the Beginning/End lines into long narrow polygons with a tiny buffer amount.
  4. AreaOnAreaOverlayer: Overlay those buffer areas, generate list to store the coordinates extracted by the CoordinateExtractor.
  5. Tester: Select overlaid area having 3 as the overlapping count attribute.
  6. CenterPointReplacer: Transform the selected area into its center point. Consider it as the cross point of the original three lines.
  7. ListExploder: Explode the list to make 3 copies of the center point.
  8. VertexCreator: Add vertex (x, y) which were saved with the CoordinateExtractor to connect between the center point and the original line.

Thanks @takashi! Your idea worked, however because this is a common throughout the map, it solved 95% of the problems. I am hoping to use some sort of algorithm that can find the intersection of the point in space. I guess I'm trying to make it automated. I have been using the intersection of two straight lines to find the intersection point. (mx+b = mx+b) by using the math functions. But it is creating a bit more questions than answers.

 

 


Hi @jdh,

 

 

The closest common id they have is the autocad layer name. There are multiple areas within the map that are similar. Yes, they will need to form a an intersection. The end goal will then turn the areas that they form into polygons. I am trying to use an algorithm that will find that intersection in space. I'm brushing up on some Linear Algebra to solve this but it is proving to be a bit more difficult.

 

 

Thanks!

 

The algebraic method to solve for the theoretical intersection of two lines defined by coordinates is:

 

 

 

 

It will work for all cases except parallel lines.

 

 

The trick is to pair the relevant lines.

 

 

I would probably use a TopologyBuilder to identify all the dangle nodes.

 

Bufferer->Dissolver->Counter OR

 

Snapper->Matcher (geometry only) (I don't know which is more efficient, but I suspect the latter)

 

Followed by a FeatureMerger to get a commonID for each "intersection".

 

A coordinateExtractor to get the last two (or first two) coordinates.

 

You can then use an Aggregator on the lines grouped by the commonID.

 

That will give you one feature per intersection, with the coordinates that can be plugged into the above equation.

 

You can either calculate an arbitrary pair of lines (non parallel) or all 3 potential intersections and take the average of the values.

 

You can then explode the aggregate and use the VertexCreator to add the intersection coordinates to the lines.

 

 

 

 

 


Hi @david_prosack88 Extending lines until they intersect has been suggested by other FME users in the past, but not at Ideas. Can you please post this there?https://knowledge.safe.com/content/idea/list.html Thanks


@david_prosack88

 

I went to the trouble doing these things awhile ago.

Look forum for ZeroStrokeOfsetter.

Converting algebra to parametric expression...the most anoying thing is the continous need to use @Value(). It consumes most of this post's space..LOL.

Here is intersect:

First get start and end of lines to use. I used _t to distiguish between 2 lines.

Ix=

@Evaluate(((@Value(Sx)*@Value(Ey)-@Value(Sy)*@Value(Ex))*(@Value(Sx_t)-@Value(Ex_t))-(@Value(Sx)-@Value(Ex))*(@Value(Sx_t)*@Value(Ey_t)-@Value(Sy_t)*@Value(Ex_t)))/(((@Value(Sx)-@Value(Ex))*(@Value(Sy_t)-@Value(Ey_t))-(@Value(Sy)-@Value(Ey))*(@Value(Sx_t)-@Value(Ex_t)))*1.0))

 

Iy=@Evaluate(((@Value(Sx)*@Value(Ey)-@Value(Sy)*@Value(Ex))*(@Value(Sy_t)-@Value(Ey_t))-(@Value(Sy)-@Value(Ey))*(@Value(Sx_t)*@Value(Ey_t)-@Value(Sy_t)*@Value(Ex_t)))/(((@Value(Sx)-@Value(Ex))*(@Value(Sy_t)-@Value(Ey_t))-(@Value(Sy)-@Value(Ey))*(@Value(Sx_t)-@Value(Ex_t)))*1.0))

 

(test parallel beforehand! Very close to parallel can also get your computer crunching hard))

 

 

addendum. As it is old it still uses *1.0.


Reply