Example #1
0
        public short[] LoadElevationMap(TileInfo tileInfo)
        {
            MemoryStream memoryStream;

            if (tileInfo.FileName.EndsWith(".zip", StringComparison.OrdinalIgnoreCase))
            {
                memoryStream = GeoTiffHelper.GetZippedTiffStream(GetFileStream(tileInfo.FileName));
            }
            else
            {
                memoryStream = GetFileStream(tileInfo.FileName);
            }
            using var tiff = GeoTiffHelper.TiffFromStream(memoryStream);
            return(GeoTiffHelper.GetElevationMap(tiff));
        }
Example #2
0
        private void CreateSubtiles(TileInfo tileInfo, DirectoryInfo targetDirectory, int height, int width, SubTileInfo[] subtilesInfo)
        {
            using var tiff = GeoTiffHelper.TiffFromFile(_sourceRepository.GetFile(tileInfo));

            short[] elevationMap = GeoTiffHelper.GetElevationMap(tiff);

            subtilesInfo.AsParallel()
            .WithDegreeOfParallelism(4)
            .ForAll(CreateSubtileZip);

            void CreateSubtileZip(SubTileInfo subTileInfo)
            {
                var subTileData = GetSubTileData(tileInfo, subTileInfo, width, height, elevationMap);

                if (subTileData.Any(v => v != 0))
                {
                    var(north, west, subTileName) = (subTileInfo.North, subTileInfo.West, subTileInfo.SubtileName);
                    using var subTileTiffStream   = GeoTiffHelper.CreateGeoTiff(tiff, subTileName, north, west, width, height, subTileData);
                    SaveTile(targetDirectory, subTileName, subTileTiffStream);
                }
            }
        }