Hacker News new | ask | show | jobs
by lutusp 4807 days ago
That would be very difficult, and couldn't be made deterministic with a typical ZIP code database. The reason is most ZIP code databases list a geological position representing a location within the zone, but not its perimeter or geological extent. Therefore, converting from a geological position to a ZIP code would be a guessing game.

Here's a typical ZIP code database entry:

"74857","Newalla","OK","35.351612","-97.19507","-6","1"

The fields are ZIP code, place name, state, latitude ("-" = south), longitude ("-" = west), time zone, location honors daylight time. So no size or shape for the zone itself, only a location within the zone.

An algorithm might find the geographically nearest ZIP code position for a given argument position and return that result, but it would likely be wrong in many situations where there are a lot of ZIP codes, like urban areas.

1 comments

that's actually good enough for my purposes :-) (I'm looking to get a zip code from the browser and then show stores, for example, in a 50 mile radius). 2 adjacent zip codes would still be around 50 miles from the store.