Example #1
0
 private void TryCreateDefaultArg(IRasterDataProvider srcRaster, HDF4FilePrjSettings prjSettings, ref ISpatialReference dstSpatialRef)
 {
     if (dstSpatialRef == null)
     {
         dstSpatialRef = _srcSpatialRef;
     }
     if (string.IsNullOrWhiteSpace(prjSettings.OutFormat))
     {
         prjSettings.OutFormat = "LDF";
     }
     if (dstSpatialRef.ProjectionCoordSystem == null)
     {
         _srcImgResolution = 0.01f;
     }
     else
     {
         _srcImgResolution = 0.01f;
     }
     if (prjSettings.OutResolutionX == 0 || prjSettings.OutResolutionY == 0)
     {
         if (dstSpatialRef.ProjectionCoordSystem == null)
         {
             prjSettings.OutResolutionX = 0.01f;
             prjSettings.OutResolutionY = 0.01f;
         }
         else
         {
             prjSettings.OutResolutionX = 1000f;
             prjSettings.OutResolutionY = 1000f;
         }
     }
 }
Example #2
0
        private HDF4FilePrjSettings ArgsCheck(IRasterDataProvider srcRaster, FilePrjSettings prjSettings, Action <int, string> progressCallback)
        {
            if (srcRaster == null)
            {
                throw new ArgumentNullException("srcRaster", "待投影数据为空");
            }
            if (prjSettings == null)
            {
                throw new ArgumentNullException("prjSettings", "投影参数为空");
            }
            HDF4FilePrjSettings _prjSettings = prjSettings as HDF4FilePrjSettings;

            if (_prjSettings.LocationFile == null)
            {
                throw new ArgumentNullException("prjSettings.LocationFile", "L2L3级轨道数据投影未设置经纬度数据集文件");
            }
            return(_prjSettings);
        }
Example #3
0
        private IRasterBand[] TryCreateRasterDataBands(IRasterDataProvider srcRaster, HDF4FilePrjSettings prjSettings, Action <int, string> progressCallback)
        {
            IBandProvider      srcbandpro  = srcRaster.BandProvider as IBandProvider;
            int                count       = srcRaster.BandCount;
            List <IRasterBand> rasterBands = new List <IRasterBand>();

            for (int i = 0; i < count; i++)
            {
                if (progressCallback != null)
                {
                    progressCallback(_readyProgress++, "准备第" + i + "个输入数据通道");
                }
                IRasterBand band = srcRaster.GetRasterBand(i + 1);
                rasterBands.Add(band);
            }
            return(rasterBands.ToArray());
        }
Example #4
0
 private void DoSession(IRasterDataProvider srcRaster, ISpatialReference dstSpatialRef, HDF4FilePrjSettings prjSettings, Action <int, string> progressCallback)
 {
     if (_curSession == null || _curSession != srcRaster || _isBeginSession)
     {
         IRasterDataProvider locationRester = prjSettings.LocationFile;
         ReadyLocations(locationRester, dstSpatialRef, out _xs, out _ys, out _maxPrjEnvelope, out _srcLocationSize, progressCallback);
         if (progressCallback != null)
         {
             progressCallback(_readyProgress++, "准备其他参数");
         }
         //if (prjSettings.IsSolarZenith && prjSettings.IsRadiation)
         //{
         //    _szDataFilename = GetSolarZenithCacheFilename(locationRester.fileName);
         //    if (!File.Exists(_szDataFilename))
         //        ReadySolarZenithArgsToFile(locationRester);
         //    else
         //        _solarZenithCacheRaster = GeoDataDriver.Open(_szDataFilename) as IRasterDataProvider;
         //    if (prjSettings.IsSensorZenith)
         //    {
         //        ReadySensorZenith(locationRester);
         //    }
         //}
         _rasterDataBands = TryCreateRasterDataBands(srcRaster, prjSettings, progressCallback);
         _isBeginSession  = false;
     }
 }
Example #5
0
 private void SetPrjBand(HDF4FilePrjSettings prjSettings, PrjBand[] defaultPrjBands)
 {
 }
Example #6
0
        private void ReadyArgs(IRasterDataProvider srcRaster, FilePrjSettings prjSettings, ISpatialReference dstSpatialRef, Action <int, string> progressCallback)
        {
            float resolutionScale = 1f;

            _readyProgress = 0;
            if (progressCallback != null)
            {
                progressCallback(_readyProgress++, "准备相关参数");
            }
            if (dstSpatialRef == null)
            {
                dstSpatialRef = SpatialReference.GetDefault();
            }
            _dstSpatialRef = dstSpatialRef;
            _prjSettings   = ArgsCheck(srcRaster, prjSettings, progressCallback);
            //_fileType = CheckFile(srcRaster);
            _locationRaster = (prjSettings as HDF4FilePrjSettings).LocationFile;
            ReadExtArgs(prjSettings);
            TryCreateDefaultArg(srcRaster, _prjSettings, ref _dstSpatialRef);
            _left  = 0;
            _right = 0;
            TrySetLeftRightInvalidPixel(_prjSettings.ExtArgs);
            DoSession(srcRaster, _dstSpatialRef, _prjSettings, progressCallback);
            if (_prjSettings.OutEnvelope == null || _prjSettings.OutEnvelope == PrjEnvelope.Empty)
            {
                _prjSettings.OutEnvelope = _maxPrjEnvelope;
                _orbitBlock = new Block {
                    xOffset = 0, yBegin = 0, xEnd = srcRaster.Width - 1, yEnd = srcRaster.Height - 1
                };
            }
            else
            {
                GetEnvelope(_xs, _ys, _srcLocationSize.Width, _srcLocationSize.Height, _prjSettings.OutEnvelope, out _orbitBlock);
                if (_orbitBlock == null || _orbitBlock.Width <= 0 || _orbitBlock.Height <= 0)
                {
                    throw new Exception("数据不在目标区间内");
                }
                float invalidPresent = (_orbitBlock.Width * _orbitBlock.Height * resolutionScale) / (srcRaster.Width * srcRaster.Height);
                if (invalidPresent < 0.0001f)
                {
                    throw new Exception("数据占轨道数据比例太小,有效率" + invalidPresent * 100 + "%");
                }
                if (invalidPresent > 0.60f)
                {
                    _orbitBlock = new Block {
                        xOffset = 0, yBegin = 0, xEnd = srcRaster.Width - 1, yEnd = srcRaster.Height - 1
                    }
                }
                ;
            }
            _dstEnvelope = _prjSettings.OutEnvelope;
            if (!_dstEnvelope.IntersectsWith(_maxPrjEnvelope))
            {
                throw new Exception("数据不在目标区间内");
            }
            _outResolutionX = _prjSettings.OutResolutionX;
            _outResolutionY = _prjSettings.OutResolutionY;
            _outFormat      = _prjSettings.OutFormat;
            _outfilename    = _prjSettings.OutPathAndFileName;
            _dstProj4       = _dstSpatialRef.ToProj4String();
            //_dstBandCount = _prjBands.Length;
            _dstBandCount = _rasterDataBands.Length;
            _dstSize      = _prjSettings.OutSize;
            //_isRadiation = _prjSettings.IsRadiation;
            //_isSolarZenith = _prjSettings.IsSolarZenith;
            //_isSensorZenith = _prjSettings.IsSensorZenith;
        }