Question

first time here so I'll try to be precise and detailed.

I'm working on a project where users will be able to sort local attractions by driving distance. The starting point will be their home address, the ending point will be one of the (many) attractions stored on the database: a lake, a park, a shop, a museum and so on.

A registered user needs to specify his/her address and the site will run a server-side script that will slowly find the distances between that address and the stored attractions.

The driving distance calculation is automatically triggered when:

1) a new user registers to the website

or

2) a new attraction is added to the database

Let's say I have 400 attractions and 1500 users. If I add a new attraction, the website will fetch the distance 1500 times (one per user). And if I add a new user, the website will do the same job for 400 times (one per attraction).

I am currently working with Goolge API's and they're pretty good. The only problem is... I've got a maximum of 2500 queries per day. So if I add 2 new attractions (that will require a total of 3000 distances) I am locked out until the next day.

In a bigger scenario, the driving distances can be quite long to retrieve. If I have 5000 registered users, whenever I add a new attraction I must fetch 5000 distances. That would take 2 days.

What could be a better approach? I was evaluating the Google Business API too (10.000$/year) but that would work for huge realities only, with good cash ad their disposal.

Was it helpful?

Solution

Why do you want to do it from the server side? Directions requests count against the IP address (2500 queries per day per IP), so you could do just a handful of requests in the background every time a visitor comes to the site and they would count against the visitor's IP, not the server's. You just need to be good with AJAX. ;-)

OTHER TIPS

Use the straight line instead. Don't use driving distances. Or store them in the database and use a spatial index.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top