Skip to main content
Question

Snapping end points to segments


jdh
Contributor
Forum|alt.badge.img+28
  • Contributor

I have a use case that is not covered under the three snapping modes available in the anchoredSnapper.

My candidates are a set of lines, the anchors can be either lines or polygons, but for this discussion will be polygons.

The lines need to have their end points (and only their endpoints) snapped to the nearest polygon segment. The rest of the vertices of the line should remain untouched.

 

Currently I am developing the following workflow:

Create a unique id for the lines.

Extract the end points of the candidate lines, send them to an anchoredSnapper with the polygons as the anchor, use snapping type Segment.

Take the original lines and send them to a second AnchoredSnapper with the points as anchors and snapping type End Point, grouped by unique id.

 

Is there a better solution I'm overlooking?

4 replies

drc43
Contributor
Forum|alt.badge.img+11
  • Contributor
  • October 6, 2021

I don't know if this is a better solution, but I think you could run your lines and polygons through a NeighborFinder transformer, then use the output _closest_candidate coordinates to create a point which you could then use as the anchor in an AnchoredSnapper with your lines.


jdh
Contributor
Forum|alt.badge.img+28
  • Author
  • Contributor
  • October 6, 2021
drc43 wrote:

I don't know if this is a better solution, but I think you could run your lines and polygons through a NeighborFinder transformer, then use the output _closest_candidate coordinates to create a point which you could then use as the anchor in an AnchoredSnapper with your lines.

I did consider that, but there are edge cases where the line passes closer to the polygon somewhere in the middle rather than near the end points. So the closest candidate XY corresponds to a base XY that is not the end point(s).


Forum|alt.badge.img+2
  • October 8, 2021

@jdh​ I think the approach you proposed is probably as god as it gets.


jdh
Contributor
Forum|alt.badge.img+28
  • Author
  • Contributor
  • October 8, 2021
markatsafe wrote:

@jdh​ I think the approach you proposed is probably as god as it gets.

as God eh?


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