Ejemplo n.º 1
0
 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>();
 }
Ejemplo n.º 2
0
 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));
 }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
 public RasterTileSource(long finestLodWidth, long finestLodHeight, int tileWidth, int tileHeight, int minimumLevelOfDetail, RasterTileDownloader rasterTileDownloader, bool useGlobalMemoryCache = true)
 {
     if (finestLodWidth <= 0L)
     {
         throw new ArgumentOutOfRangeException(nameof(finestLodWidth));
     }
     if (finestLodHeight <= 0L)
     {
         throw new ArgumentOutOfRangeException(nameof(finestLodHeight));
     }
     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));
     }
     this.finestLodWidth       = finestLodWidth;
     this.finestLodHeight      = finestLodHeight;
     this.tileWidth            = tileWidth;
     this.tileHeight           = tileHeight;
     this.minimumLevelOfDetail = minimumLevelOfDetail;
     ConstructCommon(rasterTileDownloader, useGlobalMemoryCache);
 }