我正在处理 MySQL 地理查询。
因此,按照本教程:http ://howto-use-mysql-spatial-ext.blogspot.it/2007/11/using-circular-area-selection.html
我已经实现了这个查询,它找到了与指定点有特定距离的所有点:
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;
它似乎工作正常。
我的疑问是:@radius的度量单位是什么?是公里还是什么?
在此示例中, @radius的值设置为30。但究竟是什么代表了这个价值呢?