如何计算 Bing 地图 MapPolygon 的地理区域?

发布于 2024-10-19 09:42:37 字数 207 浏览 6 评论 0原文

我有一个带有 Bing Map 控件的 Silverlight 应用程序,该控件显示一系列可编辑的 MapPolygon,用户可以随意调整其大小。当然,这些 MapPolygon 被定义为地理坐标。如何计算多边形的面积?

多边形作为地理类型存储在 SQL Server 中,我可以返回服务器获取答案,但随后用户在重塑多边形时会丢失该区域的交互式更新。精确度控制在百分之几以内是理想的。

I have a Silverlight application with a Bing Map control that displays a series of editable MapPolygons that the user can resize at will. These MapPolygons are, of course, defined as geographic coordinates. How do I calculate the area of a polygon?

The polygons are stored as geography types in SQL Server and I could go back to the server for the answer, but then the user loses an interactive update of the area as they reshape the polygons. Accuracy to within a few percent is desirable.

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

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

发布评论

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

评论(2

温馨耳语 2024-10-26 09:42:37

我通过编写一个例程在客户端上进行“球面几何”面积计算来解决这个问题。工作起来很愉快,无需返回服务器。

简而言之,我作弊。我找到该区域的质心,展平到以质心为中心的平面,并使用平面几何通过将多边形视为一系列三角形来进行多边形面积计算。

虽然这是一个近似值,但对于我的目的来说已经足够准确了。如果我需要确切的答案,我会使用 SCHUMMBO 方法。

戴夫.

I solved this by writing a routine to do 'spherical geometry' area calculations on the client. Works a treat and no need to go back to the server.

In short, I cheat. I find the centroid of the area, flatten to a plane centered on the centroid, and use plane geometry to do the polygon area calculation by treating the polygon as a series of triangles.

Although it's an approximation it's quite accurate enough for my purposes. If I needed an exact answer I would use SCHUMMBOs method.

Dave.

长安忆 2024-10-26 09:42:37

如果您不介意返回到 WCF 服务,则可以使用 Microsoft.SqlServer.Types 库来进行计算。 SqlGeometry 有一个名为 STArea 的方法可以执行此操作: http://blogs.msdn.com/b/davidlean/archive/2008/10/17/this-site-under-construction.aspx

您不必失去应用程序的交互性要么必然。当用户完成大小调整后,您可以向服务询问该区域并短暂显示一个旋转器或其他内容。我知道这不会像调整大小那样即时进行,但您也不必在客户端上计算面积。

抱歉,我在回答如何即时执行此操作方面没有提供更多帮助。

If you don't mind going back to a WCF service, you can use the Microsoft.SqlServer.Types library to do the calculation. SqlGeometry has a method called STArea that does this: http://blogs.msdn.com/b/davidlean/archive/2008/10/17/this-site-under-construction.aspx

You wouldn't have to lose the interactivity of the app either necessarily. When the user is finished resizing, you can ask the service for the area and display a spinner or something briefly. I understand this wouldn't be as slick as doing it on the fly as the resize, but you also don't have to calculate the area on the client.

Sorry I wasn't more helpful in answering how to do it on the fly.

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