Search code examples
graph-algorithmzipcodeproximity

How do I do real time search for results based on driving distance?


I have a database of events (in the UK) and their postcodes (zip codes).

The user will enter their postcode into the webpage and hit enter, some awesome algorithm/system will subsequently return a list of events within x miles driving distance of the user's postcode.

Is this possible in real-time?

The solutions I've considered are:

  • Caching all distances between postcode areas (4100 of them) and using that. Imperfect because postcode areas are a few miles square, but OK for now. The biggest issue is that I'd need approx 8403000 journey distances, and Google Maps has usage restrictions and Map Quest's API is slow, imperfect for looking up postcodes, and I don't want to perform a DOS attack on it.

  • Caching all distances between event postcodes and my list of postcode areas. Still imperfect because there will be 1000s of events and it will take too long to look up distances when adding an event.

  • Limit the amount of journey caching to postcodes within 100 or 200 miles as the crow flies. I've not investigated this, but given the size of the UK it could cut down the total number of journey's required per event by 1/2 or even 2/3... which is better, but will still take too long to lookup when adding an event.

  • Store some sort of graph of postcode locations with journey distances to next postcode area, and use something like A* to search on the fly for close postcodes. The problem with this is that I don't have the time/availability to implement and host a system like this.

Are there better solutions? Have I missed something obvious?


EDIT: MapQuest appears to support driving distance search using custom POI data sets.

Not a duplicate of proximity search as I want driving distance proximity, not latitude/longitude proximity.


Solution

  • As I've added in as an edit:

    MapQuest appears to support driving distance search using custom POI data sets.

    Unfortunately, as was bound to happen, due to the data limits on MapQuest the customer has decided to use a less interesting solution!