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>
        /// Tests interpreting all data from a given pbf source.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="scene"></param>
        /// <param name="interpreter"></param>
        /// <param name="pbfSource"></param>
        public static Stream TestInterpret(string name, MapCSSInterpreter interpreter, Scene2D scene, string pbfSource)
        {
            StyleOsmStreamSceneTarget target = new StyleOsmStreamSceneTarget(
                interpreter, scene, new WebMercator());
            FileInfo testFile = new FileInfo(string.Format(@".\TestFiles\{0}", pbfSource));
            Stream stream = testFile.OpenRead();
            OsmStreamSource source = new PBFOsmStreamSource(stream);
            OsmStreamFilterProgress progress = new OsmStreamFilterProgress();
            progress.RegisterSource(source);
            target.RegisterSource(progress);

            PerformanceInfoConsumer performanceInfo = new PerformanceInfoConsumer(string.Format("{0}.Add", name));
            performanceInfo.Start();
            performanceInfo.Report("Interpreting style with objects from {0}...", pbfSource.ToString());

            target.Pull();

            performanceInfo.Stop();

            Console.Write("", scene.BackColor);
            stream.Dispose();

            return testFile.OpenRead();
        }
        /// <summary>
        /// Builds a tile server instance based on the given osm source and mapcss styles file.
        /// </summary>
        /// <param name="name">The name of the instance-to-be.</param>
        /// <param name="source">The osm source stream.</param>
        /// <param name="mapCSSfile">The stream containing the mapcss.</param>
        /// <param name="cacheFolder"></param>
        private static void BuildTileServer(string name, OsmStreamSource source, Stream mapCSSfile, string cacheFolder)
        {
            try
            {
                // initialize mapcss interpreter.
                var mapCSSInterpreter = new MapCSSInterpreter(mapCSSfile, new MapCSSDictionaryImageSource());

                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());
                target.RegisterSource(source);
                target.Pull();

                //var merger = new Scene2DObjectMerger();
                //scene = merger.BuildMergedScene(scene);

                OsmSharp.Service.Tiles.RenderingInstance instance = null;
                if (string.IsNullOrWhiteSpace(cacheFolder))
                { // no cache.
                    instance = new OsmSharp.Service.Tiles.RenderingInstance();
                }
                else
                { // use cache.
                    var instanceCacheFolder = Path.Combine(cacheFolder, name);
                    var instanceCacheDirectoryInfo = new DirectoryInfo(instanceCacheFolder);
                    if (!instanceCacheDirectoryInfo.Exists)
                    { // create the directory if it doesn't exists.
                        instanceCacheDirectoryInfo.Create();
                    }
                    var instanceCache = new OsmSharp.Service.Tiles.Cache.TileCache(new DirectoryInfo(instanceCacheFolder));
                    instanceCache.Clear();
                    instance = new OsmSharp.Service.Tiles.RenderingInstance(instanceCache);
                }
                instance.Map.AddLayer(new LayerScene(scene));

                // add a default test instance.
                OsmSharp.Service.Tiles.ApiBootstrapper.AddInstance(name, instance);
            }
            catch (Exception ex)
            {
                OsmSharp.Logging.Log.TraceEvent("Bootstrapper.BuildTileServer", OsmSharp.Logging.TraceEventType.Error,
                    "Failed to setup tile service: " + ex.Message);
            }
        }