Ejemplo n.º 1
0
// [Test()]
        public void ExecuteDatabaseRenderer()
        {
            var start = DateTime.Now;

            System.Diagnostics.Debug.WriteLine(string.Format("Start: {0}", DateTime.Now.ToString("hh:mm:ss.fff")));
            var filename       = PortablePath.Combine(new string[] { "andorra.map" });
            var file           = FileSystem.Current.LocalStorage.GetFileAsync(PortablePath.Combine(new string[] { "andorra.map" })).Result;
            var mapFile        = new MapFile(FileSystem.Current.LocalStorage.GetFileAsync(PortablePath.Combine(new string[] { "andorra.map" })).Result);
            var graphicFactory = new SkiaGraphicFactory();
            var tileCache      = new InMemoryTileCache(20);
            var labelStore     = new TileBasedLabelStore(1000);

            //var renderer = new DatabaseRenderer(mapFile, graphicFactory, tileCache);
            var renderer = new DatabaseRenderer(mapFile, graphicFactory, labelStore);

            var renderTheme       = ExternalRenderTheme.CreateExternalRenderTheme(PortablePath.Combine(new string[] { "osmarender", "osmarender.xml" }));
            var displayModel      = new DisplayModel();
            var renderThemeFuture = new RenderThemeFuture(graphicFactory, renderTheme, displayModel);
            // Andorra
            var tile           = new Tile(33047, 24202, 16, 256);
            var neighbourTiles = tile.Neighbours;

            System.Diagnostics.Debug.WriteLine(string.Format("Before RenderJob: {0}", DateTime.Now.ToString("hh:mm:ss.fff")));
            var renderJob = new RendererJob(tile, mapFile, renderThemeFuture, displayModel, 1, false, false);

            System.Diagnostics.Debug.WriteLine(string.Format("After RenderJob: {0}", DateTime.Now.ToString("hh:mm:ss.fff")));

            System.Diagnostics.Debug.WriteLine(string.Format("Before ExecuteJob: {0}", DateTime.Now.ToString("hh:mm:ss.fff")));
            var tileImage = renderer.ExecuteJob(renderJob);

            System.Diagnostics.Debug.WriteLine(string.Format("After ExecuteJob: {0}", DateTime.Now.ToString("hh:mm:ss.fff")));

            System.Diagnostics.Debug.WriteLine(string.Format("Before Neighbours ExecuteJob: {0}", DateTime.Now.ToString("hh:mm:ss.fff")));
            foreach (Tile neighbourTile in neighbourTiles)
            {
                renderJob = new RendererJob(neighbourTile, mapFile, renderThemeFuture, displayModel, 1, false, true);
                renderer.ExecuteJob(renderJob);
            }
            System.Diagnostics.Debug.WriteLine(string.Format("After Neighbours ExecuteJob: {0}", DateTime.Now.ToString("hh:mm:ss.fff")));

            System.Diagnostics.Debug.WriteLine(string.Format("Before image write: {0}", DateTime.Now.ToString("hh:mm:ss.fff")));
            var output = FileSystem.Current.LocalStorage.CreateFileAsync($"Tile.{tile.TileX}.{tile.TileY}.{tile.ZoomLevel}.png", CreationCollisionOption.ReplaceExisting).Result;

            using (var outputStream = output.OpenAsync(FileAccess.ReadAndWrite).Result)
            {
                tileImage.Encode().AsStream().CopyTo(outputStream);
            }
            output = null;
            System.Diagnostics.Debug.WriteLine(string.Format("After image write: {0}", DateTime.Now.ToString("hh:mm:ss.fff")));
            System.Diagnostics.Debug.WriteLine(string.Format("End: {0}", DateTime.Now.ToString("hh:mm:ss.fff")));
            System.Diagnostics.Debug.WriteLine(string.Format("Time to render: {0}", (DateTime.Now - start).ToString()));
        }
Ejemplo n.º 2
0
//        [Test()]
        public void ExecuteDatabaseRenderer()
        {
            var start = DateTime.Now;

            System.Diagnostics.Debug.WriteLine(string.Format("Start: {0}", DateTime.Now.ToString("hh:mm:ss.fff")));
            var filename       = PortablePath.Combine(new string[] { "baden-wuerttemberg.map" });
            var file           = FileSystem.Current.LocalStorage.GetFileAsync(PortablePath.Combine(new string[] { "baden-wuerttemberg.map" })).Result;
            var mapFile        = new MapFile(FileSystem.Current.LocalStorage.GetFileAsync(PortablePath.Combine(new string[] { "baden-wuerttemberg.map" })).Result);
            var graphicFactory = new SkiaGraphicFactory();
            var tileCache      = new InMemoryTileCache(20);

            var renderer = new DatabaseRenderer(mapFile, graphicFactory, tileCache);

            var renderTheme       = ExternalRenderTheme.CreateExternalRenderTheme(PortablePath.Combine(new string[] { "osmarender", "osmarender.xml" }));
            var displayModel      = new DisplayModel();
            var renderThemeFuture = new RenderThemeFuture(graphicFactory, renderTheme, displayModel);

            System.Diagnostics.Debug.WriteLine(string.Format("Before RenderJob: {0}", DateTime.Now.ToString("hh:mm:ss.fff")));
            var renderJob = new RendererJob(new Tile(4306, 2831, 13, 256), mapFile, renderThemeFuture, displayModel, 1, false, false);

            //var renderJob = new RendererJob(new core.model.Tile(17220, 11324, 15, 256), mapFile, renderThemeFuture, displayModel, 1, false, false);
            //var renderJob = new RendererJob(new core.model.Tile(34440, 22648, 16, 256), mapFile, renderThemeFuture, displayModel, 1, false, false);
            //var renderJob = new RendererJob(new core.model.Tile(68881, 45297, 17, 256), mapFile, renderThemeFuture, displayModel, 1, false, false);
            System.Diagnostics.Debug.WriteLine(string.Format("After RenderJob: {0}", DateTime.Now.ToString("hh:mm:ss.fff")));

            System.Diagnostics.Debug.WriteLine(string.Format("Before ExecuteJob: {0}", DateTime.Now.ToString("hh:mm:ss.fff")));
            var tile = renderer.ExecuteJob(renderJob);

            System.Diagnostics.Debug.WriteLine(string.Format("After ExecuteJob: {0}", DateTime.Now.ToString("hh:mm:ss.fff")));

            System.Diagnostics.Debug.WriteLine(string.Format("Before image write: {0}", DateTime.Now.ToString("hh:mm:ss.fff")));
            var output = FileSystem.Current.LocalStorage.CreateFileAsync("Tile.4305.2831.13.png", CreationCollisionOption.ReplaceExisting).Result;

            using (var outputStream = output.OpenAsync(FileAccess.ReadAndWrite).Result)
            {
                tile.Encode().AsStream().CopyTo(outputStream);
            }
            output = null;
            System.Diagnostics.Debug.WriteLine(string.Format("After image write: {0}", DateTime.Now.ToString("hh:mm:ss.fff")));
            System.Diagnostics.Debug.WriteLine(string.Format("End: {0}", DateTime.Now.ToString("hh:mm:ss.fff")));
            System.Diagnostics.Debug.WriteLine(string.Format("Time to render: {0}", (DateTime.Now - start).ToString()));
        }