I am working on a MySQL geographical query.
So, following this tutorial: http://howto-use-mysql-spatial-ext.blogspot.it/2007/11/using-circular-area-selection.html
I have implemented this query that finds all the points having a specific distance from a specified point:
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, '))'
);
By this code I am defining the center point and the radious.
Finnally I perform the query that finds all the points having the distance reprensented by the radius from this setted center point:
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;
It seems to works fine.
My doubt is: what is the units of measure of the @radius? Are km or what?
In this example @radius is setted with the value of 30. But what exactly represent this value?