Hi.
If u want to find the distance between all the points, a cartesian product, you need to link em all.
from the points make a connection to a AttributeRenamers, have one renamed to name_new.
Ectract coordinates, on to Start_somename and the other to End_.
Now merge these trough a featuremerger, they should have a common attribute as the emerge from the same set of points (else create one rior to sending them to the merger). Use processduplicates adn explode the "Complete" output.
You can also use the store Unconditional merger if u prefer.
Now test for name=name_new, no need to find distance between a point and itself...
After this
a 2DPointreplacer (now a Vertexcreator) and the Start_
then a 2DPointAdder (Vertexcreator) on the End_.
Calculate Length.
Now you have all distances.
If the distances need to be within certain polygons, or along a certain roadline, you need to build in restriction for that.
a pic
Hi,
Another approach. Although this may sound strange, the NeighborFinder can be also used to find the farthest neighbor for every point.
Send the all points to the Candidate port of the NeighborFinder; specify enough large value to Maximum Distance parameter; set Close Candidate List Name parameter. You can then get the farthest neighbor for every point (ListIndexer), and also select the one having the longest distance in the dataset (Sorter and Sampler).
each gray line indicates the relation between a point and its farthest neighbor.
the red line indicates the longest one among them.
In FME 2014+, the list elements will be sorted by distance ascending automatically. If you are using FME 2013 or earlier, use the ListSorter to sort the list elements by distance before the ListIndexer.
If an appropriate value to be used as Maximum Distance parameter is unknown, the diagonal length of the bounding box containing all the points can be used. Use BoundingBoxAccumulator, BoundsExtractor, ExpressionEvaluator (calculate the diagonal length), FeatureMerger (merge the diagonal length attribute to every point unconditionally), for example.
For the NeighborFinder in FME 2014 (no SP), you cannot specify an attribute to Maximum Distance parameter when you don't use the Base port. It was a bug, and has been fixed already in FME 2014 SP1+.
Takashi
Thank you both so much for your replies. After having tested both approaches, I have so fat settled for another approach that kind of materialized out of an amalgamation of the two suggestions.
Takashi picked up on my understated need to find the longest distance as well as all other distances (sorry for not being clear on that point in my above formulation), so that seemed like the most promising solution. However, it gets cumbersome because of the large amounts of data.
What I ended up doing (testing it now) is to do a GeometryExtractor with a count on all individual polygons that originally go into the workbench. Then I extract the vertices and send them through an ExpressionEvaluator to find the distances between all points (@sqrt(@pow(@Value(_x),2))+@pow(@Value(_y),2)). Then I sort these and send them through a StatisticsCalculator on the _result variable from the evaluator and do a rather complex TestFilter on the _result variable.
The resulting points' coordinates are being sent as a call to an API via an HTTPFetcher to get real life data on road nodes. This seems like the best solution so far.
Thank you both very much for your comments. They were very helpful in figuring out the best solution.
Chris
Hi Chris,
Good to hear that you got the solution.
I understood your approach. I think that would be efficient. Thanks for sharing.
Just a tip. You can also use @hypot function to calculate distance. Although efficiency may not change, the expression becomes simpler. i.e. understandability and maintainability may be increased.
FYI.
Takashi
@takashi
I need to calculate the distance from each point feature in a point dataset to each polygon feature in another dataset. Like you recommended in here, I've used the neighbourfinder with the maximum distance set in such a way that it will include all the features involved.
I also set the number of neighbours to find to the amount of polygon features I have.
I set the list name.
After that I used a list exploder to get a list of all the distances. That seems to do the job. However, how do I know transpose the list?
I get a table with the amount of records equal to the number of point features multiplied by the numer of polygon features. I want a table with the same amount of records as the point featurues, and added to it the distance to each polygon feature in separate columns, preferable with the new columns automatically named after an "id attribute" in the polygon dataset.
How do I do that? Or maybe there's another transformer that does the trick?