如何简化KML(减少点数)?

发布于 2024-07-06 21:38:07 字数 547 浏览 9 评论 0原文

我遇到了与这篇文章类似的问题。 我需要在嵌入式 Google 地图上显示最多 1000 个多边形。 这些多边形位于 SQL 数据库中,我可以使用自定义 HttpHandler(在 ASP.NET 中)将每个多边形即时渲染为单个 KML 文件,如下所示 http://alpha.foresttransparency.org/concession.1.kml

即使在我的(非常快的)开发机器上,加载几十个形状也需要一段时间。 所以有两个问题:

  1. 一旦我超出一定的缩放级别,将这些渲染为标记而不是覆盖层的好策略是什么?

  2. 是否有公开可用的算法来简化多边形(减少点数),以便我在特定缩放级别上显示的点不会多于有意义?

I have a similar problem to this post. I need to display up to 1000 polygons on an embedded Google map. The polygons are in a SQL database, and I can render each one as a single KML file on the fly using a custom HttpHandler (in ASP.NET), like this http://alpha.foresttransparency.org/concession.1.kml .

Even on my (very fast) development machine, it takes a while to load up even a couple dozen shapes. So two questions, really:

  1. What would be a good strategy for rendering these as markers instead of overlays once I'm beyond a certain zoom level?

  2. Is there a publicly available algorithm for simplifying a polygon (reducing the number of points) so that I'm not showing more points than make sense at a certain zoom level?

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

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

发布评论

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

评论(5

时间你老了 2024-07-13 21:38:07

对于第二个问题:您需要 Douglas-Peucker 泛化算法

For your second question: you need the Douglas-Peucker Generalization Algorithm

够运 2024-07-13 21:38:07

对于您的第一个问题,您是否可以计算特定多边形的面积,并将每个缩放级别与特定的最小区域相关联,以便当您放大或缩小时,多边形会消失,并且标记会根据缩放级别而出现。

对于第二个问题,我会使用马克·贝西的建议。

For your first question, could you calculate the area of a particular polygon, and relate each zoom level to a particular minimum area, so as you zoom in or out polygon's disappear and markers appear depending on the zoom level.

For the second question, I'd use Mark Bessey's suggestion.

誰ツ都不明白 2024-07-13 21:38:07

我对 KML 不太了解,但我认为问题#2 的通常解决方案涉及迭代点,并删除特定大小以下的任何线段。 在某些情况下,这会导致一些“不幸”的影响,但它相对较快且容易做到。

I don't know much aobut KML, but I think the usual solution to question #2 involves iterating over the points, and deleting any line segments under a certain size. This will cause some "unfortunate" effects in some cases, but it's relatively fast and easy to do.

梦言归人 2024-07-13 21:38:07

我会推荐两件事:
- 计算并组合接触的多边形。 这涉及大量的处理和硬数学,但我已经做到了,所以我知道这是可能的。
- 创建您自己的叠加层,而不是使用 PNG 格式的 KML,同时在之前的建议中将它们组合起来。 您必须创建大量 PNG,但它在客户端上的速度非常快。

祝你好运 :)

I would recommend 2 things:
- Calculate and combine polygons that are touching. This involves a LOT of processing and hard math, but I've done it so I know it's possible.
- Create your own overlay instead of using KML in PNG format, while you combine them in the previous suggestion. You'll have to create a LOT of PNGs but it is blazing fast on the client.

Good luck :)

Saygoodbye 2024-07-13 21:38:07

不久前我需要一个解决你的#2问题的方法,在查看了一些可用的线路简化算法之后,我创建了自己的算法。

这个过程很简单,而且似乎运行良好,尽管如果您没有正确实现它可能会有点慢:

P[0..n] 是您的点数组
T[n] 定义为由点 P[n-1]、P[n]、P[n+1 形成的三角形]
Max 是您尝试将此线减少到的点数。

  1. 计算集合中每个可能的三角形 T[1..n-1] 的面积。
  2. 选择面积最小的三角形T[i]
  3. 删除点P[i],使三角形基本变平
  4. 重新计算受影响三角形的面积T[n -1], T[n+1]
  5. 如果点数 > 则转到步骤 #2 最大

I needed a solution to your #2 question a little bit ago and after looking at a few of the available line-simplification algorithms, I created my own.

The process is simple and it seems to work well, though it can be a bit slow if you don't implement it correctly:

P[0..n] is your array of points
Let T[n] be defined as the triangle formed by points P[n-1], P[n], P[n+1]
Max is the number of points you are trying to reduce this line to.

  1. Calculate the area of every possible triangle T[1..n-1] in the set.
  2. Choose the triangle T[i] with the smallest area
  3. Remove the point P[i] to essentially flatten the triangle
  4. Recalculate the area of the affected triangles T[n-1], T[n+1]
  5. Go To Step #2 if the number of points > Max
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文