[nycphp-talk] Zip code radius
Aaron Fischer
afischer at smith.edu
Fri May 22 16:24:00 EDT 2009
That sounds good, thanks for the link Paul.
-Aaron
On May 22, 2009, at 4:21 PM, Paul Guba wrote:
> Here is what I used:
> http://www.micahcarrick.com/04-19-2005/php-zip-code-range-and-distance-calculation.html
> Paul Guba
> paul at gubavision.com
>
>
>
> On May 22, 2009, at 4:04 PM, Aaron Fischer wrote:
>
>> Great stuff, thanks John!
>>
>> I got my Google API Key and am reading up on geocoding now Never
>> tried something like this before so it looks like I've got some
>> learning to do.
>>
>> -Aaron
>>
>> On May 22, 2009, at 2:36 PM, John Campbell wrote:
>>
>>> I used to do a bit of GIS stuff.
>>>
>>> Here is what you need to do.
>>>
>>> 1) Import a list of zip codes & lat/lng centroids into your
>>> database.
>>> The data is here:
>>> http://www.census.gov/tiger/tms/gazetteer/zips.txt
>>>
>>> 2) Geocode all of your contacts, and store the lat/lng coordinates
>>> with the contacts. Google has a free geocoding service. You need a
>>> google api key, and they only allow 10,000 queries per day per IP.
>>> Depending on how many contacts you have, this may take several
>>> days to
>>> get all of the coordinates.
>>> The docs are here:
>>> http://code.google.com/apis/maps/documentation/geocoding/index.html
>>>
>>> 3) Read up on the Haversine formula.
>>> http://en.wikipedia.org/wiki/Haversine_formula
>>>
>>> Once you have these three pieces, you will be able to calculate the
>>> distance between contacts and any zip code.
>>>
>>> Regards,
>>> John Campbell
>>>
>>>
>>>
>>>
>>> On Fri, May 22, 2009 at 2:09 PM, Aaron Fischer
>>> <afischer at smith.edu> wrote:
>>>> I'd like to build a feature that will allow someone to enter a
>>>> zip and a
>>>> radius and have the page display all the contacts that are within
>>>> the
>>>> specified radius of that location. (I have a db table to query
>>>> that has
>>>> contacts and their address information, including zips.)
>>>>
>>>> Has anyone found a class or code that they like that will do this?
>>>>
>>>> Displaying results on a map would be a sweet bonus but is not
>>>> required.
>>>>
>>>> -Aaron
>>>> _______________________________________________
>>>> New York PHP User Group Community Talk Mailing List
>>>> http://lists.nyphp.org/mailman/listinfo/talk
>>>>
>>>> http://www.nyphp.org/show_participation.php
>>>>
>>> _______________________________________________
>>> New York PHP User Group Community Talk Mailing List
>>> http://lists.nyphp.org/mailman/listinfo/talk
>>>
>>> http://www.nyphp.org/show_participation.php
>>
>> _______________________________________________
>> New York PHP User Group Community Talk Mailing List
>> http://lists.nyphp.org/mailman/listinfo/talk
>>
>> http://www.nyphp.org/show_participation.php
>
> _______________________________________________
> New York PHP User Group Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> http://www.nyphp.org/show_participation.php
More information about the talk
mailing list