mysql里存储经纬度,如何根据某个经纬度找到最近的几个点 数据量大的话,普通的按距离一个个查找肯定不行,现在查到好像有空间索引之类的东西,不知道如何使用。。有人知道吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 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()这两个函数就没有实现。你得想办法的找到替代函数。 知道坐标 计算球面的弧长 三角函数计算可以计算出其距离 这样的话 你写一个函数计算每个坐标点到你坐标点的距离 排序后你想取几条记录都行 具体代码:http://blog.csdn.net/ecdyf1989/article/details/8077943 为什么用distinct去重后,还会有重复记录 【求助】怎么用cmd开启 mysqld-nt.exe mysql合并数据库问题 如何查询出两张表不同记录! sql 简单问题 请教一SQL语句 马上给分!!!!!!!!!!!!!!!!! 我安装了个MYSQL4.1.9 可是安装完后不知道哪个程序启动啊! mysql可以使用终端登录,但却不能通过php连接是怎么回事? 求助:jsp中使用beans访问mysql数据库问题! 是否是 mysql 数据库的问题 Windows下mysql集群问题?求救! 关于pgAdmin的问题,希望懂postgerSQL的进。。。。。。。。。
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()这两个函数就没有实现。
你得想办法的找到替代函数。
具体代码:http://blog.csdn.net/ecdyf1989/article/details/8077943