I'm writing a query that needs to be able to work with data of any SRID. The basic problem is very simple - I get two pieces of information:
- A point (SRID = 900913)
- A distance (unit = meters)
I [would like to] transform these into the native SRID, and then run a query to find features within the given distance of the point:
proj_point = ST_Transform(point, (SELECT ST_SRID(geom) FROM table LIMIT 1)); proj_dist = Something... But what? SELECT * FROM table WHERE ST_Distance(geom, proj_point) < proj_dist ORDER BY geom <-> proj_point LIMIT 10;
My problem is the conversion of the units. I can look up the SRID of the native data and transform the point no problem. But how do I do the same with the distance?
I've seen answers to related questions, but they have all involved reprojecting the queried data. Holy overkill! This should be doable with a single lookup and multiplication...
Pointers, anyone? Thanks very much in advance!