Skip to content

Instantly share code, notes, and snippets.

@xivk
Created July 20, 2014 15:56
Show Gist options
  • Save xivk/d01c899f5ff46b9f2146 to your computer and use it in GitHub Desktop.
Save xivk/d01c899f5ff46b9f2146 to your computer and use it in GitHub Desktop.
using OsmSharp.Collections.Tags;
using OsmSharp.Routing;
using OsmSharp.Routing.CH;
using OsmSharp.Routing.Osm.Interpreter;
using System.IO;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
// create serializer.
var routingSerializer = new OsmSharp.Routing.CH.Serialization.Sorted.CHEdgeDataDataSourceSerializer();
// serialize/deserialize.
var metaData = new TagsCollection();
var graph = routingSerializer.Deserialize(new FileInfo(@"C:\Users\xivk\Downloads\Routes.osm.routing").OpenRead(), false)
var router = Router.CreateCHFrom(graph, new CHRouter(), new OsmRoutingInterpreter());
var resolved1 = router.Resolve(Vehicle.Car, new OsmSharp.Math.Geo.GeoCoordinate(47.4234351, -103.3960672));
var resolved2 = router.Resolve(Vehicle.Car, new OsmSharp.Math.Geo.GeoCoordinate(46.8108147, -102.7004338));
var route = router.Calculate(Vehicle.Car, resolved1, resolved2);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment