static void Main(string[] args)
        {
            // enable logging and use the console as output.
            OsmSharp.Logging.Log.Enable();
            OsmSharp.Logging.Log.RegisterListener(
                new OsmSharp.WinForms.UI.Logging.ConsoleTraceListener());

            // create router.
            using (var source = new FileInfo(@"kempen.osm.pbf").OpenRead())
            {
                var pbfSource = new PBFOsmStreamSource(source);
                var progress = new OsmStreamFilterProgress();
                progress.RegisterSource(pbfSource);
                var router = Router.CreateFrom(progress, new OsmRoutingInterpreter());

                OsmSharp.Service.Routing.ApiBootstrapper.Add("default", router);
            }

            // initialize mapcss interpreter.
            var mapCSSInterpreter = new MapCSSInterpreter(
                Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Service.Routing.Sample.SelfHost.custom.mapcss"),
                new MapCSSDictionaryImageSource());

            using (var source = new FileInfo(@"kempen.osm.pbf").OpenRead())
            {
                var pbfSource = new PBFOsmStreamSource(source);
                var scene = new Scene2D(new OsmSharp.Math.Geo.Projections.WebMercator(), new List<float>(new float[] {
                16, 14, 12, 10 }));
                var target = new StyleOsmStreamSceneTarget(
                    mapCSSInterpreter, scene, new WebMercator());
                var progress = new OsmStreamFilterProgress();
                progress.RegisterSource(pbfSource);
                target.RegisterSource(progress);
                target.Pull();

                // create a new instance (with a cache).
                var instance = new RenderingInstance();
                instance.Map.AddLayer(new LayerScene(scene));

                // add a default test instance.
                OsmSharp.Service.Tiles.ApiBootstrapper.AddInstance("default", instance);
            }

            var uri = new Uri("http://*****:*****@ http://localhost:1234");
                System.Diagnostics.Process.Start("http://localhost:1234/default");

                Console.ReadLine();
            }
        }
        /// <summary>
        /// Builds a rendering instance.
        /// </summary>
        /// <param name="streamSource">Source data.</param>
        /// <param name="interpreter">The style interpreter.</param>
        /// <returns></returns>
        public static RenderingInstance Build(OsmStreamSource streamSource, StyleInterpreter interpreter)
        {
            var instance = new RenderingInstance();

            // load data into memory.
            var dataSource = MemoryDataSource.CreateFrom(streamSource);

            // add layer to map.
            instance.Map.AddLayer(new LayerOsm(dataSource, interpreter, instance.Map.Projection));

            return(instance);
        }
        /// <summary>
        /// Builds a rendering instance for a mapCSS file.
        /// </summary>
        /// <param name="streamSource"></param>
        /// <param name="mapCSSFile"></param>
        /// <returns></returns>
        public static RenderingInstance BuildForMapCSS(OsmStreamSource streamSource, Stream mapCSSFile)
        {
            var instance = new RenderingInstance();

            // load data into memory.
            var dataSource = MemoryDataSource.CreateFrom(streamSource);

            // create mapCSS interpreter.
            var interpreter = new MapCSSInterpreter(mapCSSFile, new MapCSSDictionaryImageSource());

            // add layer to map.
            instance.Map.AddLayer(new LayerOsm(dataSource, interpreter, instance.Map.Projection));

            return(instance);
        }
 /// <summary>
 /// Adds a new rendering instance.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="instance"></param>
 public static void AddInstance(string name, RenderingInstance instance)
 {
     _instances[name] = instance;
 }
        /// <summary>
        /// Builds a rendering instance for a mapCSS file.
        /// </summary>
        /// <param name="streamSource"></param>
        /// <param name="mapCSSFile"></param>
        /// <returns></returns>
        public static RenderingInstance BuildForMapCSS(OsmStreamSource streamSource, Stream mapCSSFile)
        {
            var instance = new RenderingInstance();

            // load data into memory.
            var dataSource = MemoryDataSource.CreateFrom(streamSource);

            // create mapCSS interpreter.
            var interpreter = new MapCSSInterpreter(mapCSSFile, new MapCSSDictionaryImageSource());

            // add layer to map.
            instance.Map.AddLayer(new LayerOsm(dataSource, interpreter, instance.Map.Projection));

            return instance;
        }
        /// <summary>
        /// Builds a rendering instance.
        /// </summary>
        /// <param name="streamSource">Source data.</param>
        /// <param name="interpreter">The style interpreter.</param>
        /// <returns></returns>
        public static RenderingInstance Build(OsmStreamSource streamSource, StyleInterpreter interpreter)
        {
            var instance = new RenderingInstance();

            // load data into memory.
            var dataSource = MemoryDataSource.CreateFrom(streamSource);

            // add layer to map.
            instance.Map.AddLayer(new LayerOsm(dataSource, interpreter, instance.Map.Projection));

            return instance;
        }
 /// <summary>
 /// Adds a new rendering instance.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="instance"></param>
 public static void AddInstance(string name, RenderingInstance instance)
 {
     _instances[name] = instance;
 }