Beispiel #1
0
        private async Task <IFeature?> ToFeatureAsync(TileInfo tileInfo)
        {
            var tileData = await _tileSource.GetTileAsync(tileInfo);

            var mRaster = ToRaster(tileInfo, tileData);

            if (mRaster != null)
            {
                return(new RasterFeature(mRaster));
            }

            return(null);
        }
Beispiel #2
0
        private static async Task <List <RasterFeature> > TileIndexToFeaturesAsync(TileIndex[] tileIndexes, ITileSource tileSource)
        {
            var features = new List <RasterFeature>();

            foreach (var tileIndex in tileIndexes)
            {
                var tileInfo = new TileInfo
                {
                    Index  = tileIndex,
                    Extent = TileTransform.TileToWorld(
                        new TileRange(tileIndex.Col, tileIndex.Row), tileIndex.Level, tileSource.Schema)
                };

                var raster = new MRaster(await tileSource.GetTileAsync(tileInfo), tileInfo.Extent.ToMRect());
                features.Add(new RasterFeature(raster));
            }
            return(features);
        }
Beispiel #3
0
        private async Task <RasterFeature> TileToFeatureAsync(ITileSource tileProvider, TileInfo tileInfo)
        {
            var tile = await tileProvider.GetTileAsync(tileInfo);

            // A tile layer can return a null value. This indicates the tile is not
            // present in the source, permanently. If this is the case no further
            // requests should be done. To avoid further fetches a feature should
            // be returned with the Geometry set to null. If a null Feature is returned
            // this equates to having no tile at all and attempts to fetch the tile will
            // continue. TileLayer.ToGeometry() follows the same implementations.
            //
            // Note, the fact that we have to define this complex method on the outside
            // indicates a design flaw.
            if (tile == null)
            {
                return(new RasterFeature((MRaster?)null));
            }
            return(new RasterFeature(new MRaster(tile, tileInfo.Extent.ToMRect())));
        }
Beispiel #4
0
        private static async Task <List <Models.TileDataset> > GetSourceTilesAsync(
            ITileSource source,
            IList <Models.TileCoordinates> tileCoordinates)
        {
            var sourceTiles = new List <Models.TileDataset>(tileCoordinates.Count);

            foreach (var tc in tileCoordinates)
            {
                // 180 degrees
                var tileCount = U.WebMercator.TileCount(tc.Z);
                var x         = tc.X % tileCount;

                var tileData = await source.GetTileAsync(x, U.WebMercator.FlipYCoordinate(tc.Y, tc.Z), tc.Z);

                if (tileData != null)
                {
                    sourceTiles.Add(new Models.TileDataset(tc.X, tc.Y, tc.Z, tileData));
                }
            }

            return(sourceTiles);
        }