我画的区域(使用 SqlGeometry / SqlGeography ,并将其转换为WPF 在必应地图WPF控件LocationCollection 当量),并贴上标签需要。我上了区绘制的标签,并将其连接到由 STCentroid发现点()。当然,如你想象这是用U或C形状的区域,其中的重心区域,这使得标签不正确外结束的一个问题。
有没有使用 SqlGeometry / SqlGeography 办法找到视觉中心或者找到能够适应最大圆的形状,并使用该中心?我试过各种方法使用 STPointOnSurface()但似乎 STPointOnSurface()总是挑选对像这样DCREHA边缘的点(为底深绿色区域中的标签总是在边缘结束
解决方案
这是几乎相同的问题已经被问这里。在你的情况下,最相关的答案可能是这的之一。这个问题的答案的最艰难的部分是确定在哪里画的拆分多边形进线。两个相等的区域。因此,我提出以下稍作修改的版本的SQL Server:
有关实例,给出了上面的DCREHA例如多边形,以下的GIF动画上面列出的程序(
的
I'm drawing regions (using SqlGeometry/SqlGeography and translating them to the WPF LocationCollection equivalent) on the Bing Maps WPF Control and needed to label them. I got the labels drawn on the regions and attached them to the point found by STCentroid(). Of course as you imagine this is a problem with the 'U' or 'C' shaped regions where the centroid ends up outside the region, which makes the label incorrect.
Is there a way using SqlGeometry/SqlGeography to find the "visual" center or perhaps find the largest circle that can fit in the shape and use that center? I've tried various methods using STPointOnSurface() but it seems that STPointOnSurface() always picks a point on the edge like so DCREHA (the label for the bottom dark green region always ends up on the edges:
解决方案An almost identical question has already been asked here. In your case, the most relevant answer is probably this one. The hard part of that answer is determining where to draw the line that splits the polygon into two equal areas. Therefore, I propose a slightly modified version below for SQL Server:
For instance, given the polygon for the DCREHA example above, the following GIF animates the procedure listed above (judged by eye - actual result will differ):
更多推荐
使用SQL空间数据(C#)来查找"视觉"不规则多边形的中心
发布评论