通过KM搜索附近的Lat / Long查询半径

时间:2015-03-23 14:41:01

标签: php mysql

我正在使用此查询来搜索圈区中的点

SET @center = GeomFromText('POINT(10 10)'); 
SET @radius = 30; 
SET @bbox = CONCAT('POLYGON((', 
    X(@center) - @radius, ' ', Y(@center) - @radius, ',', 
    X(@center) + @radius, ' ', Y(@center) - @radius, ',', 
    X(@center) + @radius, ' ', Y(@center) + @radius, ',', 
    X(@center) - @radius, ' ', Y(@center) + @radius, ',', 
    X(@center) - @radius, ' ', Y(@center) - @radius, '))' 
); 
SELECT name, AsText(location) 
FROM Points 
WHERE Intersects( location, GeomFromText(@bbox) ) 
AND SQRT(POW( ABS( X(location) - X(@center)), 2) + 
         POW( ABS(Y(location) - Y(@center)), 2 )) < @radius;

我从KM获取用户的半径,因此我想将其转换为在查询中使用它

0 个答案:

没有答案