Skip to content

Instantly share code, notes, and snippets.

@tiensonqin
Created November 26, 2013 04:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tiensonqin/7653639 to your computer and use it in GitHub Desktop.
Save tiensonqin/7653639 to your computer and use it in GitHub Desktop.
SET @center = GeomFromText('POINT(34 110)');
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 AsText(point)
FROM exhibition_data
WHERE Intersects( point, GeomFromText(@bbox) )
AND SQRT(POW( ABS( X(point) - X(@center)), 2) + POW( ABS(Y(point) - Y(@center)), 2 )) < @radius;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment