Hi comleted your workspace.But have some remarks and questions, mainly related to the bojects on the nodes.Do you want those related to the lines?
In the workspace i relate only the objects between the nodes.You can easily have the ones on teh nodes relaed in the first bit (where is exclude them from the process).
Of course Neighbourfinder approach yields result.
I always try to avoid to have to guess what the search range would have to be.IF you just set a huge range or for instance the Diameter of the data bounding box, the neighborfinder has a lot of work to do (and consequently consumes time and memory).
I prefer to do away with that.( in fact I have build a iterative neighbourfinder years ago to prevent useless searches)
I just avoid its use when not necessary.
Also I thought you would appreciate the fact that there are "many ways to kill a cat".
Certainly in the question bytrentanderinits is totally not necessary.As the points, as he stated are actually on the line.You could even solve that one by setting measures.
Also I wish safe would one day fix the spatialrelator.
You can use two Snippers to create start and end nodes of the line, and find points closest to those nodes separately with two NeighborFinders.This is a mock-up.
If you need to preserve the original line geometry, you can use a GeometryExtractor before the Snipper to store the geometry as an attribute and use a GeometyReplacer after the FeatureMerger to restore the geometry from the attribute.
Here is a workspace to do it.No searching for anything.Just topo and nodenumbers.
When points are always on lines you can simply use a
Topology builder on the (poly)lines which gives you the begin and end point the (poly)lines( node output).
Then (for instance) a pointonpoint overlayer with the points.(PoP has a tolerance setting in case there is any accuracy problem)
As you don't know the distance to set for the neighbor finder (you might end up having to search half the map), I would suggest a different approach.
1) If you have a large amount of objects:
I would start to tile the data set by a percentage of the boundingboxes ( scale 2x or maybe larger) of the lines.
Then Relate all objects in each b-box, lines and points.(spatialrelator)
2) Merge lines and points grouped by b-boxes.
Extract end and startpoint of line (index 0 and -1 with coordinate extractor).Extract coord of points.Name attributes appropriately.
simple lengthcalculation for start and end to point.
( you know..for end E to point P for instance
@sqrt(@pow( E_x - P_x,2) @pow(E_y-P_y,2))
)
If you do this conditional using attribute creator you can simultaneously test which is shortest and set it to a "distance" attribute.
Then Sort by LineID and "distance" attribute, ascending.
Sample by LineID, 1, first n features.
@erik_jan.Hi there, i have the same problem as the question but can't seem to get your anwser to work, i have many line objects and many point objects that sit on these lines.I want to be able to output a csv file that contains all details of the line with two extra columns that 1.contains the closest point object to the start vertex of the line and 2.contains the closest point object to the end vertex of the line.I have had a play with your answer above but had no luck, is there any way of providing an example workbench to view on how it is structured?
Use the CoordinateExtractor (index 0 for start and index -1 for end) to extract the start and end coordinates.
Use the 2DPointReplacer to replace the line using start coordinates.
Use the NeighborFinder to find closest point to start.
Repeat last two steps for end coordinates.