OsmSharp / ui

The UI components.
http://osmsharp.com/
GNU General Public License v2.0
139 stars 91 forks source link

RouterTSP does not work and throws exception when calculate TSP for trucks #238

Open FelixPetzold opened 9 years ago

FelixPetzold commented 9 years ago

Versions: OsmSharp v4.2.0.723 .Net 4.5.1

When I calculate a TSP for a truck, I get an exception. Same code but Vehicle.Car and it works. tspSolver.CalculateTSP is the method that is crashing.

Points I requested: Addresses.Add(new PointLatLng(51.6882, 8.69939)); // Wewer, Wasserburg 29 Addresses.Add(new PointLatLng(51.9515971, 8.5717169)); // Aldi Bielefeld Sennestadt Addresses.Add(new PointLatLng(51.7795244, 8.7130426)); // Rewe Sennelager

My code: Vehicle oVehilce = Vehicle.SmallTruck; List lGeoCoordinates = new List();

foreach (PointLatLng oPoint in Addresses) { RouterPoint oGeoCoordinate = oRouter.Resolve(oVehilce, new GeoCoordinate(oPoint.Lat, oPoint.Lng)); if (oGeoCoordinate != null && oRouter.CheckConnectivity(oVehilce, oGeoCoordinate, 100)) lGeoCoordinates.Add(oGeoCoordinate); }

var tspSolver = new RouterTSPWrapper(new RouterTSPAEXGenetic(1000, 200), oRouter, oOsmRoutingInterpreter); Route oRoute = tspSolver.CalculateTSP(oVehilce, lGeoCoordinates.ToArray(), 0, false);