dtpfia3334 2013-10-21 06:36
浏览 30

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

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.

enter image description here

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?

  • 写回答

1条回答 默认 最新

  • dtll2016 2013-10-26 10:37
    关注

    According to the doc, I changed your Polygon parameters as follows

     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!

    评论

报告相同问题?

悬赏问题

  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建