数据量大的话,普通的按距离一个个查找肯定不行,现在查到好像有空间索引之类的东西,不知道如何使用。。有人知道吗?

解决方案 »

  1.   

    mysql> create table tpoint(id int primary key, pt point not null) engine=Myisam;
    Query OK, 0 rows affected (0.09 sec)mysql> insert into tpoint values(1, point(2, 3));
    Query OK, 1 row affected (0.02 sec)mysql> insert into tpoint values(2, point(2, 3.5));
    Query OK, 1 row affected (0.00 sec)mysql> insert into tpoint values(3, point(4.0, 0.5));
    Query OK, 1 row affected (0.00 sec)mysql> create spatial index sp_idx_tpoint on tpoint(pt);
    Query OK, 3 rows affected (0.13 sec)
    Records: 3  Duplicates: 0  Warnings: 0mysql> select id, pt from tpoint where 2 >= distance(pt, point(2, 2.9));
    ERROR 1305 (42000): FUNCTION foo.distance does not exist
    我要说明的是mysql5.x版本似乎没有安全实现OpenGIS中规定的标准函数
    像Distance()和Related()这两个函数就没有实现。
    你得想办法的找到替代函数。
      

  2.   

    知道坐标 计算球面的弧长  三角函数计算可以计算出其距离  这样的话 你写一个函数计算每个坐标点到你坐标点的距离 排序后你想取几条记录都行  
    具体代码:http://blog.csdn.net/ecdyf1989/article/details/8077943