如何过滤空间数据

发布于 2024-07-29 01:20:33 字数 378 浏览 1 评论 0原文

我有一个地图点数据库,我想将显示限制为一次最多显示约 50 个点。 当用户放大时,可以显示更多点。

目前,我只是从结果集中随机抽取样本。 这不太好,因为可能存在空白区域,放大时会突然显示一个点。

我的下一个想法是我可以创建一个 10x5 网格,并迭代结果。 如果网格中的某个位置是空的,我会显示一个点。 这解决了之前的问题,但也无法让用户了解集中区域在哪里。 此外,如果用户决定缩小到整个世界,这会非常慢。

现在,我没有使用任何空间算法来对数据进行排序。 我的计划是先让它正常运行,然后再快速运行。 阅读了一些 RTress、kd 树和四叉树后,我找不到任何可以帮助我选择样本的“智能”子集的内容。 似乎应该有某种广度优先搜索来很容易地解决这个问题。

I have a database of map points, and I want to limit the display to showing at most ~50 points at a time. When a user zooms in, more points may be displayed.

Currently, I'm just taking a random sample of the result set. This isn't great, as there can be empty areas, that when zoomed in suddenly show a point.

My next thought was I could create a 10x5 grid, and iterate over the results. If a location in the grid was empty, I would show a point. This fixes the previous problem, but also doesn't give the user a sense of where concentrated areas are. Also, this is quite slow if the user decides to zoom out to the entire world.

Right now, I'm not using any spatial algorithm to sort the data. My plan is to get it working right first, and then get it fast. Reading a little into RTress, kd-trees, and quad-trees, I couldn't find anything that would help me select a 'smart' subset of the sample. It seems like there should be some sort of breadth first search which would solve this problem quite easily.

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

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

发布评论

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

评论(3

绝對不後悔。 2024-08-05 01:20:33

稍微扩展一下你原来的想法怎么样? 将其分成网格,然后使用密度分析根据该区域中的要素数量创建不同大小的点。 这样,用户只需查看较大(或较小)的点,就可以在视觉上更清楚地了解特征密度。

至于让它更快,也许你可以为每个网格设置一个阈值。 如果计数达到一定数量,则移动到下一个网格。 这样,您就可以获得一个“最大”点,并通过忽略高于人为设置的阈值(您可以根据数据的经验分析来确定)的点来加快速度。

How about extending your original idea a bit. Break it into grids, then use a density analysis to create differently-sized points based upon the number of features in that area. That way a user is more visually aware of feature density simply by looking at the larger (or smaller) points.

As for making it faster, perhaps you could set a threshold for each grid. If the count hits a certain amount, move on to the next grid. That way you can have a "maximum" point and speed things up by ignoring points above that artificially set threshold (which you can determine based upon an empirical analysis of your data).

梦过后 2024-08-05 01:20:33

迈克尔·托德提出了一些很好的建议。 为此+1。

我想补充一点(取决于数据的类型),您可以向地图点添加额外的属性。

例如,对于城市,您可以添加居住在其中的人数。
然后根据缩放级别,仅显示特定大小的城市。 或者更好的是,在您的选择算法中给他们更高的分数。 在空旷的地区你仍然会看到较小的城市,在拥挤的地区你只会看到大城市。

这种方法适用于任何缩放级别,而每个缩放级别的预定义数据集仅适用于离散步骤。

Michael Todd made some good suggestions. +1 for that.

I'd like to add that (depending on the type of data) you could add an extra property to your map points.

For example, for cities, you could add the amount of people living in it.
Then depending on the zoomlevel, you only show cities of a certain size. Or better yet, give them a higher score in your selection algorithm. In empty areas you'll still see smaller ones, in crowded areas you'll only see large cities.

This approach works out nicely for any zoomlevel, while predefined sets of data per zoomlevel only work in discrete steps.

一念一轮回 2024-08-05 01:20:33

由于我只有几千个点和大量的离线时间,因此我创建了一个算法来创建一个分散因子,我可以通过该因子对数据进行排序。

  1. 我从我的集合中随机选择一个点,给它一个 n=1 的分数,然后将其添加到选定列表中。
  2. 然后,我搜索距离选定列表中任何点更远的点。
  3. 我选取该点,为其评分为 n + 1,将其添加到选定列表中,然后重复第二步,直到选择所有点。

在我的地图中,我获取与范围过滤器匹配的所有点,并按排名升序对它们进行排序。 无论过滤器或缩放如何,我都会得到分布在屏幕上的点。

Since I have only a few thousand points, and plenty of offline time, I created an algorithm to create a dispersion factor by which I can sort the data.

  1. I start with a random point from my set, give it a score of n=1, and add it to the selected list.
  2. I then search for the point which is further from any point in the selected list.
  3. I take this point, give it a score of n + 1, add it to the selected list, and then repeat step two until all points have been selected.

In my map, I take all points which match a range filter and sort them by rank ascending. Regardless of the filter or zoom, I'll have points which are distributed across the screen.

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