Menu

Post image 1
Post image 2
1 / 2
0

When zippopotam.us 404s on a real US ZIP: building a 4-tier geocoding fallback

DEV Community·GasPriceCheck·19 days ago
#NVLZdp5N
Reading 0:00
15s threshold

ZIP-to-lat/lng feels like a solved problem. There are something like 41,000 active US ZIP codes. They're a public dataset. They're geocoded. Multiple free APIs serve them. You wire one up, it works, you ship. That's what I thought. Then a user reported that the gas station on his block was showing as "8,247 miles away." Quick context: I run a gas price finder side project. When you enter a ZIP, the site looks up that ZIP's lat/lng, then sorts nearby gas stations by driving distance. If the ZIP's lat/lng resolves to (0, 0), the Haversine math returns absurd distances because (0, 0) is in the middle of the Atlantic Ocean off the coast of Africa. The user's ZIP was 75072. McKinney, Texas. Population 200,000. Not some obscure rural P.O. box. A real ZIP code with a real population center. My geocoder was returning (0, 0).…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More