hi, 
thanks, but the problem is still there, the time Distance() query is taking. 
the concept behind using within() is only to minimize the number of time the 
distance function executes. it works ok without using within() also, but the 
time is still much longer. is there any way to minimize the time it is taking 
to perform distance(), or any other way to do the same task without using 
distance().
regards.


----- Original Message ----
From: Andy Anderson <[EMAIL PROTECTED]>
To: PostGIS Users Discussion <[email protected]>
Sent: Tuesday, May 20, 2008 10:09:27 PM
Subject: Re: [postgis-users] extent of properties within a specified distance


On May 19, 2008, at 5:01 AM, User Map wrote:
hi,
thanks for reply. i think i have to clarify my problem a bit more. i want to 
get the records from my table within a specified distance for e.g 50 meters. 
For this i have to calculate the extent first to get the image in mapserver. 
what i have is just a polygon geom, which area as you know can vary from 
property to property. i dont want to take into account the area/distance the 
property holds, but a center point for that polygon, so to calculate the 
distance equally on each side of that point, and then calculate the extent of 
those records, for the image to be generated. what i have done uptil now is:
SELECT extent(geom),max(Distance('<center of polygon>',geom))as distance
from tarea
where within(geom,'<expand(geom,50)from the given geom>')
and Distance('<center of polygon>',geom)<=50
but this query is taking about 25-26 mins which is quite a large time span. and 
also when i get the results and on showing through the map server, the scale 
bar is not matching, i mean it has to show a 100 meter bar scale, but, it is 
showing more then 100 meters on the scalebar, about 192 or so.

A couple of thoughts, upon which the more experienced may correct or elaborate:

1) It looks to me like you are performing a duplicate calculation. I'm not sure 
if Postgres is smart enough to avoid this by itself, but just in case you 
should take advantage of a subexpression to perform the calculation once for 
each geom:

SELECT extent(geom), distance from (SELECT geom, Distance('<center of 
polygon>', geom)) from tarea) as tdistance where distance <= 50.

2) Seems like

within(geom,'<expand(geom,50)from the given geom>')

is unnecessary, it will always be true. Or do you mean something different than 
the simpler form:

within(geom, expand(geom,50))

-- Andy



      
_______________________________________________
postgis-users mailing list
[email protected]
http://postgis.refractions.net/mailman/listinfo/postgis-users

Reply via email to