public Route Calculate(Vehicle vehicle, RouterPoint source, RouterPoint target)
{
177: if(source.Vehicle.UniqueName != target.Vehicle.UniqueName)
{ // vehicles are different.
throw new ArgumentException(string.Format("Not all vehicle profiles match, {0} and {1} are given, expecting identical profiles.",
source.Vehicle.UniqueName, target.Vehicle.UniqueName));
}
if(vehicle.UniqueName != target.Vehicle.UniqueName)
{ // vehicles are different.
throw new ArgumentException(string.Format("Given vehicle profile does not match resolved points, {0} and {1} are given, expecting identical profiles.",
vehicle.UniqueName, target.Vehicle.UniqueName));
}
return _router.Calculate(vehicle, source, target);
}
var router = Router.CreateFrom (
new PBFOsmStreamSource (new FileInfo ("denmark-latest.osm.pbf").OpenRead ()), new OsmRoutingInterpreter ());
Console.WriteLine (pdc.Count);
if (pdc.Count > 1)
{
for (int i = 0; i < pdc.Count; i++)
{
decimal lat = pdc [i].Latitude;
decimal lng = pdc [i].Longitude;
var resolved1 = router.Resolve (Vehicle.Car, new OsmSharp.Math.Geo.GeoCoordinate ((double)lat, (double)lng));
foreach (PatientData pd in pdc)
{
if (pd.Latitude == lat && pd.Longitude == lng)
continue;
// hook points to the route-network.
var resolved2 = router.Resolve (Vehicle.Car, new OsmSharp.Math.Geo.GeoCoordinate ((double)pd.Latitude, (double)pd.Longitude));
// calculate route.
var route = router.Calculate (Vehicle.Car, resolved1, resolved2);
Console.WriteLine ("{0} -> {1} = {2}", pdc [i].Address, pd.Address, route.TotalDistance);
}
}
}
ERROR: 2015-07-28 11:26:51 Object reference not set to an instance of an object
ERROR: 2015-07-28 11:26:51 at OsmSharp.Routing.Router.Calculate (OsmSharp.Routing.Vehicles.Vehicle vehicle, OsmSharp.Routing.RouterPoint source, OsmSharp.Routing.RouterPoint target) [0x00000] in /home/mkj/Projects/OsmSharp/OsmSharp.Routing/Router.cs:177
Using the latest from master.