From: | "Sykora, Dale" <Dale(dot)Sykora(at)COMPAQ(dot)com> |
---|---|
To: | <postgresql(at)fruru(dot)com>, "Milo Hyson" <milo(at)cyberlifelabs(dot)com> |
Cc: | <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Postal code radius searches |
Date: | 2002-02-06 20:30:48 |
Message-ID: | E7BC9AA1C77D634D8255A878AB49B09D02330EA1@cceexc19.americas.cpqcorp.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
You could expand on this solution by including points where x&y are +&-
.707*r and calulating points between .707r and r. Basically draw a
square inside the radius circle and outside it. Points between these
squares need calculating, points withing both squares do not. This will
change slightly as x & y are not linear so you are dealing with
rectangles/ellipses instead of circle/squares.
> -----Original Message-----
> From: postgresql(at)fruru(dot)com [mailto:postgresql(at)fruru(dot)com]
> Sent: Wednesday, February 06, 2002 1:30 PM
> To: Milo Hyson
> Cc: pgsql-general(at)postgresql(dot)org
> Subject: Re: [GENERAL] Postal code radius searches
>
>
> On Wed, 6 Feb 2002, Milo Hyson wrote:
>
> > figure out a fast way to locate all of the postal codes
> within an arbitrary
> > radius of another postal code.
>
> perhaps a "refined" brute force is ok :
>
> 1. take the point you want to calculate distances around
>
> 2. calculate the maximum and minimum latitude/longitude so
> that a city can
> be nearer than your distance limit (equivalent to going x km/mi north,
> south, east and west)
>
> 3. do a brute force search but limit yourself to the "square"
> (it's not
> really square ;-) around your starting point.
>
> If the distances are normally small, this should be able to
> use indexes on
> the coordinates and probably be a lot faster already.
>
> Hope this helps,
> Tycho
>
> --
> Tycho Fruru tycho(dot)fruru(at)conostix(dot)com
>
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to
> majordomo(at)postgresql(dot)org
>
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2002-02-06 20:50:27 | Re: Indexs and prolems with. |
Previous Message | mlw | 2002-02-06 20:15:55 | Re: [GENERAL] PostgreSQL v7.2 Final Release |