如何确定 MKAnnotation 对象最集中的 MKMapRect 区域?

发布于 2024-12-28 17:26:02 字数 398 浏览 3 评论 0原文

给定一个 MKMapView,其中在地图上的各个点包含可变数量的注释 ([mapView Annotations]) 以及 MKMapRectMKMapRectWorld,如何确定地图上最集中 MKAnnotation 对象的区域(可能是彼此最接近的 5-15 个注释)?

示例场景:

* 咖啡查找器:确定地图上哪个区域星巴克最多

* K9统计数据:确定地图上哪个区域有最多可卡犬


“区域”可以是设定的矩形大小或由注释块确定,我不一定关心。感谢您的帮助!

Given an MKMapView that contains a variable amount of annotations ([mapView annotations]) at various points on the map and the MKMapRect value MKMapRectWorld, how can I determine an area on the map that has the greatest concentration on MKAnnotation objects (perhaps the 5-15 annotations closest to one another) ?

Example scenarios:

* Coffee finder: Determine which area of the map has the most Starbucks

* K9 statistics: Determine which area of the map has the most Cocker Spaniels

The "area" could be a set rect size or determined by a block of annotations, I don't necessarily care. Thanks for your help!

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

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

发布评论

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

评论(1

浅听莫相离 2025-01-04 17:26:02

您会发现相关问题很有帮助。

请查看 K-means_algorithm

K-means_algorithm

如果您有 N 个注释并想要分解为 K 个注释, 您可以使用 K 均值算法找到 K 个零件中每个零件的中心(这将满足某些条件,例如最小化簇内平方和)。一旦您找到了中心和距中心最远的注释之间的距离,它将给出您感兴趣的区域的半径。 K-means_algorithm 有多种变体,您可以根据性能和实施难易程度进行选择。

编辑:
我还没有实现以下,但认为肯定会给出解决方案之一

如果您对范围 5-10 没问题,则可以有多种解决方案。所以我们会找到解决方案之一。

1- 假设您有 (N=100) 个注释,并且希望其中 (P =15) 个注释的位置最密集。

2- 然后我们将 N 个注释随机划分为 K = N/P 组(这里 K = 7)

3- 使用 K-means 算法,这样最终我们将拥有 K 个可以区分为单独实体的组。

4-这些K组将具有最小“簇内平方和”的性质。

5-如果您想节省计算时间,您可以将最集中的组的定义放宽为最小“簇内平方和”,而不是由它们界定的区域。

6-从获得的K组中选择满足您的标准的组。

7-如果想坚持最小面积(最大浓度)定义,那么您将需要进行大量计算

a。首先确定给定组的边界注释,这本身就是一个巨大的问题。

b.计算每个多边形的面积并查看哪个最小。不复杂,但计算要求高)

EDIT2

我尽了一切努力,最后认为这个问题属于专业数学网站。我在这里问了你的问题< /a> 从答案中,你可以得到讨论这个问题和解决方案的论文此处。他们讨论的问题给定N个点,找到凸包面积最小的K个点。

You will find related question helpful.

Also take look at K-means_algorithm

K-means_algorithm

If you have N annotations and want to break into K parts you can find center (which will fill certain criteria. e.g. minimize the within-cluster sum of squares ) of each of K parts with K-means-algorithm. Once you have center find out distance between center and annotation farthest from center it will give radius of region you are interested. There are several variations of K-means_algorithm, you can choose whichever based on performance and ease of implementation.

EDIT:
I have not implemented following, but think will definitely give one of solution

If you are OK with range 5-10, there can be multiple solutions. So we will find one of solution.

1- Say you have (N=100) annotations and want which (P =15) of them are most located densely.

2- Then we will divide N annotations in K = N/P groups(here K = 7) randomly

3- Use K-means algorithm so that finally we will have K groups that can be differentiated as separate entities.

4- These K groups will have property of minimum " within-cluster sum of squares".

5- If you want to save computational time, you can relax definition of most concentrated group as minimum "within-cluster sum of squares" as opposed to area bounded by them.

6- select a group from obtained K group that satisfies your criteria.

7- If want to persist to minimum area(greatest concentration) definition then you will need to do lots of computation

a. First determine boundary annotations of given group, which itself a huge problem.

b. calculate are of each polygon and see which is least. not complicated but computationally demanding)

EDIT2:

I tried whatever I can and finally thought it this question belongs to specialist math website. I asked your question here and from the answer , you can get paper discussing this problem and solution here. Problem they discuss is given N points, find the K points whose area of convex hull is minimum.

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