Foursquare API:获取给定区域内场地的详尽列表 [英] Foursquare API: Getting an exhaustive list of venues in a given area

查看:25
本文介绍了Foursquare API:获取给定区域内场地的详尽列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Foursquare API 来获取某个类别的场地列表.一个重要的要求是该列表是详尽无遗的,即包括所有相关要点.v2/venues/search API 端点对输出强制执行 50 个场所的限制.所以想到的第一个想法是将区域分成几个部分(使用sw"和ne"参数),然后组合结果.

I'm using Foursquare API to get a list of venues of a certain category. One important requirement is that the list is exhaustive, i.e. includes all relevant points. The v2/venues/search API endpoint enforces a limit of 50 venues on the output. So the first idea that comes to mind is splitting the area into several sections (using "sw" and "ne" params) and then combining the results.

显然,点的密度会因位置而异,因此我们需要使用某种自适应算法来灵活调整搜索窗口的大小,使其包含所有点.此外,遇到速率限制的风险也会增加,因此我们可能需要算法在其请求配额用完时停止.

Clearly, the density of points will vary dramatically depending on location, so we'll need to use some kind of adaptive algorithm to flexibly adjust the size of the search window so that it contains all points. Also, there's an increased risk of running into the rate limit, so we might need the algorithm to stop when it's used up its quota of requests.

最后,似乎判断搜索窗口是否应该进一步缩小的唯一方法是计算结果中的点数:如果我们少于 50,那么我们就有了一个完整的列表部分并可以进入下一个部分;否则,我们应该进一步拆分它.这似乎很浪费,因为我们将丢弃中间结果(即搜索树中除叶子之外的所有结果).

Finally, it seems that the only way to tell if a search window should be shrunk even further is to count the number of points in the result: if we have less than 50, then we've got a complete list for this section and can move on to the next one; otherwise, we should split it further. It seems to be wasteful as we'll be throwing away the intermediate results (i.e. all results in our search tree except for the leaves).

以下是我的一些问题:

  • 这是整理一份详尽清单的最佳方式吗?也许我是缺少某些 API 功能?
  • 在这种情况下,您是否会使用任何特定算法?
  • 您将如何减少必须丢弃的结果数量?

提前致谢!

推荐答案

一个重要的免责声明是,当您在同一区域执行大量搜索时,foursquare 不喜欢它.

话虽如此,您应该考虑在场地搜索 API 中尝试使用 categoryId 过滤器.Foursquare 上的大部分数据都与食物(餐厅)和夜生活相关.

Having said that, you should look into experimenting with categoryId filter in the venue search api. Most of the data on foursquare is food (restaurants) and nightlife related.

因此,如果您排除这些(通过包括其他人,无法排除),您可以在更大的区域内进行搜索,但仍然会得到 50 个以下的结果.

So if you exclude these (by including others, no way to exclude) you can search on a larger area and still get below 50 results.

从未真正尝试过使用这样的算法,因为 categoryId 过滤效果很好,但理论上,该算法很简单,每个 lat/lng 0.001 约为 111 米.

Never really tried using such an algorithm because the categoryId filtering worked good enough, but in theory, the algorithm is simple, each lat/lng 0.001 is ~111 meters.

使用小半径(对于大都市区约为 200)和三角测量(扫描)区域进行搜索.

Search using a small radius (~200 for large metropolitan areas) and triangulate (scan) areas.

最初让我们执行大量搜索(后来停止这样做)的原因是,有时 Foursquare 会在不询问您的情况下过滤结果(对我来说,这看起来像是错误,对他们来说,这是算法的一部分).例如,我会搜索 50 米半径,找到我想要的地方(我知道我在搜索什么),扩展到 500 米,找不到它(并且得到的结果少于 50 个——所以它没有被淘汰,因为我击中了上限,因为 ???),将我的搜索位置向北移动约 300 米,找到它 -> 零星行为.

What got us to originally perform a lot of searches (and later stop doing so) is that sometimes foursquare filter out results without asking you (for me, it looks like bugs, for them its part of the algorithm). So for example I would search on a 50 meter radius, find the place I want (I know what I am searching for), expand to 500 meters, not find it (and get less than 50 results - so it was not dropped out because I hit the cap, it was dropped out because ???), move my search location ~300 meters north, find it -> sporadic behavior.

我的观点是(以及我们停止进行大量搜索并改变我们的方法的原因),您想要实现的目标是,完全覆盖"非常当前的 API 和当前的使用政策,以及 -> 这实际上并不重要.在玩了几个月之后,我们发现我们应该查询foursqaure,以了解我们的用户此刻正在寻找和需要的东西,我们缓存结果 - 随着时间的推移,我们将拥有完整的覆盖范围,也许一开始我们会错过一些地方,但从长远来看,这并不重要.

My point is (and the reason for why we stopped making a lot of searches and changed our approach), what you are trying to achieve, 'complete coverage' is very hard to do given the current API and the current usage policy, and -> it is not important really. After a few months of playing with it, we figured out that we should query foursqaure for what our users are looking for and require at this moment, we cache the results - over time we will have a complete coverage, maybe at start we will miss a few spots, but for the long run its not really important.

这篇关于Foursquare API:获取给定区域内场地的详尽列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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