Question

How to snapping edges endpoints to node?

  • 10 April 2018
  • 8 replies
  • 11 views

Badge

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

Userlevel 4

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)

Badge

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

 

 

Badge

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

Userlevel 4
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.
Userlevel 4

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.

 

 

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

 

 

Userlevel 4
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.
Badge +22

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