For a given point (x,y), I would like to find all the points in the neighborhood (defined by myRadius, a number, in meters).
For now, I’m using a circle around each point, but some reason, I’d like to draw a square around each point instead of a circle (square in the orientation of x-y coordinates).
Command I use for the circle (distance):
SELECT * FROM table_of_points WHERE (ST_Transform(the_geom,21781) && ST_expand(ST_SetSRID(ST_GeomFromText('Point(x y)'), 21781), myRadius )
For the square, can I use:
SELECT * FROM table_of_points WHERE (ST_Transform(the_geom,21781) && ST_MakeEnvelope(x-myRadius, y-myRadius, x+myRadius, y+myRadius, 21781 ) )
It works, but I’m just wondering if it’s the fastest way of doing this.