从随机坐标列表中查找外边界
我有一个巨大的坐标列表(60 000+),但我还没有找到识别外边界的方法。
坐标列表是相当随机的,但它们定义了一些真正特定的区域。
我应该能够通过使用 OpenLayers 使用该列表来绘制一个区域,因此它们也应该按顺序排列。
这似乎是相对容易打破的坚果,但事实证明非常具有挑战性。
解决这个问题的最佳方法是什么?
- 海基
I've a huge list (60 000+) of coordinates and I haven't found a way for recognizing the outer borders.
The list of coordinates are quite random, but they're defining some really specific area.
I should be able to draw an area by using that list by using OpenLayers, so they also should in order.
This seemed to be relatively easy nut to break but has proven to be quite challenging.
What might be the best approach for this problem?
- Heikki
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您是否正在寻找凸包?
Are you looking for a convex hull?
如果您只想要边界框,这很简单:
如果您的平台上没有 MAX_INT 和 MIN_INT 的简单等效项,只需选择列表中的第一个即可。它可能是不太“漂亮”的代码,但也可能快了一些毫无意义的量。
当然,如果您的数据以某种重要方式排序,您可能可以做一些比迭代超过 60k 项并执行 240k 比较更聪明的事情。 (请记住,仅为此而以某种重要方式订购 60k 积分可能无法收回成本。)
If you just want the bounding box, it's easy enough:
If there's no easy equivalent of MAX_INT and MIN_INT on your platform, just pick the first one in the list. It's possibly less 'pretty' code, but it is also possibly faster by a meaningless amount.
Of course, if your data were ordered in some significant way, you might be able to do something more clever than iterating over 60k items and performing 240k comparisons. (Keeping in mind that ordering 60k points in some significant way just for this may not pay for itself.)
凸包是我一直在寻找的主题。我从 http://code.activestate.com/recipes/66527-finding-the-convex-hull-of-a-set-of-2d-points/。
非常感谢所有参与者!
Convex hull is the subject what I've been looking for. I found a really nice script from http://code.activestate.com/recipes/66527-finding-the-convex-hull-of-a-set-of-2d-points/.
Many thanks for all participants!