Here is an example of getting all the zipcodes within a certain radius -

Something I did in SAS but I am sure you can convert the formula into
another language.

http://www.sconsig.com/sastips/tip00156.htm

Chuck Patridge

Charles Patridge
Full Capture Solutions, Inc.
333 Roberts Street, Suite 400
East Hartford, CT 06108
Phone: 860-291-9517 x 106
Email: [EMAIL PROTECTED]
-----Original Message-----
From: Steven Rowe [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 29, 2007 12:37 PM
To: java-user@lucene.apache.org
Subject: Re: Postal Code Radius Search

Mike wrote:
> I've searched the mailing list archives, the web, read the FAQ, etc
and I
> don't see anything relevant so here it goes...
> 
> I'm trying to implement a radius based searching based on zip/postal
codes.

Here is a selection of interesting threads from the Lucene ML with
relevant info:

<http://www.nabble.com/all-records-within-distance----small-index-tf3303
731.html>

<http://www.nabble.com/Hacking-proximity-search%3A-looking-for-feedback-
tf1201416.html>

<http://www.nabble.com/Announcement%3A-Lucene-powering-Monster-job-searc
h-index-%28Beta%29-tf2522646.html>

The standard answer seems to be something like:

1. Index latitude and longitude fields with fixed length
(left-zero-padded) integral values - shift the decimal point to the
right to the desired level of discriminability.  (In your case, convert
the postal codes to lats/longs.)

2. Do a range query on both your lat and your long fields to collect
hits inside a bounding box with your target at the center and with sides
of length double the desired radius.

3. Optionally, sort (and filter) the results by distance from your
target, displaying only those within the desired radius.  If you leave
out this step, you'll get some hits that are outside of the desired
radius - inbetween the bounding circle and the bounding box.

Steve

-- 
Steve Rowe
Center for Natural Language Processing
http://www.cnlp.org/tech/lucene.asp

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to