服务器端 Google 标记聚类 - Python/Django

发布于 2024-07-18 02:16:52 字数 326 浏览 3 评论 0原文

在尝试使用客户端方法来聚类大量 Google 标记后,我认为这对于我的项目(拥有 28,000 多名用户的社交网络)来说是不可能的。

是否有在服务器端对坐标进行聚类的示例 - 最好是在 Python/Django 中?

我希望它的工作方式是根据标记的接近度(半径)和缩放级别逐渐索引标记。

换句话说,当新用户注册时,他/她会自动分配到彼此靠近的某个标记“组”,从而增加“组”计数器。 发送到服务器的只是少量的“组”。 仅当地图的缩放级别/比例为 1:1 时 - 实际用户才会显示在地图上。

这样,客户端只需处理每个请求/缩放级别 10-50 个标记。

After experimenting with client side approach to clustering large numbers of Google markers I decided that it won't be possible for my project (social network with 28,000+ users).

Are there any examples of clustering the coordinates on the server side - preferably in Python/Django?

The way I would like this to work is to gradually index the markers based on their proximity (radius) and zoom level.

In another words when a new user registers he/she is automatically assigned to a certain 'group' of markers that are close to each other thus increasing the 'group's' counter. What's being send to the server is just a small number of 'groups'. Only when the zoom level/scale of map is 1:1 - actual users are shown on the map.

That way the client side will have to deal only with 10-50 markers per request/zoom level.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

南风几经秋 2024-07-25 02:16:52

这是一项使用服务器端集群的付费服务,但我不确定它是如何工作的。 我猜测他们只是使用您的数据来生成要在每个缩放级别显示的标记。

更新:此教程演示了基本的服务器端集群功能。 它是用 PHP 为静态地图 API 编写的,但您可以使用它作为起点。

This is a paid service that uses server-side clustering, but I'm not sure how it works. I'm guessing that they just use your data to generate the markers to be shown at each zoom level.

Update: This tutorial demonstrates a basic server-side clustering function. It's written in PHP for the Static Maps API, but you could use it as a starting point.

清风无影 2024-07-25 02:16:52

您可能想查看 DBSCANOPTICS 维基百科上的页面,这些看起来非常适合在地图上对地点进行聚类。 还有一个关于聚类分析的页面,显示了您可以使用的所有可能的算法,大多数会使用您选择的语言来实现是很简单的。

有了 28k+ 点,您可能想跳过 django,直接跳到 C/C++,并且肯定不会期望它能够响应 Web 请求而实时计算。

You might want to take a look at the DBSCAN and OPTICS pages on wikipedia, these looks very suitable for clustering places on a map. There is also a page about Cluster Analysis that shows all the possible algorithms you can use, most would be trivial to implement using the language of your choice.

With 28k+ points, you might want to skip django and just jump into C/C++ directly, and surely not expect this to get calculated in real-time in response to web requests.

余生共白头 2024-07-25 02:16:52

一种方法是根据缩放级别定义一个具有单位大小的网格。 因此,您可以按经纬度收集网格内的所有项目,精确到小数点后一位。 例如 42.2x73.4。 因此 42.2003x73.4021 处的点落在该网格单元中。 该单元格的边界为 42.2x73.3 和 42.2x73.5。

如果网格单元中有一个或多个点,则可以在该网格的中心放置一个标记。

然后,您连接 Zoomend 事件并相应地更改网格大小,并重新绘制标记。

http://code.google.com/apis/maps/文档/reference.html#GMap2.zoomend

One way to do it would be to define a grid with a unit size based on the zoom level. So you collect up all the items within a grid by lat,lon to one decimal place. An example is 42.2x73.4. So a point at 42.2003x73.4021 falls in that grid cell. That cell is bounded by 42.2x73.3 and 42.2x73.5.

If there are one or more points in a grid cell, you place a marker in the center of that grid.

You then hook up the zoomend event and change your grid size accordingly, and redraw the markers.

http://code.google.com/apis/maps/documentation/reference.html#GMap2.zoomend

心凉怎暖 2024-07-25 02:16:52

您可以尝试我的服务器端集群 django 应用程序:

https://github.com/biodiv/anycluster

它提供 kmeans 和网格集群。

You can try my server-side clustering django app:

https://github.com/biodiv/anycluster

It prvides a kmeans and a grid cluster.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文