GMap.NET和VB:如何获得点之间的最短路径? [英] GMap.NET and VB : How to get the shortest Route between points ?
问题描述
大家好,
关于VB .NET语言中 GMap.NET 库的问题。 />
这是我在地图上显示的( GMapControl 在Windows窗体应用程序中的窗体上)一条只有2个点的简单路径:P1是开始,P2是目的地。
工作代码是:
GMC.Position = New PointLatLng(40.654331,-73.917067)
Dim RP As RoutingProvider = DirectCast(GMC.MapProvider,RoutingProvider)
Dim P1 As New PointLatLng(40.657161,-73.921079)
Dim P2 As New PointLatLng(40.65587,-73.915188)
Dim MP As MapRoute = RP.GetRoute(P1,P2,True,False,Convert.ToInt32(GMC.Zoom) ))
Dim R As New GMap.NET.WindowsForms.GMapRoute(MP.Points," Route")
Dim SB As New SolidBrush(Color.FromArgb(125,0,255,0))
R.Stroke = New Pen(SB,6)
m OverlayRoutes.Routes.Add(R)
GMC 是我的GMapControl,
和 mOverlayRoutes 是一个简单的GMap.NET.WindowsForms.GMapOverlay,之前已声明并添加到GMC.Overlays:
< pre class ="prettyprint lang-vb"> mOverlayRoutes = New GMap.NET.WindowsForms.GMapOverlay(" Routes")
GMC.Overlays.Add(mOverlayRoutes)
代码非常简单且运行良好。
现在的问题是:如何获得相同的路线3或更多积分?
例如,我现在有5个积分,我的路线必须尽可能短,达到地图上的所有5个积分。
有人在这里解决了同样的问题吗?
感谢大家的帮助。
嗨
你正在钻研非平凡的旅行萨莱斯曼问题。
如果你谷歌(或者,Kookaburra算法),你会得到很多信息。
我什么都不知道 GMap.NET ,它可能包含执行此类操作的方法,但由于这是一项非常复杂且耗时的任务,我怀疑它确实如此。
可以合理地快速处理少数城市。
Hi everybody,
a question about GMap.NET library in VB .NET language.
This is what I do to display on Map ( GMapControl on a Form in a Windows Forms Application ) a simple route with just 2 points : P1 is Start and P2 is Destination.
The working code is :
GMC.Position = New PointLatLng(40.654331, -73.917067) Dim RP As RoutingProvider = DirectCast(GMC.MapProvider, RoutingProvider) Dim P1 As New PointLatLng(40.657161, -73.921079) Dim P2 As New PointLatLng(40.65587, -73.915188) Dim MP As MapRoute = RP.GetRoute(P1, P2, True, False, Convert.ToInt32(GMC.Zoom)) Dim R As New GMap.NET.WindowsForms.GMapRoute(MP.Points, "Route") Dim SB As New SolidBrush(Color.FromArgb(125, 0, 255, 0)) R.Stroke = New Pen(SB, 6) mOverlayRoutes.Routes.Add(R)
Where GMC is my GMapControl,
and mOverlayRoutes is a simple GMap.NET.WindowsForms.GMapOverlay previously declared and added to GMC.Overlays :
mOverlayRoutes = New GMap.NET.WindowsForms.GMapOverlay("Routes") GMC.Overlays.Add(mOverlayRoutes)
Code is very simple and works well.
Now the question is : How to get the same route with 3 or more Points ?
For Example, I have now 5 Points and my route has to be the shortest possible, reaching all 5 Points on the map.
Has someone here solved the same kind of problem ?
Thanks to everyone able to help.
Hi
You are delving into the non-trivial Traveling Salesman problem.
If you Google that (or, Kookaburra algorithm), you will get a lot of information.
I don't know anything of GMap.NET, it may contain methods to do such a thing, but since it is an extremely complex and time consuming task, I would doubt that it does.
Small numbers of cities could probably be handled reasonably quickly.
这篇关于GMap.NET和VB:如何获得点之间的最短路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!