1

I have a set of bicycle station and i need to find a way from one point to another, using these bicycles. for example:

  1. User go to a nearby station and pick a bicycle
  2. he goes to another station bicycling
  3. he drops his bicycle here and finish is course on foot

Actually, my android application proceeds like that:

  1. I find the two closest stations of my current position and the two closest to my destination
  2. I calculate four different routes using google api. ( picking one station or another) and choose the best one

to calculate a route, i do three request to google direction, one from my position to a station on foot, one from one station to another on bicycle, and a third from a station to my final destination on foot. that's 3*4=12 request to google api's

Users of the free API

   2500 directions requests per 24 hour period.
   Up to 8 waypoints allowed in each request. Waypoints are not >available for transit directions.
   2 requests per second. 

12 requests is too much for my application, however, google api allows to use waypoints, i would then give the two station and only one request instead of 3, but then, I don't know how to change the mode ( bicyling or walking) between waypoints, is that possible? Or maybe google's api can find the best itinerary for me ( by giving him differents stations), is that possible?

Thanks you :)

Jean Bouvattier
  • 303
  • 3
  • 19

1 Answers1

2

You can do the calculation in 6 routes. This is most easily explained using a diagram:enter image description here

Essentially, there are 8 components common to all the possible routes you plan, which are the two distances to get to either bike station, the four from the various combinations of bike-to-bike, and the final two bike station to end options.

Actually, this can get compressed even further, since the last two routes are dependent on the bike-to-bike, but are not subject to further permutations. Therefore, this can be compressed down to six routes:

start --> A
start --> B
A --> C --> End
A --> D --> End
B --> C --> End
B --> D --> End

If you are not able to use waypoints, you can simply use eight, which would be splitting apart routes like A --> C --> End into A --> C and then C --> End, which would also be used with B --> C --> End.

Of course, the total time is the sum of a starting route and the bike/walking route afterwards, and so on.

When implemented, this will reduce your queries down to 8 (or even 6).

bcdan
  • 1,438
  • 1
  • 12
  • 25