Beispiel #1
0
        protected override async Task <byte[]> LoadHgtDataFromFileAsync(HgtCellCoords coords, string filePath)
        {
            using (var zipArchive = ZipFile.OpenRead(filePath))
            {
                var entry = zipArchive.Entries.Single();

                long length = entry.Length;
                if (!HgtUtils.IsDataLengthValid(length))
                {
                    throw new HgtFileInvalidException(coords, string.Format("Invalid length - {0} bytes", length));
                }

                using (var zipStream = entry.Open())
                {
                    return(await LoadHgtDataFromStreamAsync(zipStream));
                }
            }
        }
Beispiel #2
0
        public IHgtDataCell GetCellFor(HgtCellCoords coords)
        {
            var path = _pathResolver.FindFilePath(coords);

            FileStream file = null;

            try
            {
                int fileSize = (int)new FileInfo(path).Length;
                file = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read);
                return(new HgtDataCellInFile(file, HgtUtils.PointsPerCellFromDataLength(fileSize), coords));
            }
            catch (Exception)
            {
                if (file != null)
                {
                    file.Dispose();
                }
                throw;
            }
        }
        public async Task <IHgtDataCell> GetCellForAsync(HgtCellCoords coords)
        {
            var data = await _loader.LoadFromFileAsync(coords);

            return(new HgtDataCellInMemory(data, HgtUtils.PointsPerCellFromDataLength(data.Length), coords));
        }
        public IHgtDataCell GetCellFor(HgtCellCoords coords)
        {
            var data = _loader.LoadFromFile(coords);

            return(new HgtDataCellInMemory(data, HgtUtils.PointsPerCellFromDataLength(data.Length), coords));
        }