【问题标题】:Not able to retrive all points using mysql point type query无法使用 mysql 点类型查询检索所有点
【发布时间】:2013-10-29 13:01:18
【问题描述】:

我在 mysql 中使用空间数据类型点时遇到问题。我在 mysql 中有一张名为“tasks”的表,我在其中存储以下信息。

Id Int(11) 主键 名称 Varchar(50) 瓦查街(50) 瓦查尔市(50) 瓦查省(50) 乡村瓦查(50) 纬度小数(15,12) 长小数(15,12) 经纬点

以下是示例数据。

  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);

我们在 iPhone 中有一个应用程序,它向我发送了 2 个不同的 lat、lng 值,我们需要传递介于该 lat、long 之间的所有位置。 例如。它们传递了 2 个 lat,lng 值,我需要导出它之间的所有位置。 A点:22.327847、73.172894 B点:22.272259、73.227825

附上谷歌地图的屏幕截图。

现在用于获取我正在编写的以下查询的数据。

     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  

我无法获得给定点 A 和点 B 之间的所有点。我可以看到我存储的点在这些点之间,但无法获得所有值。我在结果中只得到一个值。我的查询有什么问题还是我应用了错误的逻辑?

有人可以帮我吗?

【问题讨论】:

    标签: php mysql spatial-query


    【解决方案1】:

    根据doc,我将你的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  
    

    希望对您有所帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-08
      • 2021-10-11
      • 1970-01-01
      • 2014-06-28
      • 1970-01-01
      • 1970-01-01
      • 2023-02-18
      • 2023-03-24
      相关资源
      最近更新 更多