[Zope] searching by miles from __ zip code----updated to: getting list of zip codes in x miles radius

Sean Kelley sean@horse101.com
Thu, 12 Jun 2003 12:23:29 -0700


--------------020402040302000002000504
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Thanks for the thought on this.  I realized that what I really need is a 
return of all of the zip codes within x miles of a zip code.  In other 
words, show me all records (from zcatalog or sql) which match the 
results of a radius search where zip codes in the radius are returned.


Dylan Reinhardt wrote:

>On Thu, 2003-06-12 at 09:29, Dennis Allison wrote:
>  
>
>>You proably should use a spherical earth model to compute distances.
>>    
>>
>
>Depending on your accuracy requirements.  
>
>The way I read the original post, the goal was to constrain search
>results to within some number of miles from a given zip code.
>
>If that's being used for figuring out how much fuel to put on an
>airplane, you're going to want far more accurate figures.  :-)
>
>But if the purpose of this is to get some proxy for driving distance,
>there's no compelling reason to be any more accurate than within a mile
>or so... distance "as the crow flies" is only a bare approximation of
>driving distance anyway.
>
>  
>
>>Database search with a "distance from" key is difficult and requires
>>specialized mechanisms.  
>>    
>>
>
>Depending, again, on how good the results need to be.
>
>Assuming your *best* search would be defined by point p and some radius
>r, you could get results *almost* as good by searching for points
>bounded by p +/- r.  A select consisting of two simple range criteria is
>pretty easy to set up and virtually indistinguishable from *correct*
>results in a decent range of probable applications.
>
>Of course, you *could* use that method as a first pass before performing
>more expensive computation on the results.  But just this one pass might
>be enough to know what things are *about* X miles from some point.
>
>You won't win any comp sci awards for this process, but it's a pragmatic
>solution that's good enough for many cases.  Your mileage may vary. :-)
>
>FWIW,
>
>Dylan
>
>
>
>  
>


--------------020402040302000002000504
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title></title>
</head>
<body>
Thanks for the thought on this. &nbsp;I realized that what I really need is a
return of all of the zip codes within x miles of a zip code. &nbsp;In other words,
show me all records (from zcatalog or sql) which match the results of a radius
search where zip codes in the radius are returned.<br>
<br>
<br>
Dylan Reinhardt wrote:<br>
<blockquote type="cite"
 cite="mid1055442004.2763.46.camel@ida.dylanreinhardt.com">
  <pre wrap="">On Thu, 2003-06-12 at 09:29, Dennis Allison wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap="">You proably should use a spherical earth model to compute distances.
    </pre>
  </blockquote>
  <pre wrap=""><!---->
Depending on your accuracy requirements.  

The way I read the original post, the goal was to constrain search
results to within some number of miles from a given zip code.

If that's being used for figuring out how much fuel to put on an
airplane, you're going to want far more accurate figures.  :-)

But if the purpose of this is to get some proxy for driving distance,
there's no compelling reason to be any more accurate than within a mile
or so... distance "as the crow flies" is only a bare approximation of
driving distance anyway.

  </pre>
  <blockquote type="cite">
    <pre wrap="">Database search with a "distance from" key is difficult and requires
specialized mechanisms.  
    </pre>
  </blockquote>
  <pre wrap=""><!---->
Depending, again, on how good the results need to be.

Assuming your *best* search would be defined by point p and some radius
r, you could get results *almost* as good by searching for points
bounded by p +/- r.  A select consisting of two simple range criteria is
pretty easy to set up and virtually indistinguishable from *correct*
results in a decent range of probable applications.

Of course, you *could* use that method as a first pass before performing
more expensive computation on the results.  But just this one pass might
be enough to know what things are *about* X miles from some point.

You won't win any comp sci awards for this process, but it's a pragmatic
solution that's good enough for many cases.  Your mileage may vary. :-)

FWIW,

Dylan



  </pre>
</blockquote>
<br>
</body>
</html>

--------------020402040302000002000504--