K最近邻居和MySql地理索引 [英] K-Nearest Neighbors and MySql Geographical Index

查看:73
本文介绍了K最近邻居和MySql地理索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在mySql数据库中有一组带有地理标签的图片.您可以将我的图片"表视为:

I have a set of geo-tagged pictures in mySql database. You can consider my Pictures table to be:

create table `Pictures` (

location Point NOT NULL, 
timeCreated timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,

SPATIAL INDEX(location)

)ENGINE= MyISAM DEFAULT CHARSET=utf8;

我打算根据图片的位置执行K最近邻算法.假设,如果K = 10,则选择地理上最接近用户位置的10张图片.

I intend to perform a K-Nearest Neighbor algorithm based on the location of the pictures. Say, if K=10, select the 10 pictures which are geographically closest to the user location.

感谢您的建议.

推荐答案

看看下面的链接.我相信它可以通过仅使用MySQL查询来解决您遇到的相同问题(如果您的问题是找到与用户位置最近的10张图片).

Have a look to the link below. I believe it addresses the same problem that you have by solely using MySQL queries (if your problem is to find the 10 nearest pictures to users location).

MySQL大圆距离(Haversine公式)

我希望这可以帮助您解决问题.

I hope that this can help you solve your problem.

这篇关于K最近邻居和MySql地理索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆