地理接近搜索 [英] Geo Proximity Search

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

问题描述



我们有一些对象,其中包含了与对象相关的所有对象,包括特定的国家和/或城市使用谷歌地图api预先分割并存储在数据库中的相应经度和纬度。有时这些对象提供的服务具有某些服务范围/范围,他们可以在其中提供服务。

现在情况就像我想找出所有的对象,例如居住在阿姆斯特丹的


应用程序应该找出所有位于的对象在
阿姆斯特丹,也是不完全位于阿姆斯特丹
但在附近,服务范围高达阿姆斯特丹的对象。所以我知道阿姆斯特丹的纬度和经度值由
google map返回,同时还有存储在数据库中的具有相应lat,lng值和
服务范围/ radius的对象。我怎样才能使它成为可能?

解决方案

您应该将国家/城市表示为DB中的多边形,然后使用OpenGIS样式的多边形交集函数来相交。



,MySQL不会 正确实现多边形交集(仅限MBR - 最小边界矩形)。所以这种方法虽然在理论上是正确的,但对于MySQL来说却不适合你。你可以考虑转移到Postgres。你可以做的是使用你的数据库的MBR交叉功能,并用你自己的代码来补充它们,这些代码可以做多边形/点交叉(你可以找到这样做的图书馆)。


There is requirement in application which states that find out all the objects that are bounded to specific country and/or city into the google map.

We have objects with respective latitude and longitude precalucated using google map api and stored in database. Some times these objects are provides service withing certain service range/radius within which they can provide their services.

For e.g. now the situation is like i wanna to find out all the objects which resides in Amsterdam for instance.

The application should find out all the objects that are located in Amsterdam, also the objects which are not exactly located in Amsterdam but nearby, having service range up to Amsterdam.

So i have known latitude, longitude values for Amsterdam returned by google map, also the objects having respective lat,lng value and service range/radius stored in database. How can i make it possible?

解决方案

You should probably represent countries/cities as polygons in the DB, and then use OpenGIS-style polygon intersection functions to intersect.

But, MySQL does not implement polygon intersection properly (only MBR - Minimum Bounding Rectangle). So this approach, while correct in theory, will simply not work for you with MySQL. You might want to consider moving to Postgres.

What you can do is use your DB's MBR intersection capabilities and supplement them with your own code that does polygon/point intersection (you can find libraries that do this).

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

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