Php 按公里搜索附近的Lat/Long查询半径

Php 按公里搜索附近的Lat/Long查询半径,php,mysql,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) +

我正在使用此查询搜索圆形区域中的点

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为单位从用户处获取半径,因此我想将其转换为在查询中使用它

这些是笛卡尔坐标,而不是lat/long,对吗?如果它们是lang/long,则需要阅读哈弗森定律或球面余弦定律距离公式。当你说要将公里转换为半径时,你是什么意思?在网站中,我标记了用户的位置,并按公里搜索半径。也许你可以展示一些示例数据。SQRTdx*dx+dy*dy甚至无法作为纬度和经度的距离计算程序正常工作。读这个。