hej there,
i don't no if i used the nearestNeighbour method of the STRtree wrong
but all i got were the same objects.
I looked at the code and saw something strange.
the method -> private Object[] nearestNeighbour(BoundablePair
initBndPair, double maxDistance) {... (line 328)
had the condition:
if (bndPair.isLeaves()) {
distanceLowerBound = currentDistance;
minPair = bndPair;
}
that means, if your pair are leaves the distanceLowerBound= 0 (!)
because it compares the first leave with itself -
and since its 0 the while-loop breaks because of (currentDistance >=
distanceLowerBound) (0=0).
The result is, you get your lowest distance with 0 and the same objects.
I guess there should be something added, like:
if (bndPair.isLeaves()) {
if(currentDistance > 0) //DON'T SAVE 0-DISTANCES
distanceLowerBound = currentDistance;
minPair = bndPair;
}
This way it doesn't save the 0 distance (Object distance with itself)
and you will get a proper result.
Since the code is quite old, i guess some people used the nearest
neighbour method before - so did i something wrong or was is it a bug?
(btw. is the jts project still alive?)
best regards,
bernd
------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
Jts-topo-suite-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jts-topo-suite-user