Re: calculating extent on basis of distance from a given point

From: "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>
To: "User Map" <map(dot)user(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: calculating extent on basis of distance from a given point
Date: 2008-05-21 19:28:15
Message-ID: dcc563d10805211228h5b5d5af2i70de5e363b7e8a40@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, May 15, 2008 at 5:34 AM, User Map <map(dot)user(at)yahoo(dot)com> wrote:
> hi,
> i have OSGB36 data in postgre, srid 27700. what i want to do is to calculate
> the extent on basis of the distance from a given point. i have geom of type
> geometry in the table, from which to calculate extent. i have tried the
> funtions Distance(geom,geom)<50, but it is too slow, as it uses no index. i
> have calculated the point from the polygon by function Centroid(geom), but i
> think its not working properly, as i am also testing it with the mapserver
> map and map saclebar, they are not matching exactly.
> the main isuue is of the time the distance query is taking.
> is there any why to do this quickly.

The usual method is to use a simple bounding box which can be indexed
to reduce the number of comparisons you need to make with the distance
function. I.e. if you've got a radius of 50 to searc withing, set up
a square 100 on a side centered on one of the points, and that with
the distance(x,y) and you should be able to get good performance.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2008-05-21 22:14:44 Re: Fwd: sql_type tinterval not supported by DBD::Pg
Previous Message Scott Marlowe 2008-05-21 19:00:27 Re: migration problem