Reputation: 677
I am building a taxi dispatching app
first: I need the passenger app to show the nearest taxis, now I know how to do that in code but in my way I have to go through all the taxis locations(in database on server) and calculate the distance from the passenger location and get the lowest ones - I don't want to do this because there will be a lot of taxis and going through all of them and making some math is kind of pain on the server- is there a way to get the nearest ones without going through all of them?
second: what the best database to use - first, should it be sql or non-sql - I need a very robust database, because there will be a lot of updates (I mean the passengers locations added then deleted when arriving to destination && the taxis location changes frequently)
finally: I will use RubyOnRails to do the server side and json as data transfer format, do you have a recommendation to me on something better?
Thanks
Upvotes: 1
Views: 607
Reputation: 5552
Calculating distances takes time because of the complex equations involved.
Instead, try to do a more simplistic "fake distance" calculations.
For example, instead of d = SQRT (x*x + y*y) for your purpose you may try something like d = |x| + |y| and sort for that. You don;t need the exact formula here because a rough approximation would do.
Upvotes: 1
Reputation: 1212
Try this link It will show you all the nearest places like Hotels,theatres,etc.. it will show the address of the particular place in list and also it will show in map view..
Hope this will be helpfull for you.
Upvotes: 0
Reputation: 766
For first: Use you need to calculate nearest distance. But instead of comparing with all taxi location i recommend you to pass lat long of passenger.
On server maintain taxi location in lat long. Write query to get taxi's with in +/- 3 of lat long. This will get limited no of taxi's available near passenger area.
For sencond: = Use Relational database, SQL Server is good for such applications I have used in my last projects.
For server: I don't have idea of RubyOnRails but this is also faster & easy to implements as they says.. , you have choose the best data exchange format Json no need to change this; you can use zip to improve performance.
Upvotes: 0
Reputation: 567
For the first question: I think you can send from the mobile device a radio (ie: /43.34343/-3.3333/1000 and 1000 represents the radio in meters), and from the server return only the taxis included on this area. You can do that calculating the distance between the device location, and the list of the Taxis.
Upvotes: 0