I am so confuse and so tired to goggling to find above trick. Actually i have a database table that have six fields id, Sratlatitude, Startlongitude, EndLatitude, EndLongitude and username. Now i want to query in the database like
SELECT * FROM LOCATIONS(table name) WHERE USERS BETWEEN STARTING POINT(InputedStartlatitude and InputedStartlongitude) AND ENDING POINT(InputedEndlatitude and InputedEndlongitude);For example : USERXXX inputted starting point(InputedStartlatitude = 18.9647 and InputedStartlongitude = 72.8258) = Mumbai and Ending point(InputedEndlatitude = 18.9647 and InputedEndlongitude = 72.8258) = Delhi. Now he want to search how many USERS between this Inputted route(Driving Direction) using Inutedlatitudes and Inputedlongitudes. Search query will fire to the mysql database and compare from the stored starting and ending latitude and longitude which are between Mumbai to Delhi.
I have found one solution for this Like making query to the database as :
SELECT * FROM lOCATIONS(tablename) WHERE (InputStartLatitude >= StartLatitude and IntartLongitude >= StartLong) and (InputEndLatitude <= EndLatitude and InuteEndLongitude <= EndLongitude);
But i have faced some problem with above query. Below are the coordinates of some places. Please have look :
The starting and ending co-ordinates are in RED color. Starting position is : Porbandar and Ending is : Mumbai. Now problem is that i m facing is when i trying to searching cities between Porbandar to Mumbai then not all cities comes those are actual situated in driving direction because of my query. I have called only those cities in my query how are greater than starting Lat and Long and Less then of Ending Lat and Long. But here Mumbai's Lat and longitude almost less then of all cities. so how can i make proper search query ?
Hope I have explain well above situation.
Any response will be very helpful to me.
I am using php-mysql as back-end and android at client side.