Hi @nickmanolis I'm not sure of what you mean by projecting to a line. Can you attach some sample data and screen shots of a polygon and its vertices (and lines?) and the output you want to get? thanks
I'm assuming the NeighborFinder is doing the 'projecting the point along the line', with the _closest_candidate_x and y. I don't think this needs to be looped, you just need a Group By your Unique ID on the NeighborFinder, so that each input polygon vertex only considers its paired line. You can also use a Chopper to break a polygon into individual vertices, which may be easier.
Mind that NeighborFinder (and AnchoredSnapper) will not project perpendicular when the line is too short: in that case these transformers will project to the start or end of the line.
With some math, using XY of the vertices and XY of the start and end point of the line, you can calculate the projected point on the line or it's extension.
Hi @nickmanolis I'm not sure of what you mean by projecting to a line. Can you attach some sample data and screen shots of a polygon and its vertices (and lines?) and the output you want to get? thanks
Thank you for the reply. I added 2 pictures of an example dataset, as well as the expected results
I think you may need something like this:
The magic happens in the AttributeManager, where the coordinates of the projected point are calculated
xProj = @Evaluate(((@Value(x2)-@Value(x1))*(@Value(x0)-@Value(x1))+(@Value(y2)-@Value(y1))*(@Value(y0)-@Value(y1)))*(@Value(x2)-@Value(x1))/(@pow((@Value(x2)-@Value(x1)),2)+@pow((@Value(y2)-@Value(y1)),2))+@Value(x1))
yProj = @Evaluate(((@Value(x2)-@Value(x1))*(@Value(x0)-@Value(x1))+(@Value(y2)-@Value(y1))*(@Value(y0)-@Value(y1)))*(@Value(y2)-@Value(y1))/(@pow((@Value(x2)-@Value(x1)),2)+@pow((@Value(y2)-@Value(y1)),2))+@Value(y1))
x0,y0 are the coordinates of a vertex of a polygon, x1,y1 and x2,y2 are the coordinates of the start and end point of the corresponding line.
The attribute manager also shows the calculation of the coordinates of the projected point in several steps, as in http://www.sunshine2k.de/coding/java/PointOnLine/PointOnLine.html#step5