Hmm, sounds really easy but seems to be pretty complicated when looking at how to do it.
The NeighborFinder will find the closest candidate for a given base feature but it can match the same candidate.
If you use the NeighborFinder to match ALL candidates to the base features then you will have all the possible pairs. 11>2, 12>2, 12>1 and 12>2 in the example above (you can use the list method to create a list of features and then explode the list to create a feature per pair.
You can sort by distance (matched distance) and use a Sampler to sample the first feature per candidate. This kind of works, but you can end up with duplicate base features (essentially the reverse of the initial problem). This happens when a base feature is closer to two candidates than any other base is.
A loop seems to be the best solution here, when in each loop you match just 1 candidate for each base, take the shortest distance for each matched candidate (sorter + sampler) and then perform another comparison using the unmatched candidates and the duplicated/un sampled base features.
Repeat this until there are no more unsmapled base features of no more unmathced candidates.
Here's an example (You would need to use the 'name' as the Group By) :
Hmm, sounds really easy but seems to be pretty complicated when looking at how to do it.
The NeighborFinder will find the closest candidate for a given base feature but it can match the same candidate.
If you use the NeighborFinder to match ALL candidates to the base features then you will have all the possible pairs. 11>2, 12>2, 12>1 and 12>2 in the example above (you can use the list method to create a list of features and then explode the list to create a feature per pair.
You can sort by distance (matched distance) and use a Sampler to sample the first feature per candidate. This kind of works, but you can end up with duplicate base features (essentially the reverse of the initial problem). This happens when a base feature is closer to two candidates than any other base is.
A loop seems to be the best solution here, when in each loop you match just 1 candidate for each base, take the shortest distance for each matched candidate (sorter + sampler) and then perform another comparison using the unmatched candidates and the duplicated/un sampled base features.
Repeat this until there are no more unsmapled base features of no more unmathced candidates.
Here's an example (You would need to use the 'name' as the Group By) :
It could be there is an easier way though. This seems overly complicated for such a simple sounding problem
Hmm, sounds really easy but seems to be pretty complicated when looking at how to do it.
The NeighborFinder will find the closest candidate for a given base feature but it can match the same candidate.
If you use the NeighborFinder to match ALL candidates to the base features then you will have all the possible pairs. 11>2, 12>2, 12>1 and 12>2 in the example above (you can use the list method to create a list of features and then explode the list to create a feature per pair.
You can sort by distance (matched distance) and use a Sampler to sample the first feature per candidate. This kind of works, but you can end up with duplicate base features (essentially the reverse of the initial problem). This happens when a base feature is closer to two candidates than any other base is.
A loop seems to be the best solution here, when in each loop you match just 1 candidate for each base, take the shortest distance for each matched candidate (sorter + sampler) and then perform another comparison using the unmatched candidates and the duplicated/un sampled base features.
Repeat this until there are no more unsmapled base features of no more unmathced candidates.
Here's an example (You would need to use the 'name' as the Group By) :
Nice job @virtualcitymatt
Unfortunately, this is not as easy as it looks at first sight.
This problem can be solved using the 'Hungarian Algorithm', also known as the 'Munkres Algorithm'.
Some nice implementations of the algorithm in Python as standalone scripts can be found here and here; a Python module can be found here.
So an easy solution may be to let Python do most of the work in FME.
Or you can implement one of the Python solutions in plain FME transformers. Beginning with the NeighborFinder, as @virtualcitymatt suggests, looks to be a promising start.