Skip to main content
Question

How to snapping edges endpoints to node?


Forum|alt.badge.img

Starting point:

 

I have a broken topology with nodes an edges as shown in the first picture below. The problem is that not all edges are graphically connected with the respective node.

Attempt to solve:

 

I used a "AnchoredSnapper" with the nodes as anchor and the edges as candidate. The "Snapping Tolerance" is depicted with the grey area in the pictures. The edges and the node which belongs together have a equal attribute what I use to group the elements.

Problem:

 

After the "AnchoredSnapper" the edges and the respective node are graphically connected as shown in the second picture (green lines). But unfortunately also the ends of the edges which have already a node and are within the "Snapping Tolerance" (red lines).

Question:

 

How can I avoid the wrong connections (red lines)? Adjusting the "Snapping Tolerance" is not an option because the not connected ends are not always in the same distance from the target node.

8 replies

david_r
Evangelist
  • April 10, 2018

Here's one possible way, off the top of my head:

  1. Use a Counter to attribute a unique ID to all the lines
  2. CoordinateExtractor to get the coordinates of either the start or end of each line
  3. VertexCreator to create a new point ("Replace with point") using the coordinates from 2
  4. AnchoredSnapper using the new points as candidates
  5. CoordinateExtractor on the points to get the new x,y values
  6. Merge the new x,y values back onto the original edge feature using the counter id from 1
  7. VertexCreator in either mode "Add point" (add to end of edge) or "Insert point at index" = 0 (add to start of edge)


Forum|alt.badge.img
  • Author
  • April 10, 2018
david_r wrote:

Here's one possible way, off the top of my head:

  1. Use a Counter to attribute a unique ID to all the lines
  2. CoordinateExtractor to get the coordinates of either the start or end of each line
  3. VertexCreator to create a new point ("Replace with point") using the coordinates from 2
  4. AnchoredSnapper using the new points as candidates
  5. CoordinateExtractor on the points to get the new x,y values
  6. Merge the new x,y values back onto the original edge feature using the counter id from 1
  7. VertexCreator in either mode "Add point" (add to end of edge) or "Insert point at index" = 0 (add to start of edge)

I tried to comprehend your possibility. I don't understand point 2, how can I decide which coordinates are interesting for me? The end of the edge without a node attached is not alway at the beginning or the end...

 

 


Forum|alt.badge.img
  • Author
  • April 10, 2018

A good hint would be also: How can I get the end-coordinates of the edge where the node is missing?


david_r
Evangelist
  • April 10, 2018
nindalf wrote:
I tried to comprehend your possibility. I don't understand point 2, how can I decide which coordinates are interesting for me? The end of the edge without a node attached is not alway at the beginning or the end...

 

 

Indeed, that decision isn't covered above. You'll need to work that out first.

 

One option could be to use NeighborFinder on the start and end vertex (separately) to decide which one is closest to the anchor.

david_r
Evangelist
  • April 10, 2018
nindalf wrote:

A good hint would be also: How can I get the end-coordinates of the edge where the node is missing?

You could extract the start and end points from each edge and e.g. use a PointOnPointOverlayer to detect which edge point isn't situated on a node.

 

 


Forum|alt.badge.img
  • Author
  • April 10, 2018
david_r wrote:
You could extract the start and end points from each edge and e.g. use a PointOnPointOverlayer to detect which edge point isn't situated on a node.

 

 

Would it be possible to get a example how to solve it this way. Unfortunately I can't find a solution to get the edge whit the information of the end without a node. Thank you very much for your help.

 

 


david_r
Evangelist
  • April 10, 2018
nindalf wrote:
Would it be possible to get a example how to solve it this way. Unfortunately I can't find a solution to get the edge whit the information of the end without a node. Thank you very much for your help.

 

 

If you could post a small sample dataset, that would be helpful.

jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • April 10, 2018

You could also make a comment on this idea: https://knowledge.safe.com/idea/20248/snapper-basecandidate-snapping-types.html

 

 

It is tagged as released, but I don't feel that the segment snapping mode captures the idea correctly, and would solve the exact situation you are dealing with.

Reply


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