I am stuck with problem using spatial data type point in mysql. I have one table called 'tasks' in mysql where I am storing following information.
Id Int(11) Primary key Name Varchar(50) Street Varchar(50) City Varchar(50) Province Varchar(50) Country Varchar(50) Lat decimal(15,12) Long decimal(15,12) latLong point
And following are sample data.
INSERT INTO `tasks`
(`id`, `name`, `street `, `city`, `province`, `postalCode`, `lat`, `lng`, `latLong`) VALUES
(202, 'task1', ' sursagar ', 'vadodara', 'Gujarat', 'India', 22.301887300000, 73.205468800000, 0x0000000001010000006288d349364e5240cfbf5df6eb4c3640),
(203, 'task2', ' madvi ', 'vadodara', 'Gujarat', 'India', 22.302665500000, 73.204284700000, 0x000000000101000000af642200134d5240a320787c7b4d3640),
(204, 'task3', 'panigat ', 'vadodara', 'Gujarat', 'India', 22.300475500000, 73.222063499999, 0x00000000010100000047e7fc14c74d5240795be9b5d94c3640),
(229, 'taks4', 'Akota Stadium Road', 'Vadodara', 'Gujarat', 'India', 22.297802300000, 73.166531300000, 0x000000000101000000aad0e572a84a5240702c83c53c4c3640);
We have an application in iPhone which sends me 2 distinct lat, lng values and we need to pass all the places coming between that lat,long. For eg. They are passing following 2 lat,lng values and I need to derive all the places coming between it. Point A : 22.327847, 73.172894 Point B : 22.272259, 73.227825
Attached screen shot of google maps for the same.
Now for fetching the data I am writing following query.
SELECT `task`.*
FROM `tasks` AS `task`
WHERE `task`.`isDeleted` = '0'
AND MBRContains(GeomFromText('Polygon((73.172894 22.327847), (73.227825 22.272259))'),latLong)
ORDER BY task.created DESC
I am not able to get all points between given point A and point B. I can see my stored points are between this points but not able to get the all values. I am getting only one value in result. what is wrong with my query or am I applying wrong logic?
can anyone help me in this?