简体   繁体   English

无法使用mysql点类型查询来检索所有点

[英]Not able to retrive all points using mysql point type query

I am stuck with problem using spatial data type point in mysql. 我在mysql中使用空间数据类型点时遇到问题。 I have one table called 'tasks' in mysql where I am storing following information. 我在mysql中有一个名为'tasks'的表,我在其中存储以下信息。

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. 我们在iPhone中有一个应用程序,它向我发送2个不同的lat,lng值,我们需要传递介于该lat之间的所有位置。 For eg. 例如。 They are passing following 2 lat,lng values and I need to derive all the places coming between it. 它们正在传递2个lat,lng值,我需要得出它之间的所有位置。 Point A : 22.327847, 73.172894 Point B : 22.272259, 73.227825 A点:22.327847,73.172894 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. 我无法获得给定点A和点B之间的所有点。我可以看到我的存储点位于这些点之间但不能获得所有值。 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? 任何人都可以帮助我吗?

According to the doc , I changed your Polygon parameters as follows 根据文档 ,我更改了您的Polygon参数如下

 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  

Hope this will help you! 希望对你有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM