如何在 Javascript 中查找/创建 GPS 点的凸包

发布于 2024-10-09 21:26:39 字数 113 浏览 0 评论 0原文

我有一个 GPS 集群(包含许多彼此靠近的 GPS 点),我想通过在其外部点周围创建一个多边形来将其识别为一个位置。一种方法是凸包,我正在寻找它在 Javascript 中的实现。

有什么想法吗?

I have a GPS cluster (contains many GPS points which are close to each other) and I want to identify it as a place by creating a polygon around its outer points. One way is Convex Hull and I am looking for its implementation in Javascript.

Any idea?

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

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

发布评论

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

评论(2

坏尐絯 2024-10-16 21:26:39

以下演示显示如何计算凸包,该凸包将绘制给定坐标的外边界或区域。该演示是用 javascript

http://www.geocodezip.com/v3_map-markers_convexhull.asp< /a>

演示代码位于
https://github.com/mgomes/ConvexHull

凸包是一个尚未提供的概念在谷歌地图 API 中还没有。

The following demo displays how to calculate a convex hull that will plot an outer boundary or the area for the given coordinates. This demo is implemented in javascript

http://www.geocodezip.com/v3_map-markers_convexhull.asp

The code for the demo is located at
https://github.com/mgomes/ConvexHull

The convex hull is a concept that has not been provided in google maps API yet.

平生欢 2024-10-16 21:26:39

是的。查看标签中的来源。有两个独立的脚本:一个执行 Hull 算法,另一个包含 google 地图 API 内容。

在示例中,Initiation() 函数由主体的 onload 事件调用,该函数为单击事件设置所有侦听器,创建随机点等。

查看船体的算法,即 chainHull_2D(P,n,H) 函数。我花了一些时间才理解它,但一旦我掌握了它,它就变得很有意义。该函数将 H 与船体的 GLatLng 数组一起吐出。然后使用 GLatLng 数组创建 GPolygon。

GPolygon 实现了谷歌地图叠加接口,因此您可以使用 Map.addOverlay 函数来显示多边形。

请查看本教程,以更好地了解地图 API。

Yep. Check out the source in the tag. there's two separate scripts: one that executes the hull algorithm, and the other has the google maps API stuff in it.

In the example, the Initiation() function is called by the body's onload event, which sets up all of the listeners for click events, creates the random points and such.

Check out the algorithm for the hull, the chainHull_2D(P,n,H) function. It took me a bit to follow it but once I got a grasp it makes a lot of sense. The function spits H back out with the array of GLatLng of the hull. A GPolygon is then created using the array of GLatLng.

GPolygon implements googles maps overlay interface so you use the Map.addOverlay function to display the polygon.

Check this tutorial out too to better understand the maps API.

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