On Wed, May 19, 2010 at 2:53 PM, Emilie Laffray <emilie.laff...@gmail.com> wrote: > The page is interesting due to the utmzone function. This will allow to know > what projection to use if you want a good approximation. It return a SRID > that you can use to do a ST_Transform.
Ah, with only the line "Find UTM (WGS84) SRID for a point (in any SRID)" I was not quite sure what it was supposed to do. Thanks for the clarification. > But what you want to do is going to be very painfully slow especially if you > are going to work with geometries other than points, since it means that you > have to reproject the data for each geometries you are going to work with > potentially. Why should that be slow? I´m calculating a projected bounding-box for each element once ahead of time and storing these. When doing the queries I only need to project my query-location to find the few elements where my query-loction is within the bounding-box. Then I transform the few geometries found to compare the distance and sort. The following page will work in any units that you want. > http://www.bostongis.com/PrinterFriendly.aspx?content_name=postgis_nearest_neighbor_generic Only if the reference-point and the bounding-boxes have the same projection and the distance()-function will use that projection to calculate the distance. So this will be highly distorted for WGS84 as 1 meter is not the same distance in lat as it is in lon. So basically back to square one. Finding a good projection. > One other possibility > instead of using a nearest neighbour functionality is to do a search with > ST_DWithin applying a ratio depending on the latitude. That could work. Calculate a WGS4-bounding box with a width and height depending on the loction of the reference-point and select all geometries who intersect it. Could I use utmzone() to calculate a good projection, then project my reference-point to it, create a bounding-box with that SRID of +- N meters, project that back to WGS84 and do the range-query? Then use that SRID in the distance-calculation of the resulting elements that where found to intersect the bounding-box? Marcus _______________________________________________ dev mailing list dev@openstreetmap.org http://lists.openstreetmap.org/listinfo/dev