I would like to raise this question again, offering with a new bounty for a solid, good solution. It seems that only the solution (shubha
The essential point of your geometry is that two circles overlap if the distance between their centers is less than the sum of their radii. Since we're doing a comparison, we can use the square of the distance, since that avoids a square root operation. In the original, each radius is fixed at 1, the sum of the two radii is 2, and the square of the sum is 4.
There's a big difference between the original question and the new question. In the first you've got circles of fixed radius and the second you've got circles of varying radius. The constant 4
in the comparison expression [...distance^2...] <= 4
needs to be replaced, since that's an artifact of the fixed radius of the original. To implement this, add the km
field into the query. And as you should check, you weren't using ppl.radius
in the WHERE filter, so it's hardly surprising that varying that value didn't change your query results.
SELECT ppl.latitude, ppl.longitude, ppl.radius
FROM
( people ppl ),
( SELECT latitude, longitude, km FROM radiuses ) AS B
WHERE [...distance^2...] <= POW( ppl.radius + B.km, 2)
I should say that this question took far longer to understand than it should have, because you're calling the entity-that's-not-a-person a "radius", when really you've got a property that ought to be called 'radius' on two different entities. So name that other entity something descriptive.