<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
<div><div><font class="Apple-style-span" color="#000000">On May 19, 2008, at 5:01 AM, User Map wrote:</font></div><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><p class="MsoNormal" style="margin-top: 5pt; margin-right: 0in; margin-bottom: 5pt; margin-left: 0in; "><font class="Apple-style-span" color="#000000">hi,</font></p><p class="MsoNormal" style="margin-top: 5pt; margin-right: 0in; margin-bottom: 5pt; margin-left: 0in; "><font class="Apple-style-span" color="#000000">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:</font></p><p class="MsoNormal" style="margin-top: 5pt; margin-right: 0in; margin-bottom: 5pt; margin-left: 0in; "><font class="Apple-style-span" color="#000000">SELECT extent(geom),max(Distance('<center of polygon>',geom))as distance</font></p><p class="MsoNormal" style="margin-top: 5pt; margin-right: 0in; margin-bottom: 5pt; margin-left: 0in; "><font class="Apple-style-span" color="#000000">from tarea</font></p><p class="MsoNormal" style="margin-top: 5pt; margin-right: 0in; margin-bottom: 5pt; margin-left: 0in; "><font class="Apple-style-span" color="#000000">where within(geom,'<expand(geom,50)from the given geom>')</font></p><p class="MsoNormal" style="margin-top: 5pt; margin-right: 0in; margin-bottom: 5pt; margin-left: 0in; "><font class="Apple-style-span" color="#000000">and Distance('<center of polygon>',geom)<=50</font></p><p class="MsoNormal" style="margin-top: 5pt; margin-right: 0in; margin-bottom: 5pt; margin-left: 0in; "><font class="Apple-style-span" color="#000000">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.</font></p></div></div></div></div></span></blockquote><font class="Apple-style-span" color="#000000"><br></font></div><div><font class="Apple-style-span" color="#000000">A couple of thoughts, upon which the more experienced may correct or elaborate:</font></div><div><br></div><div><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" color="#000000">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:</font></font></div><div><br></div><div><font class="Apple-style-span" color="#000000"><span class="Apple-tab-span" style="white-space:pre">    </span>SELECT extent(geom), distance from (SELECT geom, Distance('<center of polygon>', geom)) from tarea) as tdistance where distance <= 50.</font></div><div><br></div><div><font class="Apple-style-span" color="#000000">2) Seems like</font></div><div><font class="Apple-style-span" color="#000000"><br></font></div><div><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" color="#000000">      </font></span><font class="Apple-style-span" color="#000000">within(geom,'<expand(geom,50)from the given geom>')</font></div><div><font class="Apple-style-span" color="#000000"><br></font></div><div><font class="Apple-style-span" color="#000000">is unnecessary, it will always be true. Or do you mean something different than the simpler form:</font><font class="Apple-style-span" color="#000000"></font></div><div><font class="Apple-style-span" color="#000000"><br></font></div><div><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" color="#000000">      </font></span><font class="Apple-style-span" color="#000000">within(geom, expand(geom,50))</font></div><div><br></div><div>-- Andy</div><div><br></div></body></html>