Skip to main content

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?

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


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


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

as God eh?


Reply