从特定的地理位置库调用功能时,有时会获得意外的结果

发布于 2025-02-09 12:41:02 字数 743 浏览 1 评论 0 原文

我在API中有一个端点,其中我使用此函数 geocluster 从库中,我给它列出了坐标列表(纬度和经度),并期望返回少量点,这些点基本上是中间体的坐标,这些坐标将在较小的群集中串联坐标列表。该算法是使用标准偏差,因此称为s均值。

我的主要问题是,如果一个请求太快一个接一个地,API不会为请求的用户返回相同的坐标聚类,有时会有很小的变化,这在技术上很好,但是在某些越来越普遍的时代,它会完全返回不同的坐标簇,这是非常有问题的,很难预测或复制,因为它并非总是发生。
因此,我想问我如何避免这种行为?我应该尝试另一个类似于Node-GeoCluster的库,哪个?我应该更改库本身内的代码吗?如何?

我已经尝试更改库代码,以避免从给定坐标的随机坐标开始,以免随机行为 - 即使是随机行为,但它不起作用。还使用有序的坐标进行了尝试,但也没有成功。

提前致谢!

I have an endpoint in my API where I use this function geocluster from the library node-geocluster, where I give it a list of coordinates(latitude and longitude) and expect to have the return of a small amount of points, which are basically intermediates coordinates that clusters the given list of coordinates in smaller clusters. The algorithm is a variation from the k-means algorithm, using standard deviation, thus being called s-means.

My main problem is if there's two requests too quickly one after another, the API won't return the same clustering of coordinates for the users requesting it, sometimes with small variations, which is technically fine, but at some increasingly common times it returns completely different clusters of coordinates, which is very problematic and hard to predict or replicate, since it doesn't happen always.
So I would like to ask how could I avoid this behavior? Should I try another library similar to node-geocluster, which one? Should I change the code inside the library itself? How?

I've already tried changing the library code to avoid starting at a random coordinate from the given coordinates so it would avoid the random behavior - even though it's , but it didn't work. Also tried this with an ordered set of coordinates but no success either.

Thanks in advance!

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文