如何检查某个位置是否位于 Silverlight Bing 地图控件中的 MapPolygon 内?
我有一个 MapPolygon,它覆盖了 Silverlight Bing Maps 控件上的某个区域, 我想知道某个特定位置是否位于此 MapPolygon 内。
我尝试了以下代码,但它没有返回我想要的结果,因为它只检查测试的位置是否是 MapPolygon 的顶点之一,并且不检查此位置是否包含在该 MapPolygon 中。
polygon.Locations.Contains(new Location(this.Site.Latitude, this.Site.Longitude, this.Site.Altitude));
是否也可以确定两个 MapPolygon 是否彼此相交?
I have a MapPolygon which covers a certain area on the Silverlight Bing Maps control,
and I would like to know if a particular Location is located within this MapPolygon.
I have tried the following code which doesen't return the result I want because it only checks if the tested location is one of the vertices of the MapPolygon, and doesn't check if this Location is contained within this MapPolygon.
polygon.Locations.Contains(new Location(this.Site.Latitude, this.Site.Longitude, this.Site.Altitude));
Is it also possible to determine if two MapPolygons intersect one another?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Polygon.Locations 是定义多边形的点的列表。
您必须制定一种方法来查找您的点是否在多边形内部。
使用类似这样的东西(如果编译则未测试):
并像这样调用它:
The polygon.Locations is a list of points defining the polygon.
You have to make a method to find if your point is inside the polygon.
Use something like this (not tested if compiles):
And call it like this:
当然,这两件事都是相当微不足道的,请看下面的文章。 http://msdn.microsoft.com/en-us/library/cc451895。 aspx 它为边界框、半径和多边形搜索提供了很好的方法。特别注意 pointInPolygon 方法。
Sure both of these things are fairly trivial, take a look at the following article. http://msdn.microsoft.com/en-us/library/cc451895.aspx It gives good methods for Bounding Box, Radius, and Polygon Search. Particularity take note of the pointInPolygon method.