public TileRecord( Canvas layerCanvas, TilePyramidDescriptor tilePyramidDescriptor, TileId tileId) { tilePyramidCanvas = layerCanvas; this.tilePyramidDescriptor = tilePyramidDescriptor; this.tileId = tileId; visible = false; WillNeverBeAvailable = false; }
public RasterTileSource(long logicalFinestLodWidth, long logicalFinestLodHeight, int tileWidth, int tileHeight, int logicalMinimumLevelOfDetail, RasterTileDownloader rasterTileDownloader, TileWrap tileWrap, int log2DuplicatePyramidCount, bool useGlobalMemoryCache = true) { if (logicalFinestLodWidth <= 0L) { throw new ArgumentOutOfRangeException(nameof(logicalFinestLodWidth)); } if (logicalFinestLodHeight <= 0L) { throw new ArgumentOutOfRangeException(nameof(logicalFinestLodHeight)); } if (tileWidth <= 0) { throw new ArgumentOutOfRangeException(nameof(tileWidth)); } if (tileHeight <= 0) { throw new ArgumentOutOfRangeException(nameof(tileHeight)); } if (rasterTileDownloader is null) { throw new ArgumentNullException(nameof(rasterTileDownloader)); } if (tileWrap == TileWrap.None) { throw new ArgumentException("tileWrap must horizontal, vertical, or both."); } if (log2DuplicatePyramidCount < 1) { throw new ArgumentOutOfRangeException(nameof(log2DuplicatePyramidCount)); } finestLodWidth = logicalFinestLodWidth << log2DuplicatePyramidCount; finestLodHeight = logicalFinestLodHeight << log2DuplicatePyramidCount; this.tileWidth = tileWidth; this.tileHeight = tileHeight; minimumLevelOfDetail = logicalMinimumLevelOfDetail + log2DuplicatePyramidCount; var logicalTilePyramidDescriptor = new TilePyramidDescriptor(logicalFinestLodWidth, logicalFinestLodHeight, logicalMinimumLevelOfDetail, tileWidth, tileHeight); tileIdTransform = tileId => { var lod = tileId.LevelOfDetail - log2DuplicatePyramidCount; var detailWidthInTiles = logicalTilePyramidDescriptor.GetLevelOfDetailWidthInTiles(lod); var detailHeightInTiles = logicalTilePyramidDescriptor.GetLevelOfDetailHeightInTiles(lod); return(new TileId(tileId.LevelOfDetail - log2DuplicatePyramidCount, tileWrap == TileWrap.Horizontal || tileWrap == TileWrap.Both ? tileId.X % detailWidthInTiles : tileId.X, tileWrap == TileWrap.Vertical || tileWrap == TileWrap.Both ? tileId.Y % detailHeightInTiles : tileId.Y)); }; transform = VectorMath.TranslationMatrix3D(tileWrap == TileWrap.Horizontal || tileWrap == TileWrap.Both ? -finestLodWidth / 2L : 0.0, tileWrap == TileWrap.Vertical || tileWrap == TileWrap.Both ? -finestLodHeight / 2L : 0.0, 0.0) * VectorMath.ScalingMatrix3D(1 << log2DuplicatePyramidCount, 1 << log2DuplicatePyramidCount, 1.0); ConstructCommon(rasterTileDownloader, useGlobalMemoryCache); }
public TilePyramid( TilePyramidDescriptor tilePyramidDescriptor, TileSource tileSource, Canvas parentCanvas) { if (tilePyramidDescriptor is null) { throw new ArgumentNullException(nameof(tilePyramidDescriptor)); } if (tileSource is null) { throw new ArgumentNullException(nameof(tileSource)); } if (parentCanvas is null) { throw new ArgumentNullException(nameof(parentCanvas)); } if (tilePyramidDescriptor.FinestLevelWidth != tileSource.FinestLodWidth || tilePyramidDescriptor.FinestLevelHeight != tileSource.FinestLodHeight) { throw new ArgumentException("Tile pyramid descriptor and tile source sizes must match."); } TilePyramidDescriptor = tilePyramidDescriptor; this.parentCanvas = parentCanvas; TileSource = tileSource; TileSource.NewTilesAvailable += new EventHandler(TileSource_NewTilesAvailable); var canvas = new Canvas { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, UseLayoutRounding = false, IsHitTestVisible = false, Tag = "TilePyramidCanvas" }; tilePyramidCanvas = canvas; Canvas.SetLeft(tilePyramidCanvas, 0.0); Canvas.SetTop(tilePyramidCanvas, 0.0); this.parentCanvas.Children.Add(tilePyramidCanvas); ChooseLevelOfDetailSettings = DownloadFinestNLevelsOfDetailNeeded(3, true, true); levelOfDetailSettings = new List <LevelOfDetailSettings?>(tileSource.MaximumLevelOfDetail); for (var index = 0; index <= tileSource.MaximumLevelOfDetail; ++index) { levelOfDetailSettings.Add(new LevelOfDetailSettings?(new LevelOfDetailSettings(false, 0.0, new int?()))); } coverageMap = new TilePyramidCoverageMap(tileSource.MinimumLevelOfDetail, tileSource.MaximumLevelOfDetail); }
public RasterTileCache(TilePyramidDescriptor tilePyramidDescriptor, RasterTileDownloader rasterTileDownloader, TransformTileId transformTileId, bool useGlobalMemoryCache) { this.tilePyramidDescriptor = tilePyramidDescriptor; this.rasterTileDownloader = rasterTileDownloader; this.transformTileId = transformTileId; this.useGlobalMemoryCache = useGlobalMemoryCache; rasterTileCacheId = nextRasterTileCacheId++; if (this.transformTileId is null) { this.transformTileId = tileId => tileId; } if (useGlobalMemoryCache) { return; } rasterTileCacheValues = new Dictionary <TileId, RasterTileCacheValue>(); relevantTransformedTileIds = new HashSet <TileId>(); rasterTileCacheValuesToRemove = new List <TileId>(); }
public void Initialize( TilePyramidDescriptor tilePyramid, ref Matrix3D renderableToViewportTransform, Point2D viewportSize, TileId visibleTileId) { VisibleTileId = visibleTileId; viewportCenter = 0.5 * viewportSize; bucketRadiusInterval = 0.5 * Math.Sqrt(viewportSize.X * viewportSize.X + viewportSize.Y * viewportSize.Y) / 5.0 - 1.0; lod = visibleTileId.LevelOfDetail; tileWidthAtFinestLod = tilePyramid.TileWidth * (1 << tilePyramid.FinestLevelOfDetail - lod); tileHeightAtFinestLod = tilePyramid.TileHeight * (1 << tilePyramid.FinestLevelOfDetail - lod); vTL0 = VectorMath.Transform(renderableToViewportTransform, new Point4D(tileWidthAtFinestLod * visibleTileId.X, tileHeightAtFinestLod * visibleTileId.Y, 0.0, 1.0)); var point4D1 = VectorMath.Transform(renderableToViewportTransform, new Point4D(tileWidthAtFinestLod * (visibleTileId.X + 1L), tileHeightAtFinestLod * visibleTileId.Y, 0.0, 1.0)); var point4D2 = VectorMath.Transform(renderableToViewportTransform, new Point4D(tileWidthAtFinestLod * visibleTileId.X, tileHeightAtFinestLod * (visibleTileId.Y + 1L), 0.0, 1.0)); vR = point4D1 - vTL0; vD = point4D2 - vTL0; }
private void ConstructCommon(RasterTileDownloader rasterTileDownloader, bool useGlobalMemoryCache) { tilePyramidDescriptor = new TilePyramidDescriptor(finestLodWidth, finestLodHeight, minimumLevelOfDetail, tileWidth, tileHeight); maximumLevelOfDetail = tilePyramidDescriptor.FinestLevelOfDetail; if (minimumLevelOfDetail < 0 || minimumLevelOfDetail > maximumLevelOfDetail) { throw new ArgumentException("minimumLevelOfDetail must be in range [0, finest level of detail]."); } rasterTileImageCache = new RasterTileCache(tilePyramidDescriptor, rasterTileDownloader, tileIdTransform, useGlobalMemoryCache); rasterTileImageCache.NewTilesAvailable += (sender, e) => { if (NewTilesAvailable is null) { return; } NewTilesAvailable(this, EventArgs.Empty); }; TileFadeInDuration = new TimeSpan?(TimeSpan.FromMilliseconds(300.0)); }