OpenMap-java / openmap

OpenMap is an Open Source JavaBeans-based programmer's toolkit. Using OpenMap, you can quickly build applications and applets that access data from legacy databases and applications.
http://openmap-java.org
Other
73 stars 43 forks source link

Possible wrong computation? #27

Open jx5c opened 8 years ago

jx5c commented 8 years ago

in QuadTreeRect.java file,

    double dx = ewdistance * ewdistance;
    double dy = nsdistance * nsdistance;
    double distanceSqr = dx * dx + dy * dy;
    return distanceSqr;

should the distanceSqr be dx+dy?

dfdietrick commented 8 years ago

No, that's what the method is supposed to return. Note the javadoc comments on the algorithm, the distance squared is used consistently throughout. Are you seeing unusual results in how the quad tree is functioning?

jx5c commented 8 years ago

I did not see unusual results. I wanted to find some open-source Geographic applications for research purposes, and came across yours. I am reading and analyzing the source code.

For this part, what I am thinking is that

   dx = ewdistance * ewdistance 
   dy = nsdistance * nsdistance;

seem already squared, why do we have dx*dx?

   distanceSqr = dx * dx + dy * dy;  

will make distanceSqr = ewdistance^4 + nsdistance^4. That seems different from the code in the old borderDistance function.

Jian