基于坐标的搜索(coordinates based search)

系统教程 行业动态 更新时间:2024-06-14 17:04:03
基于坐标的搜索(coordinates based search)

我正在开发一个用户可以创建活动的网页,其他人可以通过搜索功能找到它们。 当您创建活动时,您必须指定它将发生的确切位置,在谷歌地图的帮助下我检索纬度和经度。 现在,在进行搜索时,我希望能够找到靠近指定位置的所有活动(也由谷歌地图协助)。

所以我有一组带坐标的活动,我想在附近找到活动的点的坐标,我想要返回的活动不超过,比如5公里(或者你喜欢的任何东西),远离这个点。

我脑子里有这个想法可以通过计算最大/最小纬度和经度来解决这个问题,并在sql-query中使用这些作为参数,我使用where子句进行过滤...我在这里遇到的问题首先计算这些最大/最小值,其次是圆形区域(半径5km),而不是矩形

非常感谢这里的任何输入! 谢谢!:)

I am developing a web page where users can create activities and others find them via a search function. When you create an activity you must specify the exact location where it will take place, assisted by google maps I retrieve the latitude and longitude. Now, when doing a search I want to have the functionality to find all activities close to a specified location(also assisted by google maps).

So I have a set of activities with coordinates, the coordinates of a point I want to find activities nearby, and I want to return activities that are no more than, lets say, 5 km(or miles or whatever you prefer) away from this point.

I am having this idea in my head that this can be solved by calculating max/min latitude and longitude, and use these as parameters in an sql-query where I use a where clause for filtering...The problem I'm facing here is firstly calculating these max/min values, secondly in an circular area(with radius 5km), and not a rectangular

Would appreciate any input here! Thanks!:)

最满意答案

你获得的坐标可能不是x和y,而是纬度和经度; 你将需要球面距离,除非你的所有点都在相当小的半径范围内,例如几百英里。

如果你有很多分数,那么直接穷举搜索就会变得太慢,无论是否为球形。 幸运的是,GIS扩展可用于MySQL和Postgres 。 商业DB还具有空间扩展。 这些可以有效地搜索附近的对象。

Coordinates you get are probably not x and y but latitude and longitude; you will need spherical distance unless all your points are within rather small radius, e.g. few hundred miles.

If you have many points, direct exhaustive search becomes too slow, spherical or not. Fortunately, GIS extensions available both for MySQL and for Postgres. Commercial DBs also have spatial extensions. These make searches for nearby objects efficient.

更多推荐

本文发布于:2023-04-24 21:11:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/6c1a5c04c59f6943698b8fc09722d1d6.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:标的   coordinates   search   based

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!